river/src/log.zig
Isaac Freund 5020106b93
Explictly define log level ordering
This was technically undefined before.
2020-03-29 21:17:57 +02:00

25 lines
611 B
Zig

const std = @import("std");
pub const Log = enum {
const Self = @This();
Silent = 0,
Error = 1,
Info = 2,
Debug = 3,
var verbosity = Self.Error;
pub fn init(_verbosity: Self) void {
verbosity = _verbosity;
}
fn log(level: Self, comptime format: []const u8, args: var) void {
if (@enumToInt(level) <= @enumToInt(verbosity)) {
// TODO: log the time since start in the same format as wlroots
// TODO: use color if logging to a tty
std.debug.warn("[{}] " ++ format ++ "\n", .{@tagName(level)} ++ args);
}
}
};