Structured leveled logging for fastC.
Part of the fastc-core launch set. The implementation ships in the
fastC v1.0 prelude — every use log::* works out of the box.
use log::debug;
use log::info;
use log::warn;
use log::error;
use log::kv_int;
use log::kv_str;
// Threshold levels:
use log::level_debug; // 0
use log::level_info; // 1
use log::level_warn; // 2
use log::level_error; // 3
use log::info;
use log::warn;
use log::kv_int;
use log::kv_str;
fn main() -> i32 {
info(cstr("starting up"));
kv_str(cstr("user"), cstr("alice"));
kv_int(cstr("requests"), 42);
info(cstr("hourly stats"));
warn(cstr("disk usage high"));
return 0;
}
Outputs:
[INFO] starting up
user="alice" requests=42 [INFO] hourly stats
[WARN] disk usage high
kv_* helpers emit on the same line without a terminator and
pair with a closing info / warn / error call. All log
functions allocate nothing — safe inside @noalloc blocks.
v0.1.0 — preview. API is final; will become installable via
fastc add once consumption ships.
MIT