adding lz4 to slugger
This commit is contained in:
parent
ce85abe197
commit
8b3ed473f6
|
|
@ -5,6 +5,9 @@ pub fn build(b: *std.Build) void {
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
const p2 = b.dependency("p2", .{ .target = target, .optimize = optimize });
|
const p2 = b.dependency("p2", .{ .target = target, .optimize = optimize });
|
||||||
|
|
||||||
|
const lz4 = b.dependency("lz4", .{ .target = target, .optimize = optimize });
|
||||||
|
_ = lz4;
|
||||||
|
|
||||||
const mod = b.addModule("slugger", .{
|
const mod = b.addModule("slugger", .{
|
||||||
.root_source_file = b.path("src/slugger.zig"),
|
.root_source_file = b.path("src/slugger.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
.minimum_zig_version = "0.17.0",
|
.minimum_zig_version = "0.17.0",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.p2 = .{ .path = "../p2" },
|
.p2 = .{ .path = "../p2" },
|
||||||
|
.lz4 = .{ .path = "../lz4" },
|
||||||
},
|
},
|
||||||
.paths = .{ "build.zig", "build.zig.zon", "src" },
|
.paths = .{ "build.zig", "build.zig.zon", "src" },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -560,6 +560,7 @@ pub fn DeclareLoggerSystem(comptime opts: LoggerSystemInitOptions) type {
|
||||||
// The payload is copied into the entries arena, so the producer's
|
// The payload is copied into the entries arena, so the producer's
|
||||||
// copy is freed whether or not accept succeeds.
|
// copy is freed whether or not accept succeeds.
|
||||||
defer self.payload_allocator.free(entry.serialized_args);
|
defer self.payload_allocator.free(entry.serialized_args);
|
||||||
|
|
||||||
const log = self.mem.accept(entry) catch |err| {
|
const log = self.mem.accept(entry) catch |err| {
|
||||||
_ = self.dropped.fetchAdd(1, .monotonic);
|
_ = self.dropped.fetchAdd(1, .monotonic);
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -613,7 +614,7 @@ pub fn initialize(
|
||||||
) void {
|
) void {
|
||||||
gLoggerSystem.init(io, allocator, payload_allocator);
|
gLoggerSystem.init(io, allocator, payload_allocator);
|
||||||
if (use_stdout) {
|
if (use_stdout) {
|
||||||
try gLoggerSystem.addStdout();
|
gLoggerSystem.addStdout() catch {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -661,7 +662,12 @@ pub const LogRef = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eql(_: @This(), a: LogRef, b: LogRef) bool {
|
pub fn eql(_: @This(), a: LogRef, b: LogRef) bool {
|
||||||
return a.line == b.line and std.mem.eql(u8, a.file, b.file) and std.mem.eql(u8, a.fmt, b.fmt) and std.mem.eql(u8, a.args_type, b.args_type);
|
// zig fmt: off
|
||||||
|
return a.line == b.line
|
||||||
|
and std.mem.eql(u8, a.file, b.file)
|
||||||
|
and std.mem.eql(u8, a.fmt, b.fmt)
|
||||||
|
and std.mem.eql(u8, a.args_type, b.args_type);
|
||||||
|
// zig fmt: on
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1068,6 +1074,7 @@ test "testing" {
|
||||||
initialize(std.testing.io, std.testing.allocator, std.testing.allocator, false);
|
initialize(std.testing.io, std.testing.allocator, std.testing.allocator, false);
|
||||||
defer deinit();
|
defer deinit();
|
||||||
const Logger = DeclareLogger("mylogger", .{ .verbosity = .verbose });
|
const Logger = DeclareLogger("mylogger", .{ .verbosity = .verbose });
|
||||||
|
|
||||||
Logger.addLog(@src(), .log, "{} {} who doesn't {} {s} 2 + 2 is {d}", .{ TestEnum.ending, TestEnum2.ending, true, "dragons", 4 });
|
Logger.addLog(@src(), .log, "{} {} who doesn't {} {s} 2 + 2 is {d}", .{ TestEnum.ending, TestEnum2.ending, true, "dragons", 4 });
|
||||||
Logger.addLog(@src(), .warn, "{} {} who doesn't {} {s} 2 + 2 is {d}", .{ TestEnum.ending, TestEnum2.ending, true, "dragons", 4 });
|
Logger.addLog(@src(), .warn, "{} {} who doesn't {} {s} 2 + 2 is {d}", .{ TestEnum.ending, TestEnum2.ending, true, "dragons", 4 });
|
||||||
Logger.addLog(@src(), .err, "{} {} who doesn't {} {s} 2 + 2 is {d}", .{ TestEnum.ending, TestEnum2.ending, true, "dragons", 4 });
|
Logger.addLog(@src(), .err, "{} {} who doesn't {} {s} 2 + 2 is {d}", .{ TestEnum.ending, TestEnum2.ending, true, "dragons", 4 });
|
||||||
|
|
|
||||||
|
|
@ -292,3 +292,4 @@ const EnumEntry = slugger.EnumEntry;
|
||||||
const ArgsDecoderOp = slugger.ArgsDecoderOp;
|
const ArgsDecoderOp = slugger.ArgsDecoderOp;
|
||||||
const ArgsDecoderOpKind = slugger.ArgsDecoderOpKind;
|
const ArgsDecoderOpKind = slugger.ArgsDecoderOpKind;
|
||||||
const RenderOp = slugger.RenderOp;
|
const RenderOp = slugger.RenderOp;
|
||||||
|
const lz4 = @import("lz4");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue