Skip to content

Commit

Permalink
correctly handle empty logger.logfile setting if 'file' is in the act…
Browse files Browse the repository at this point in the history
…ivated log-types and no file name was given, thx to Oops

Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Nov 26, 2023
1 parent 6a1e7cc commit b13b1e8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/Froxlor/FroxlorLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b13b1e8

Please sign in to comment.