Vindicta-Team / FileXT

Arma 3 addon to store data in files
9 stars 4 forks source link

!R (Logging) Refactored logging mechanism to prevent server stalls on Windows #9

Closed uniflare closed 2 years ago

uniflare commented 2 years ago

This change refactors the logging mechanism such that:

  1. On Windows, we never write to stderr.
  2. RAII added to log file handle, closing on DLL exit (static destructor).
  3. For Critical Errors, source filename and line number appended to message.
  4. Version text bumped to 1.2.
Sparker95 commented 2 years ago

This brings so many questions. What was my intention behind logging two years ago? What was intention of @xoorath for logging? Did I really ship the debug .dll with enabled logging to people?

Also for some reason only Linux build was complaining about the missing std vector include, Windows build was fine :D I will publish to Steam a bit later, perhaps someone at our Discord can test it on their Linux server.

uniflare commented 2 years ago

Indeed :D. I don't see an issue with logging, it could prove useful to mission makers to see what happened or what commands are actually being actioned.

I don't think you shipped the debug DLL, I think some logging was enabled even in release from what I remember.

Thanks for adding the vector, I did compile locally using WSL and GCC, probably a dirty workspace as I was managing 2 branches at the time so good catch :).

An no worries, it is something I ended up fixing on my end anyway for our server, as we like FileXT and want to continue using it. Cleaning it up a little and making it official wasn't a big deal.

Thanks for your time on this matter :).

xoorath commented 2 years ago

The only intent I had for logging was make it a little less hairy, it used to be like so:

#define LOG(text) fprintf(gLogFile, text); fflush(gLogFile)
#define LOG_0(text) fprintf(gLogFile, text); fflush(gLogFile)
#define LOG_1(text, a) fprintf(gLogFile, text, a); fflush(gLogFile)
#define LOG_2(text, a, b) fprintf(gLogFile, text, a, b); fflush(gLogFile)
#define LOG_3(text, a, b, c) fprintf(gLogFile, text, a, b, c); fflush(gLogFile)
#define LOG_4(text, a, b, c, d) fprintf(gLogFile, text, a, b, c, d); fflush(gLogFile)

Except I made the mistake of thinking it would also be a direct improvement to have the log file default to stderr when the file pointer was unassigned.

Now I know better :)