remove logTags functionality
This commit is contained in:
27
src/root.zig
27
src/root.zig
@@ -18,7 +18,6 @@
|
|||||||
//! ```
|
//! ```
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const root = @import("root");
|
const root = @import("root");
|
||||||
const builtin = @import("builtin");
|
|
||||||
|
|
||||||
pub const options: Options = if (@hasDecl(root, "faller_options")) root.faller_options else .{};
|
pub const options: Options = if (@hasDecl(root, "faller_options")) root.faller_options else .{};
|
||||||
|
|
||||||
@@ -38,7 +37,6 @@ pub const Options = struct {
|
|||||||
/// tags is present it **isn't** logged. May overwrite `tags_enabled`.
|
/// tags is present it **isn't** logged. May overwrite `tags_enabled`.
|
||||||
tags_disabled: []const @Type(.enum_literal) = &.{},
|
tags_disabled: []const @Type(.enum_literal) = &.{},
|
||||||
buffer_size: u64 = 64,
|
buffer_size: u64 = 64,
|
||||||
disabled_in_test: bool = false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A Logger with prefixes.
|
/// A Logger with prefixes.
|
||||||
@@ -59,18 +57,7 @@ pub const Logger = struct {
|
|||||||
comptime format: []const u8,
|
comptime format: []const u8,
|
||||||
args: anytype,
|
args: anytype,
|
||||||
) void {
|
) void {
|
||||||
logger.logTags(&.{tag}, format, args);
|
const all_tags = logger.base_tags ++ [_]@Type(.enum_literal){tag};
|
||||||
}
|
|
||||||
|
|
||||||
/// Log with multiple `tags`. Checks whether the log is enabled.
|
|
||||||
pub fn logTags(
|
|
||||||
comptime logger: Logger,
|
|
||||||
comptime tags: []const @Type(.enum_literal),
|
|
||||||
comptime format: []const u8,
|
|
||||||
args: anytype,
|
|
||||||
) void {
|
|
||||||
if (builtin.is_test and options.disabled_in_test) return;
|
|
||||||
const all_tags = logger.base_tags ++ tags;
|
|
||||||
options.function(all_tags, format, args);
|
options.function(all_tags, format, args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -88,17 +75,7 @@ pub fn log(
|
|||||||
comptime format: []const u8,
|
comptime format: []const u8,
|
||||||
args: anytype,
|
args: anytype,
|
||||||
) void {
|
) void {
|
||||||
logTags(&.{tag}, format, args);
|
options.function(&.{tag}, format, args);
|
||||||
}
|
|
||||||
|
|
||||||
/// Log with multiple `tags`. Checks whether the log is enabled.
|
|
||||||
pub fn logTags(
|
|
||||||
comptime tags: []const @Type(.enum_literal),
|
|
||||||
comptime format: []const u8,
|
|
||||||
args: anytype,
|
|
||||||
) void {
|
|
||||||
if (builtin.is_test and options.disabled_in_test) return;
|
|
||||||
options.function(tags, format, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether the log is enabled for a specific combination of `tags`. Depends on the `options`
|
/// Checks whether the log is enabled for a specific combination of `tags`. Depends on the `options`
|
||||||
|
|||||||
Reference in New Issue
Block a user