fix(log): send the page's own log somewhere it can be read - #79
Merged
Conversation
`craft.log.{debug,info,warn,error}` reached `std.debug.print` on macOS and
nothing at all anywhere else: the write sat behind
`if (builtin.os.tag == .macos)`, so on Linux and Windows the payload was
parsed, discarded, and answered `{"ok":true}`. A page that logged into that got
a resolved promise and no record.
Even on macOS it went to stderr rather than through the host logger, so
`--log-file` — which now exists — did not contain it. A page's diagnostics and
the host's belong in one stream, in one order; splitting them across two
destinations on one platform and dropping them on the others is most of what
made the namespace useless.
Records are tagged `[page]` so it is obvious which side a line came from, an
unrecognised level is recorded as info rather than dropped, and the message is
clamped, because it comes from the page.
The `os_log_create` handle is gone. It was opened at init, never used, and the
comment beside it described a future revision that would reach `os_log`
properly through libBlocksRuntime — which never happened, and which a file sink
is a better answer to anyway.
The file had no tests, which is why nobody noticed two of the three platforms
recorded nothing.
✅ Binary load timeWhat this measures
Both binaries are measured interleaved on this runner and compared by |
✅ Binary Size Report
Size limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #70. That issue's ask was the
--log-fileflag, which #78 delivered — but it also noted, separately, that the page-facingcraft.log.*namespace was macOS-only and discarded its payload elsewhere. I didn't do that half, so here it is.What it did
On Linux and Windows the payload was parsed, discarded, and answered
{"ok":true}. A page that logged into that got a resolved promise and no record anywhere.On macOS it went to stderr rather than through the host logger — so
--log-file, which now exists, did not contain it either.What it does now
Page records go through
log.zig, the same sink--log-fileconfigures, on every platform:Verified by running the binary with
--log-file --log-quietand a page calling all four methods. Thedebugcall is correctly absent — default level is info — and appears when--log-level debugis passed.[page], because the host's records and the page's now share one stream and telling them apart is most of what makes that stream readable.The dead
os_loghandleos_log_create("com.craft.app", "default")was called at init, stored, and never used. The comment beside it described a future revision reachingos_logproperly through libBlocksRuntime — which never happened, and which a file sink is a better answer to. Removed rather than left as a placeholder for something that now has a better implementation.Tests
The file had none, which is why nobody noticed two of three platforms recorded nothing. The level mapping is now a pure function with 5 tests, wired into
zig build test— including that an invented level is still heard, and that the four levels the JS facade actually sends all map somewhere.Verified
zig build·zig build test·zig build test-js·x86_64-windowscross-build ·zig fmt --check· 511 bun tests · pickier 38 warnings, unchanged from main.