diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Syslog.php b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Syslog.php new file mode 100644 index 000000000..f1895067d --- /dev/null +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Syslog.php @@ -0,0 +1,81 @@ +iLogLevel = \defined('LOG_INFO') ? LOG_INFO : 6; + + if (\function_exists('openlog') && \function_exists('closelog') && \defined('LOG_ODELAY') && \defined('LOG_USER')) + { + \openlog('rainloop', LOG_ODELAY, LOG_USER); + + \register_shutdown_function(function () { + @\closelog(); + }); + } + else + { + $this->iLogLevel = null; + } + } + + /** + * @return \MailSo\Log\Drivers\Syslog + */ + public static function NewInstance() + { + return new self(); + } + + /** + * @param string|array $mDesc + * + * @return bool + */ + protected function writeImplementation($mDesc) + { + if (null === $this->iLogLevel) + { + return false; + } + + if (\is_array($mDesc)) + { + $mDesc = \implode($this->sNewLine, $mDesc); + } + + return \syslog($this->iLogLevel, $mDesc); + } + + /** + * @return bool + */ + protected function clearImplementation() + { + return true; + } +} diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index ed9e95ccc..ff44a088f 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -214,16 +214,6 @@ class Actions { $this->oConfig = new \RainLoop\Config\Application(); -// $bSave = defined('APP_INSTALLED_START'); -// if (!$this->oConfig->Load()) -// { -// $bSave = true; -// } -// else if (!$bSave) -// { -// $bSave = APP_VERSION !== $this->oConfig->Get('version', 'current'); -// } - $bSave = defined('APP_INSTALLED_START'); $bLoaded = $this->oConfig->Load(); @@ -1087,22 +1077,31 @@ class Actions $this->oLogger->SetShowSecter(!$this->Config()->Get('logs', 'hide_passwords', true)); - $sLogFileFullPath = \APP_PRIVATE_DATA.'logs/'.$this->compileLogFileName( - $this->Config()->Get('logs', 'filename', '')); + $sLogFileName = $this->Config()->Get('logs', 'filename', ''); - $sLogFileDir = \dirname($sLogFileFullPath); - - if (!@is_dir($sLogFileDir)) + $oDriver = null; + if ('syslog' === $sLogFileName) { - @mkdir($sLogFileDir, 0755, true); + $oDriver = \MailSo\Log\Drivers\Syslog::NewInstance(); + } + else + { + $sLogFileFullPath = \APP_PRIVATE_DATA.'logs/'.$this->compileLogFileName($sLogFileName); + $sLogFileDir = \dirname($sLogFileFullPath); + + if (!@is_dir($sLogFileDir)) + { + @mkdir($sLogFileDir, 0755, true); + } + + $oDriver = \MailSo\Log\Drivers\File::NewInstance($sLogFileFullPath); } - $this->oLogger->Add( - \MailSo\Log\Drivers\File::NewInstance($sLogFileFullPath) - ->WriteOnErrorOnly($this->Config()->Get('logs', 'write_on_error_only', false)) - ->WriteOnPhpErrorOnly($this->Config()->Get('logs', 'write_on_php_error_only', false)) - ->WriteOnTimeoutOnly($this->Config()->Get('logs', 'write_on_timeout_only', 0)) - ->SetTimeOffset($iTimeOffset) + $this->oLogger->Add($oDriver + ->WriteOnErrorOnly($this->Config()->Get('logs', 'write_on_error_only', false)) + ->WriteOnPhpErrorOnly($this->Config()->Get('logs', 'write_on_php_error_only', false)) + ->WriteOnTimeoutOnly($this->Config()->Get('logs', 'write_on_timeout_only', 0)) + ->SetTimeOffset($iTimeOffset) ); if (!$this->Config()->Get('debug', 'enable', false))