river/src/log.zig

25 lines
611 B
Zig
Raw Normal View History

2020-03-29 12:05:34 -07:00
const std = @import("std");
pub const Log = enum {
const Self = @This();
Silent = 0,
Error = 1,
Info = 2,
Debug = 3,
2020-03-29 12:05:34 -07:00
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);
}
}
};