Closed carrotstien closed 3 years ago
ZLogger tries to write as quickly as possible. That is, it flushes when the message buffer is empty. I need to add the FlushRate setting.
As i'm using this for a vr application, i'm worried that writing so often to the disk (and i'm hoping on a side thread...but can't find where), might result in some frame skipping.
In my own logging implementation that I replaced with Zlogger, I wrote to a fileWriter with autoflush=0ff, and then had a side thread call flush() at some interval (i think once ever 10 seconds)
reader is already in async reader-loop. https://github.com/Cysharp/ZLogger/blob/master/src/ZLogger/AsyncStreamLineMessageWriter.cs#L89 It is run on thread-pool so does not block in logger.
yea i meant more general system wide hiccup on IO. Even my powerful computer can hang for a moment when doing a heavy IO process.
Either way, i'll look forward to the FlushRate. No rush at all (in fact let me know where to donate :D ), but any estimate as to when you'll add that?
I've released 1.4.0
, it includes ZLoggerOptions.FlushRate
.
This flush rate works mostly as expected - in that it writes to the files after the timespan. However, the log header defined only gets resolved at flush time. I was hoping the write would immediately to a buffer in memory, and that would get dumped to the system disk in flush time.
for example:
builder.AddZLoggerFile(filename, "file-plain" , x => { x.PrefixFormatter = (writer, info) => ZString.Utf8Format(writer, "[{0} {1} {2}]", info.Timestamp.ToLocalTime().DateTime,MainThreadActionQueue.frameNumber, Misc.GetLongTime()); x.FlushRate = TenSeconds; });
the frame number and time stamp are resolved at flush which make them a lot less useful for debugging :(
Timestamp is created at Log method called. https://github.com/Cysharp/ZLogger/blob/aa70632b0e7f49b3c3e959c270646734864d4c28/src/ZLogger/AsyncProcessZLogger.cs#L26
frameNumber and GetLongTime are not concerned with this lib.
My current logger writes to an output stream that i flush once ever 10 seconds to save on IO hits. It looks like ZLogger flushes immediately. It is possible to adjust this (as i suspect this might cause performance issues...or am i wrong?)