From b13b1e8ac7c68259fd8cdafe5fe7ee3d6df402c9 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sun, 26 Nov 2023 17:56:30 +0100 Subject: [PATCH] correctly handle empty logger.logfile setting if 'file' is in the activated log-types and no file name was given, thx to Oops Signed-off-by: Michael Kaufmann --- lib/Froxlor/FroxlorLogger.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/Froxlor/FroxlorLogger.php b/lib/Froxlor/FroxlorLogger.php index 014d84c461..2ca02aeb08 100644 --- a/lib/Froxlor/FroxlorLogger.php +++ b/lib/Froxlor/FroxlorLogger.php @@ -104,17 +104,15 @@ protected function __construct(array $userinfo = []) self::$ml->pushHandler(new SyslogHandler('froxlor', LOG_USER, Logger::DEBUG)); break; case 'file': + $setings_logfile = Settings::Get('logger.logfile'); + if (empty($setings_logfile)) { + Settings::Set('logger.logfile', 'froxlor.log'); + } $logger_logfile = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/logs/' . Settings::Get('logger.logfile')); // is_writable needs an existing file to check if it's actually writable - @touch($logger_logfile); - if (empty($logger_logfile) || !is_writable($logger_logfile)) { - Settings::Set('logger.logfile', 'froxlor.log'); - $logger_logfile = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/logs/froxlor.log'); - @touch($logger_logfile); - if (empty($logger_logfile) || !is_writable($logger_logfile)) { - // not writable in our own directory? Skip - break; - } + if (!@touch($logger_logfile) || !is_writable($logger_logfile)) { + // not writable in our own directory? Skip + break; } self::$ml->pushHandler(new StreamHandler($logger_logfile, Logger::DEBUG)); break;