From 551d51ea4298f7881695eabcfbd91181aad06961 Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Wed, 1 Sep 2004 17:01:52 +0000 Subject: [PATCH] When AMXX can't open the logfile it outputs an error rather than crashing --- amxmodx/amxxlog.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/amxmodx/amxxlog.cpp b/amxmodx/amxxlog.cpp index eaa03b4b..25eb0b24 100755 --- a/amxmodx/amxxlog.cpp +++ b/amxmodx/amxxlog.cpp @@ -181,9 +181,18 @@ void CLog::Log(const char *fmt, ...) { pF = fopen(build_pathname("%s/L%02d%02d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday), "a+"); } - fprintf(pF, "L %s: %s\n", date, msg); + if (pF) + { + fprintf(pF, "L %s: %s\n", date, msg); + fclose(pF); + } + else + { + ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", m_LogFile.c_str()); + m_LogType = 0; + return; + } - fclose(pF); // print on server console print_srvconsole("L %s: %s\n", date, msg); }