lib+test: add log over io.stream sink
Hare-shaped lib/log v1: logger vtable carrying one println slot, stdlogger forwarding to a *io.stream, plus *logger globals (silent / default / global), setlogger, lprintln / println, lfatal / fatal. Default sink is stderr through a private rt_syscall write callback; graduates with #17 (cgen mod-mangle for fn labels), at which point the rt_syscall stub disappears the same way fmt's will. Module-scope struct/pointer-literal init isn't constexpr in cstage emit_lets, so silent/default/global are wired lazily by ensureinit on the first exported-fn entry (lib/temp rnginit pattern). Callers that read the globals directly must call some lib/log fn first. Skipped this round: printfln / lprintfln / fatalf / lfatalf and the matching printfln vtable slot — they need a fmt {n}-placeholder parser that isn't shipped yet. fatal / lfatal's exit(255) arm has no test fixture (needs fork+wait for WEXITSTATUS); left as TODO. 971_log_run wraps the @test fixture under `ww run`, mirroring 970_fmt_run. make test: 54/54; bootstrap fixed-point (990-997) holds.
This commit is contained in:
6
Makefile
6
Makefile
@@ -230,7 +230,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_selfhost $(BIN)/test_w6a_ww $(BIN)/test_w6l_ww \
|
||||
$(BIN)/test_w6c_ww $(BIN)/test_ww_ww $(BIN)/test_self_rebuild \
|
||||
$(BIN)/test_dyn_ww $(BIN)/test_selfcheck $(BIN)/test_at_test_ww \
|
||||
$(BIN)/test_fmt_run \
|
||||
$(BIN)/test_fmt_run $(BIN)/test_log_run \
|
||||
$(BIN)/test_memio_run $(BIN)/test_temp_run $(BIN)/test_getopt_run \
|
||||
$(BIN)/test_base32_run $(BIN)/test_base64_run \
|
||||
$(BIN)/test_adler32_run $(BIN)/test_crc16_run \
|
||||
@@ -415,6 +415,10 @@ $(BIN)/test_fmt_run: test/wcc/970_fmt_run.c $(BIN)/ww $(BIN)/w6c \
|
||||
$(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_log_run: test/wcc/971_log_run.c $(BIN)/ww $(BIN)/w6c \
|
||||
$(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_memio_run: test/wcc/980_memio_run.c $(BIN)/ww $(BIN)/w6c \
|
||||
$(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
Reference in New Issue
Block a user