authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-07-07 20:40:31+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-07-07 21:40:31+03:00
log6f17be063d37f5ecd9552479e65428a5c60d9152
treeea5072883e66ff72d591637c7e2ebd197b65f503
parent81bbefe9b837dc439a68458ca91d522c1c49b96b
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

std.log: give friendly error to freestanding users


2 files changed, 17 insertions(+), 5 deletions(-)

lib/std/log.zig+5-5
......@@ -156,11 +156,11 @@ pub fn defaultLog(
156156 comptime format: []const u8,
157157 args: anytype,
158158) void {
159 if (builtin.os.tag == .freestanding) {
160 // On freestanding one must provide a log function; we do not have
161 // any I/O configured.
162 return;
163 }
159 if (builtin.os.tag == .freestanding)
160 @compileError(
161 \\freestanding targets do not have I/O configured;
162 \\please provide at least an empty `log` function declaration
163 );
164164
165165 const level_txt = comptime message_level.asText();
166166 const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
test/standalone/issue_7030/main.zig+12
......@@ -1,5 +1,17 @@
11const std = @import("std");
22
3pub fn log(
4 comptime message_level: std.log.Level,
5 comptime scope: @Type(.EnumLiteral),
6 comptime format: []const u8,
7 args: anytype,
8) void {
9 _ = message_level;
10 _ = scope;
11 _ = format;
12 _ = args;
13}
14
315pub fn main() anyerror!void {
416 std.log.info("All your codebase are belong to us.", .{});
517}