raduprv / Eternal-Lands

http://www.eternal-lands.com
Other
157 stars 57 forks source link

Add date to the logs (log only, not in console) #160

Closed brunoramoslu closed 2 years ago

brunoramoslu commented 2 years ago

Currently we only log the time without the date, which makes it difficult to search for things in a big log file. It would be nice to have the date also in the log. No need to change the console/chat messages (those can keep the time only). Date should be in ISO-8601 format: YYYY-MM-DD (e.g.: 2021-12-21)

Edit: add reference to date format

gvissers commented 2 years ago

I added the date to the log file timestamps in 2a78dd89.

But this issue reminded me of another pet peeve of mine: the log file is overwritten when a new client instance is started. Which can be inconvenient when testing multiple clients. OTOH we don't want to keep ages old log files around either. Perhaps I should open a separate issue for this though.

pjbroad commented 2 years ago

I'd assumed @brunoramoslu was referring to the chat logs not the file in the logs directory. Anyway, I agree that one log getting overwritten by another instance is a pain. Perhaps we could use separate log files per instance and age them off.

gvissers commented 2 years ago

I'd assumed @brunoramoslu was referring to the chat logs not the file in the logs directory.

Oh, yeah, you're probably right. Added it there as well.

Anyway, I agree that one log getting overwritten by another instance is a pain. Perhaps we could use separate log files per instance and age them off.

Separating the files in the logs dir also per profile (main/ test/ etc.) would be easy to do and already help somewhat. Also I wonder if we could work around the one file per thread that is used right now.

pjbroad commented 2 years ago

Message from player in game: "Add date to timestamp in chat log files is a very useful idea but it only takes effect when timestamps are not displayed in the game window"

gvissers commented 2 years ago

D'oh :facepalm:

Sorry, should be fixed now. I can't believe I missed that, it was more or less spelled out in the code comments. You know, I thought this would be a a very simple change, not something that would require at least three commits to get right.

pjbroad commented 2 years ago

Sorry.... Turns out the "%F" formatting for strftime() does not work on windows. When replaced it with "%Y-%m-%d" it does work.

Edit: I'm trying to do some builds so I'll commit this change for now. Please offer an alternative as you wish. I did quickly look at the standard versions we are using but moving to a newer standard did not fix the problem, plus we ought to do a bit more testing if we do that.

gvissers commented 2 years ago

%F is C99, but if it doesn't work Y-m-d is fine.

gvissers commented 2 years ago

Should be fixed, closing