summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig
index 47121691..61c0049e 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -18,13 +18,29 @@ pub const std_options_debug_io: std.Io = if (is_emscripten)
else
std_options_debug_threaded_io.?.io();
-// ghostty-vt's stream logs every mode it doesn't implement, and in the tty
-// shell stderr IS the screen — the warning scribbles over the grid. macOS
-// bash/readline sends one such mode (1034, meta-key) on every startup, so
-// keep the stream scope to errors; linux shells just never tripped it.
-pub const std_options: std.Options = .{
- .log_scope_levels = &.{.{ .scope = .stream, .level = .err }},
-};
+// Every std.log call in the process — ours and every dependency's — funnels
+// through this one function. ghostty-vt narrates whatever it does not
+// implement in the bytes a child writes to its pty (`debug(stream)`,
+// `warning(stream): ignoring unimplemented CSI p`, `debug(kitty_gfx)`; opening
+// yazi is worth several lines before it has drawn anything), and in the tty
+// shell stderr IS the screen — those land on top of the rendered grid, and in
+// the gui/web shells on the console. So drop the libraries at every level: an
+// `err` painted over the UI is no better than a debug one. Only pardes' own
+// scopes get through, because their messages carry detail the error returns
+// don't (gui's SDL_GetError strings, dump's zon parse diagnostic) — .default
+// is NOT one of them, ghostty and uucode both log unscoped. Set PARDES_LOG to
+// get the real logger back: `PARDES_LOG=1 pardes 2>/tmp/pardes.log`.
+pub const std_options: std.Options = .{ .logFn = logFn };
+
+fn logFn(
+ comptime level: std.log.Level,
+ comptime scope: @EnumLiteral(),
+ comptime format: []const u8,
+ args: anytype,
+) void {
+ if (scope != .gui and scope != .dump and std.c.getenv("PARDES_LOG") == null) return;
+ std.log.defaultLog(level, scope, format, args);
+}
// A panic must restore the terminal (cooked mode, main screen, mouse off)
// before the trace prints, or it lands garbled in a raw alt screen. recover()