summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-27 00:34:10 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commit950a616e45f76349c3f029e6032cce7cadc2b4e3 (patch)
tree595b04e4863e2b62214223afc77244d6ef9987c4 /src
parenta1f26fc4977b185cbd603749157360c011452e5e (diff)
downloadpardes-950a616e45f76349c3f029e6032cce7cadc2b4e3.tar.gz
pardes-950a616e45f76349c3f029e6032cce7cadc2b4e3.zip
silence library std.log: ghostty-vt's unimplemented-sequence chatter was painting over the UI
Diffstat (limited to 'src')
-rw-r--r--src/dump.zig9
-rw-r--r--src/main.zig30
2 files changed, 30 insertions, 9 deletions
diff --git a/src/dump.zig b/src/dump.zig
index 06b9cec6..51221197 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -1,6 +1,11 @@
const std = @import("std");
const builtin = @import("builtin");
+// scoped, not bare std.log: main.zig's logFn drops the unscoped .default scope
+// wholesale (ghostty and uucode log there too), and a corrupt dump's parse
+// diagnostic is the only thing that says WHICH field went bad.
+const log = std.log.scoped(.dump);
+
/// Where the next dump goes. $PARDES_DUMP wins verbatim (the snapshot harness
/// pins it for deterministic goldens); else $XDG_DATA_HOME|~/.local/share
/// /pardes/pardes-<utc>.zon — timestamped so dumps never overwrite each other.
@@ -148,7 +153,7 @@ pub fn readZon(gpa: std.mem.Allocator, bytes: []const u8, label: []const u8) !St
pub fn readZonZ(gpa: std.mem.Allocator, source: [:0]const u8, label: []const u8) !State {
if (builtin.os.tag == .emscripten) {
const state = std.zon.parse.fromSliceAlloc(State, gpa, source, null, .{}) catch |err| {
- std.log.err("parse dump {s}: {s}", .{ label, @errorName(err) });
+ log.err("parse dump {s}: {s}", .{ label, @errorName(err) });
return err;
};
errdefer std.zon.parse.free(gpa, state);
@@ -159,7 +164,7 @@ pub fn readZonZ(gpa: std.mem.Allocator, source: [:0]const u8, label: []const u8)
var diag: std.zon.parse.Diagnostics = .{};
defer diag.deinit(gpa);
const state = std.zon.parse.fromSliceAlloc(State, gpa, source, &diag, .{}) catch |err| {
- std.log.err("parse dump {s}: {f}", .{ label, diag });
+ log.err("parse dump {s}: {f}", .{ label, diag });
return err;
};
errdefer std.zon.parse.free(gpa, state);
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()