Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
damage220 opened this issue Sep 18, 2023 · 2 comments

Comments

@damage220
Copy link

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)

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

public plugin_init()
{
  server_print("%d");
}
  1. Make cstrike/addons/amxmodx/logs not writable or simply delete it
  2. 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
Copy link
Contributor

Th3-822 commented Sep 18, 2023

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

amxmodx/amxmodx/amxxlog.cpp

Lines 260 to 267 in 27f451a

} else {
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Error Logging disabled for this map.\n", file);
m_FoundError = true;
return;
}
// print on server console
print_srvconsole("L %s: %s\n", date, msg);
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

@damage220 damage220 changed the title amxx does not respect amxx_logging setting AMXX does not print error message to the console if amxx_logs directory is not writable Sep 18, 2023
@damage220
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants