amxmodx
amxmodx copied to clipboard
AMXX does not print error message to the console if amxx_logs directory is not writable
Environment
- Operating System version: Arch Linux (6.4.9-arch1-1)
- Game/AppID (with version if applicable): Counter Strike (10), Build ID: 5424799
- Current AMX Mod X version: v1.9.0.5294
- Current Metamod version: metamod-r-1.3.0.131
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)
- Create plugin that will throw an error
#include <amxmodx>
public plugin_init()
{
server_print("%d");
}
- Make cstrike/addons/amxmodx/logs not writable or simply delete it
- 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
).
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
- fixing LogError to always show errors on console, even if it can't write the log file
- doing a fallback on amxx_logs to modname/logs folder if the amxx's folder isn't writable, which i think is not a good thing as lots of stuff relies on amxx's folders being writeable (stats, vaults and lots of plugins)
- adding a note on amxx_logging usage and amxx_logs to reflect this behavior
doing stuff like allowing to change the error log filename formatting or mixing both logfiles would have more cons than pros
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.