Skip to content

Commit

Permalink
Enable flushing for JSON logger
Browse files Browse the repository at this point in the history
  • Loading branch information
sile committed Jul 3, 2021
1 parent 37c3fea commit 0c60fa7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ impl Build for FileLoggerBuilder {
}
#[cfg(feature = "json")]
Format::Json => {
let drain = slog_json::Json::default(self.appender.clone());
let drain = slog_json::Json::new(self.appender.clone())
.set_flush(true)
.add_default_keys()
.build();
self.common.build_with_drain(drain)
}
};
Expand Down
18 changes: 12 additions & 6 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,18 @@ impl Build for TerminalLoggerBuilder {
}
#[cfg(feature = "json")]
Format::Json => match self.destination {
Destination::Stdout => self
.common
.build_with_drain(slog_json::Json::default(std::io::stdout())),
Destination::Stderr => self
.common
.build_with_drain(slog_json::Json::default(std::io::stderr())),
Destination::Stdout => self.common.build_with_drain(
slog_json::Json::new(std::io::stdout())
.set_flush(true)
.add_default_keys()
.build(),
),
Destination::Stderr => self.common.build_with_drain(
slog_json::Json::new(std::io::stderr())
.set_flush(true)
.add_default_keys()
.build(),
),
},
};
Ok(logger)
Expand Down

0 comments on commit 0c60fa7

Please sign in to comment.