blob: 0212885c95cbc25b509d4fc6e2b07edd0aad7953 (
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
|
// Copyright 2022 DistressNetwork° <uplink@distress.network>
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
const std = @import("std");
const Level = std.log.Level;
pub const log_level: Level = .warn;
pub fn log(
comptime level: Level,
comptime format: []const u8,
args: anytype,
) void {
if (@enumToInt(level) > @enumToInt(log_level)) return;
const msg = "[" ++ switch (level) {
.info => "ok",
.err => "err",
else => level.asText(),
} ++ "]\t" ++ format ++ "\n";
const stderr = std.io.getStdErr().writer();
nosuspend stderr.print(msg, args) catch return;
}
|