move log overrides into std_options
(#902)
This commit is contained in:
parent
bbbd54498d
commit
20d29fd491
12
src/main.zig
12
src/main.zig
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user