aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorheidezomp <heidezomp@protonmail.com>2020-08-13 16:50:38 +0200
committerheidezomp <heidezomp@protonmail.com>2020-08-13 16:50:38 +0200
commita8e0f667c64bc6413a2c10ac76cd4e3000ceaf1b (patch)
tree02041d85daee749864a68fe3e9a513a09d926928 /lib
parent3e2e6baee568b0fb9d019fc53974aad30386b824 (diff)
downloadzig-a8e0f667c64bc6413a2c10ac76cd4e3000ceaf1b.tar.gz
zig-a8e0f667c64bc6413a2c10ac76cd4e3000ceaf1b.zip
std.log: (breaking) remove scope parameter from logging functions
The logging functions in std.log don't take a scope parameter anymore, but use the .default scope. To provide your own scope, use the logging functions in std.log.scoped(.some_other_scope). As per nmichaels' suggestion: https://github.com/ziglang/zig/pull/6039#issuecomment-673148971
Diffstat (limited to 'lib')
-rw-r--r--lib/std/log.zig123
1 files changed, 37 insertions, 86 deletions
diff --git a/lib/std/log.zig b/lib/std/log.zig
index 9a0dcecc05..706851d0be 100644
--- a/lib/std/log.zig
+++ b/lib/std/log.zig
@@ -129,92 +129,6 @@ fn log(
}
}
-/// Log an emergency message. This log level is intended to be used
-/// for conditions that cannot be handled and is usually followed by a panic.
-pub fn emerg(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- @setCold(true);
- log(.emerg, scope, format, args);
-}
-
-/// Log an alert message. This log level is intended to be used for
-/// conditions that should be corrected immediately (e.g. database corruption).
-pub fn alert(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- @setCold(true);
- log(.alert, scope, format, args);
-}
-
-/// Log a critical message. This log level is intended to be used
-/// when a bug has been detected or something has gone wrong and it will have
-/// an effect on the operation of the program.
-pub fn crit(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- @setCold(true);
- log(.crit, scope, format, args);
-}
-
-/// Log an error message. This log level is intended to be used when
-/// a bug has been detected or something has gone wrong but it is recoverable.
-pub fn err(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- @setCold(true);
- log(.err, scope, format, args);
-}
-
-/// Log a warning message. This log level is intended to be used if
-/// it is uncertain whether something has gone wrong or not, but the
-/// circumstances would be worth investigating.
-pub fn warn(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- log(.warn, scope, format, args);
-}
-
-/// Log a notice message. This log level is intended to be used for
-/// non-error but significant conditions.
-pub fn notice(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- log(.notice, scope, format, args);
-}
-
-/// Log an info message. This log level is intended to be used for
-/// general messages about the state of the program.
-pub fn info(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- log(.info, scope, format, args);
-}
-
-/// Log a debug message. This log level is intended to be used for
-/// messages which are only useful for debugging.
-pub fn debug(
- comptime scope: @Type(.EnumLiteral),
- comptime format: []const u8,
- args: anytype,
-) void {
- log(.debug, scope, format, args);
-}
-
/// Returns a scoped logging namespace that logs all messages using the scope
/// provided here.
pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
@@ -301,3 +215,40 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
/// The default scoped logging namespace.
pub const default = scoped(.default);
+
+/// Log an emergency message using the default scope. This log level is
+/// intended to be used for conditions that cannot be handled and is usually
+/// followed by a panic.
+pub const emerg = default.emerg;
+
+/// Log an alert message using the default scope. This log level is intended to
+/// be used for conditions that should be corrected immediately (e.g. database
+/// corruption).
+pub const alert = default.alert;
+
+/// Log a critical message using the default scope. This log level is intended
+/// to be used when a bug has been detected or something has gone wrong and it
+/// will have an effect on the operation of the program.
+pub const crit = default.crit;
+
+/// Log an error message using the default scope. This log level is intended to
+/// be used when a bug has been detected or something has gone wrong but it is
+/// recoverable.
+pub const err = default.err;
+
+/// Log a warning message using the default scope. This log level is intended
+/// to be used if it is uncertain whether something has gone wrong or not, but
+/// the circumstances would be worth investigating.
+pub const warn = default.warn;
+
+/// Log a notice message using the default scope. This log level is intended to
+/// be used for non-error but significant conditions.
+pub const notice = default.notice;
+
+/// Log an info message using the default scope. This log level is intended to
+/// be used for general messages about the state of the program.
+pub const info = default.info;
+
+/// Log a debug message using the default scope. This log level is intended to
+/// be used for messages which are only useful for debugging.
+pub const debug = default.debug;