natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.76k stars 585 forks source link

Last line truncated #123

Closed abenbouz closed 3 years ago

abenbouz commented 3 years ago

hello , i get last line truncated for each file and appended to the next file created i think it's due to the max size any idea on how to get that fixed ? Thanks

natefinch commented 3 years ago

The logic is that every call to Write, lumberjack checks the length of the write and if it would put the log file over the max, then we roll the log and instead make that write to the new log file. Unfortunately, some loggers may make multiple calls to Write for one logical log message. There's not much lumberjack can do, because it doesn't know when a log message starts or ends. It just has a Write method.

What is writing to lumberjack? If there's a way to know when a log message starts and when it finishes, you could write a wrapper for lumberjack that buffers the writes and consolidates them into one call to lumberjack's Write method.

abenbouz commented 3 years ago

Yeah got it you are right In fact i'am using now a scanner as input in order to fixe that problem Thanks for your comment I am closing the bug

abenbouz commented 3 years ago

Works as disigned