mingrammer/flog

Append to existing log in flog instead of new file

jan25 opened this issue · 2 comments

jan25 commented

flog.go creates new file each time Generate is called. It'll be nice if option param can take more info about writing- to append to existing file or create new file

Thanks for great work!

"append" option is a good idea!

But I think there might be an issue for multiple log files (with split option)

apache_logs.log (500 lines)
apache_logs1.log (500 lines)
apache_logs2.log (500 lines)
apache_logs3.log (200 lines)

Then when I re-run the flog with append option, how should flog work for this case? Of course, If I re-run the flog with options which same to previous, appending is easy. It will just fill the last log file out and create new following log files will be named log4, log5 and etc.

apache_logs.log (500 lines)
apache_logs1.log (500 lines)
apache_logs2.log (500 lines)
apache_logs3.log (500 lines)
apache_logs4.log (500 lines)
apache_logs5.log (400 lines)

But, with different options, it's not easy to determine how to append the new logs to existing log files.

Do you have a good idea? :)

What you think about generate a new file after X time?

apache_logs-2018-12-20-17:10.log (500 lines)
apache_logs-2018-12-20-17:20.log (500 lines)
apache_logs-2018-12-20-17:30.log (500 lines)
apache_logs-2018-12-20-17:40.log (500 lines)
apache_logs-2018-12-20-17:50.log (500 lines)
apache_logs-2018-12-20-18:00.log (400 lines)