Files
Paradise/code/tests/test_log_format.dm
chuga-git 5c8ba2ee4e Ports rust_g -> rustlibs: logging, toml, dmi, json, and noisegen (#28858)
* Rustlibs logging, toml, dmi, and dbpnoise

* missed one

* Hopefully fix logging utf-8 decode errors

* Fuck

* Build Rust library

* ports rust_g json validator

* rustlibs_file clippy lint

* Build Rust library

* fix merge conflict

---------

Co-authored-by: paradisess13[bot] <165046124+paradisess13[bot]@users.noreply.github.com>
2025-04-11 17:45:45 +00:00

27 lines
1.0 KiB
Plaintext

// This exists so that logs are the designated format. If they arent, it breaks logging tooling. Also 8601 is king.
#define TEST_MESSAGE "Log time format test"
#define TEST_LOG_FILE "data/ci_testing.log"
/proc/generate_test_log_message(time)
var/date_portion = time2text(time, "YYYY-MM-DD")
var/time_portion = time2text(time, "hh:mm:ss")
return "\[[date_portion]T[time_portion]] [TEST_MESSAGE]"
/datum/game_test/log_format/Run()
// Generate a list of valid log timestamps. It can be the current time, or up to 2 seconds later to account for spurious CI lag
var/valid_lines = list(
"[generate_test_log_message(world.timeofday)]",
"[generate_test_log_message(world.timeofday + 10)]",
"[generate_test_log_message(world.timeofday + 20)]",
)
rustlibs_log_write(TEST_LOG_FILE, TEST_MESSAGE)
var/list/lines = file2list(TEST_LOG_FILE)
TEST_ASSERT(lines[1] in valid_lines, \
"Rustlibs log format is not valid 8601 format. Expected '[generate_test_log_message(world.timeofday)]', got '[lines[1]]'")
#undef TEST_MESSAGE
#undef TEST_LOG_FILE