blob: ba9141e4c67eff57979c737496af04bc378f864d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
const std = @import("std");
pub const js = @import("js.zig");
pub fn default(
comptime level: std.log.Level,
comptime scope: @EnumLiteral(),
comptime format: []const u8,
args: anytype,
) void {
var buffer: [1024]u8 = undefined;
var writer: std.Io.Writer = .fixed(&buffer);
const func = switch (level) {
.err => js.err,
.warn => js.warn,
.info => js.log,
.debug => js.debug,
};
if (scope != .default) {
writer.print("[{s}]: ", .{@tagName(scope)}) catch unreachable;
}
writer.print(format, args) catch unreachable;
func(writer.buffered());
}
|