mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-15 06:26:07 +00:00
Fix default error logfile
Don't use stderr for error logfile if primary logfile is not stdout (i.e. always use the same file). Fix non-colorized duration in DeveolpmentLogger - use std.fmt.fmtDurationSigned.
This commit is contained in:
parent
09bbcebb56
commit
054d1b5d82
@ -120,7 +120,10 @@ fn getLogFile(stream: enum { stdout, stderr }, options: Options) !std.fs.File {
|
|||||||
|
|
||||||
if (std.mem.eql(u8, path, "-")) return switch (stream) {
|
if (std.mem.eql(u8, path, "-")) return switch (stream) {
|
||||||
.stdout => std.io.getStdOut(),
|
.stdout => std.io.getStdOut(),
|
||||||
.stderr => std.io.getStdErr(),
|
.stderr => if (std.mem.eql(u8, options.log, "-"))
|
||||||
|
std.io.getStdErr()
|
||||||
|
else
|
||||||
|
try std.fs.createFileAbsolute(options.log, .{ .truncate = false }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const file = try std.fs.createFileAbsolute(path, .{ .truncate = false });
|
const file = try std.fs.createFileAbsolute(path, .{ .truncate = false });
|
||||||
|
@ -68,7 +68,11 @@ pub fn logRequest(self: DevelopmentLogger, request: *const jetzig.http.Request)
|
|||||||
const formatted_duration = if (self.stdout_colorized)
|
const formatted_duration = if (self.stdout_colorized)
|
||||||
try jetzig.colors.duration(self.allocator, jetzig.util.duration(request.start_time))
|
try jetzig.colors.duration(self.allocator, jetzig.util.duration(request.start_time))
|
||||||
else
|
else
|
||||||
try std.fmt.allocPrint(self.allocator, "{}", .{jetzig.util.duration(request.start_time)});
|
try std.fmt.allocPrint(
|
||||||
|
self.allocator,
|
||||||
|
"{}",
|
||||||
|
.{std.fmt.fmtDurationSigned(jetzig.util.duration(request.start_time))},
|
||||||
|
);
|
||||||
defer self.allocator.free(formatted_duration);
|
defer self.allocator.free(formatted_duration);
|
||||||
|
|
||||||
const status: jetzig.http.status_codes.TaggedStatusCode = switch (request.response.status_code) {
|
const status: jetzig.http.status_codes.TaggedStatusCode = switch (request.response.status_code) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user