move log overrides into std_options (#902)

This commit is contained in:
Lee Cannon 2023-01-10 21:52:03 +00:00 committed by GitHub
parent bbbd54498d
commit 20d29fd491
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,16 +11,17 @@ const debug = @import("debug.zig");
const logger = std.log.scoped(.main); const logger = std.log.scoped(.main);
// Always set this to debug to make std.log call into our handler, then control the runtime
// value in the definition below.
pub const log_level = .debug;
var actual_log_level: std.log.Level = switch (zig_builtin.mode) { var actual_log_level: std.log.Level = switch (zig_builtin.mode) {
.Debug => .debug, .Debug => .debug,
else => @intToEnum(std.log.Level, @enumToInt(build_options.log_level)), // temporary fix to build failing on release-safe due to a Zig bug else => @intToEnum(std.log.Level, @enumToInt(build_options.log_level)), // temporary fix to build failing on release-safe due to a Zig bug
}; };
pub fn log( pub const std_options = struct {
// Always set this to debug to make std.log call into our handler, then control the runtime
// value in the definition below.
pub const log_level = .debug;
pub fn logFn(
comptime level: std.log.Level, comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral), comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8, comptime format: []const u8,
@ -33,6 +34,7 @@ pub fn log(
std.debug.print("{s:<5}: ({s:^6}): ", .{ level_txt, @tagName(scope) }); std.debug.print("{s:<5}: ({s:^6}): ", .{ level_txt, @tagName(scope) });
std.debug.print(format ++ "\n", args); std.debug.print(format ++ "\n", args);
} }
};
fn loop( fn loop(
server: *Server, server: *Server,