error: no field or member function named 'writeByte' in 'fs.file.File' try out.writeByte('\n');
qcjxberin opened this issue · comments
Now use zig-0.11 version.
const now1 = std.time.milliTimestamp(); var buffer1: [256]u8 = undefined; const formatted1 = try std.fmt.bufPrint(&buffer1, "{}", .{now1}); _ = formatted1;
requestLogs.err() .string("context", "divide") .float("a", 1) .float("b", 2).log();
error: no field or member function named 'writeByte' in 'fs.file.File'
try out.writeByte('\n');
Where do I need to configure it?,And how to write logs to a file.。
Looks like file.writeByte
is new in 0.12.
I've updated the branch to use writeAll
, and I've tested the code this time and it works :) Sorry, the unit tests mock the output, so this wasn't caught. I'll try to improve the unit tests and pass in a real file.
To log to your own file, you can use logTo(out: anytype)
instead of log
. It would obviously be nice to be able to specify the file initially. Not sure how doable that is without making the API harder to use (e.g. turning the logger into a generic type).
It can not be configured to write to a file:
try logz.setup(allocator, .{
...
.output = .{.file = "PATH TO FILE"},
});
There are no errors reported so far, but I don't see the log output.
`
try logz.setup(alloc, .{
.level = .Warn,
.pool_size = 100,
.buffer_size = 4096,
.large_buffer_count = 8,
.large_buffer_size = 16384,
//.output = .{ .file = "log.log" },
.output = .stdout,
.encoding = .logfmt,
});
logz.info().string("path", "test").int("ms", 12345678).log();
`
There are no errors reported so far, but I don't see the log output.
` try logz.setup(alloc, .{ .level = .Warn, .pool_size = 100, .buffer_size = 4096, .large_buffer_count = 8, .large_buffer_size = 16384, //.output = .{ .file = "log.log" }, .output = .stdout, .encoding = .logfmt, });
logz.info().string("path", "test").int("ms", 12345678).log();
`
I found the reason, I set the level to warn, but the log output is info