Closed dcormier closed 3 years ago
The solution for this is to wrap the Drain
in a Mutex
.
Before:
let log = Logger::root(
slog_json::Json::new(std::io::stdout()).build().fuse(),
o!(),
);
After:
let log = Logger::root(
Mutex::new(
slog_json::Json::new(std::io::stdout()).build().fuse(),
).fuse(),
o!(),
);
Newlines for clarity.
Found the issue while google for term logger... You can find different sync methods in slog-term's doc https://docs.rs/slog-term/2.8.0/slog_term/#synchronization-via-plainsyncdecorator and some formatter are Sync FullFormat while some are not CompactFormat
I'm trying to build a
slog_json
logger without usingslog_async
. I'm trying to write the JSON logs to a buffer and verify they contain certain output later, so I need logging to be a blocking operation so that the buffer actually has the content when.log
returns.This code:
Results in this:
Surely
slog_async
isn't a requirement for writing logs, is it?