alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
496 stars 197 forks source link

AMXX does not print error message to the console if amxx_logs directory is not writable #1084

Open damage220 opened 1 year ago

damage220 commented 1 year ago

Environment

Description

When amxx_logging is set to 3 (HL logs) and the default log directory (cstrike/amxmodx/logs) is not writable, amxx will throw an error in the terminal even if it can write to cstrike/logs.

L 09/18/2023 - 18:32:16: [AMXX] Unexpected fatal logging error (couldn't open cstrike/addons/amxmodx/logs/error_20230918.log for a+). AMXX Error Logging disabled for this map.

When amxx_logging is set to 3 and amxx_logs is set to logs, amxx prints errors to the terminal and logs them to cstrike/logs, however amxx creates error_20230918.log and does not utilize default HL log files.

Problematic Code (or Steps to Reproduce)

  1. Create plugin that will throw an error
    
    #include <amxmodx>

public plugin_init() { server_print("%d"); }


2. Make cstrike/addons/amxmodx/logs not writable or simply delete it
3. Start the server

# Expected behavior

When amxx_logging is set to 3, AMXX should print errors to the terminal regardless of the state of cstrike/addons/amxmodx/logs directory. The directory that should be writable is cstrike/logs. It is also expected that AMXX will use default HL log mechanism, i.e. not create additional log files, both normal messages and errors should be written to L${MONTH}-${DAY}-${NUMBER}.log file (if I am not mistaken the meaning of `amxx_logging 3`).
Th3-822 commented 1 year ago

amxx_logging seems to be only for normal amxx logs as LogError totally ignores amxx_logging value (which i think it's nice as there won't be ppl disabling it and then saying that X its amxx's fault instead of their plugins makings 30 errors/sec)

i really think it's great to have errors logged as another file instead of having to find errors on the regular logfiles as they may get huge

https://github.com/alliedmodders/amxmodx/blob/27f451a868c3154a0ab0d4d70e0a650074fd485d/amxmodx/amxxlog.cpp#L260-L267 but the main issue is that it stops showing errors on console after not being able to write the error log file, which i consider it kinda bad

solutions may be

doing stuff like allowing to change the error log filename formatting or mixing both logfiles would have more cons than pros

damage220 commented 1 year ago

So there is no issue with amxx_logging 3 as I simply misunderstood its meaning, though I believe comment in core.ini regarding description of this setting should be more clear.

Having errors to be placed to "normal messages" file may be useful because in this case errors will have context, i.e. you may see that some errors appear at the end of the round or under certain circumstances. I thought that amxx_logging 3 does this. I was wrong.