diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php index 47aa51db8..5f4ca9018 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php @@ -23,11 +23,7 @@ class File extends \MailSo\Log\Driver function __construct(string $sLoggerFileName) { parent::__construct(); - $this->SetLoggerFileName($sLoggerFileName); - } - public function SetLoggerFileName(string $sLoggerFileName) - { $sLogFileDir = \dirname($sLoggerFileName); if (!\is_dir($sLogFileDir)) { \mkdir($sLogFileDir, 0755, true); @@ -37,19 +33,14 @@ class File extends \MailSo\Log\Driver protected function writeImplementation($mDesc) : bool { - return $this->writeToLogFile($mDesc); + if (\is_array($mDesc)) { + $mDesc = \implode("\n\t", $mDesc); + } + return \error_log($mDesc . "\n", 3, $this->sLoggerFileName); } protected function clearImplementation() : bool { return \unlink($this->sLoggerFileName); } - - private function writeToLogFile($mDesc) : bool - { - if (\is_array($mDesc)) { - $mDesc = \implode("\n\t", $mDesc); - } - return \error_log($mDesc . "\n", 3, $this->sLoggerFileName); - } } diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/StderrStream.php b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/StderrStream.php new file mode 100644 index 000000000..eb09af466 --- /dev/null +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Log/Drivers/StderrStream.php @@ -0,0 +1,30 @@ +oConfig->Get('logs', 'filename', ''); if ('syslog' === $sLogFileName) { $oDriver = new \MailSo\Log\Drivers\Syslog(); + } else if ('stderr' === $sLogFileName) { + $oDriver = new \MailSo\Log\Drivers\StderrStream(); } else { $sLogFileFullPath = \trim($this->oConfig->Get('logs', 'path', '')) ?: \APP_PRIVATE_DATA . 'logs'; \is_dir($sLogFileFullPath) || \mkdir($sLogFileFullPath, 0700, true); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 8de03de9c..662e9a0f8 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -340,7 +340,8 @@ Examples: filename = "log-{date:Y-m-d}.txt" filename = "{date:Y-m-d}/{user:domain}/{user:email}_{user:uid}.log" filename = "{user:email}-{date:Y-m-d}.txt" - filename = "syslog"'), + filename = "syslog" + filename = "stderr"'), 'auth_logging' => array(false, 'Enable auth logging in a separate file (for fail2ban)'), 'auth_logging_filename' => array('fail2ban/auth-{date:Y-m-d}.txt'),