Related to #22, but separate enough to split out.
zigdown currently writes diagnostic output through two different channels:
std.log.scoped(.utils) in src/lib/utils.zig and .ts_queries in src/lib/ts_queries.zig. I can intercept these from the root source file via std_options.logFn, but that's process-wide.
debug.print in src/lib/debug.zig, which writes to a global stream set via debug.setStream().
To fully silence zigdown (for a CLI where stderr is meaningful output) I have to wire both. Here's what I'm doing today:
// main.zig — intercept std.log scopes
pub const std_options: std.Options = .{
.logFn = md.log.zigdownSupressingLog,
};
// md/log.zig — drop known zigdown scopes
pub fn zigdownSupressingLog(
comptime level: std.log.Level,
comptime scope: @TypeOf(.enum_literal),
comptime format: []const u8,
args: anytype,
) void {
switch (scope) {
.present, .server, .tree_sitter, .syntax, .utils => return,
else => std.log.defaultLog(level, scope, format, args),
}
}
// md/render.zig — redirect debug.print into /dev/null
var discarding_writer: std.Io.Writer.Discarding = .init(&.{});
zigdown.debug.setStream(&discarding_writer.writer);
It works. But two globals don't compose well when zigdown is embedded in a longer-running process or a test.
Related to #22, but separate enough to split out.
zigdown currently writes diagnostic output through two different channels:
std.log.scoped(.utils)insrc/lib/utils.zigand.ts_queriesinsrc/lib/ts_queries.zig. I can intercept these from the root source file viastd_options.logFn, but that's process-wide.debug.printinsrc/lib/debug.zig, which writes to a global stream set viadebug.setStream().To fully silence zigdown (for a CLI where stderr is meaningful output) I have to wire both. Here's what I'm doing today:
It works. But two globals don't compose well when zigdown is embedded in a longer-running process or a test.