mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
std.log: give friendly error to freestanding users
This commit is contained in:
parent
81bbefe9b8
commit
6f17be063d
@ -156,11 +156,11 @@ pub fn defaultLog(
|
|||||||
comptime format: []const u8,
|
comptime format: []const u8,
|
||||||
args: anytype,
|
args: anytype,
|
||||||
) void {
|
) void {
|
||||||
if (builtin.os.tag == .freestanding) {
|
if (builtin.os.tag == .freestanding)
|
||||||
// On freestanding one must provide a log function; we do not have
|
@compileError(
|
||||||
// any I/O configured.
|
\\freestanding targets do not have I/O configured;
|
||||||
return;
|
\\please provide at least an empty `log` function declaration
|
||||||
}
|
);
|
||||||
|
|
||||||
const level_txt = comptime message_level.asText();
|
const level_txt = comptime message_level.asText();
|
||||||
const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
|
const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn log(
|
||||||
|
comptime message_level: std.log.Level,
|
||||||
|
comptime scope: @Type(.EnumLiteral),
|
||||||
|
comptime format: []const u8,
|
||||||
|
args: anytype,
|
||||||
|
) void {
|
||||||
|
_ = message_level;
|
||||||
|
_ = scope;
|
||||||
|
_ = format;
|
||||||
|
_ = args;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
std.log.info("All your codebase are belong to us.", .{});
|
std.log.info("All your codebase are belong to us.", .{});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user