You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using the Json drain to write to a TCP port like this:
let writer = TcpStream::connect("localhost:5000").unwrap();let drain = slog_json::Json::default(writer);let logger = slog::Logger::root(Mutex::new(drain).map(slog::Fuse),o!());
The problem with this approach is that the JSON serializer will call write() on the TCP connection for every token ({, ", msg, ", : etc.). I believe this results in quite a performance hit.
I'm thinking to use a BufWriter around the TcpStream to allow buffering of the individual writes. To ensure that every log message is sent through the wire I'd want to call flush() after each message though.
Do you think that's a good solution?
I will open a pull request to add the flush() call if you agree.
The text was updated successfully, but these errors were encountered:
njam
added a commit
to njam/json
that referenced
this issue
Nov 19, 2018
I'm currently using the Json drain to write to a TCP port like this:
The problem with this approach is that the JSON serializer will call
write()
on the TCP connection for every token ({
,"
,msg
,"
,:
etc.). I believe this results in quite a performance hit.I'm thinking to use a
BufWriter
around theTcpStream
to allow buffering of the individual writes. To ensure that every log message is sent through the wire I'd want to callflush()
after each message though.Do you think that's a good solution?
I will open a pull request to add the
flush()
call if you agree.The text was updated successfully, but these errors were encountered: