]> git.mxchange.org Git - friendica.git/commitdiff
Enhance syslog logging
authorPhilipp <admin@philipp.info>
Sun, 12 Dec 2021 21:45:22 +0000 (22:45 +0100)
committerPhilipp <admin@philipp.info>
Sun, 12 Dec 2021 21:45:22 +0000 (22:45 +0100)
src/Core/Logger/Factory/Logger.php
src/Core/Logger/Type/SyslogLogger.php
static/defaults.config.php
static/env.config.php

index 8f555483c80a8cb6979d64354e0a7b009b70e707..65034b6ed352ec56f1b7fdaf4fec81a8b7bd6482 100644 (file)
@@ -119,7 +119,7 @@ class Logger
 
                        case 'syslog':
                                try {
-                                       $logger = new SyslogLogger($this->channel, $introspection, $loglevel);
+                                       $logger = new SyslogLogger($this->channel, $introspection, $loglevel, $config->get('system', 'syslog_flags', SyslogLogger::DEFAULT_FLAGS), $config->get('system', 'syslog_facility', SyslogLogger::DEFAULT_FACILITY));
                                } catch (LogLevelException $exception) {
                                        // If there's a wrong config value for loglevel, try again with standard
                                        $logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
index 54cb327951323a5310e3a038c93cc779fbfd6130..ea960b0be34f80bfc365565aebbada64630822bb 100644 (file)
@@ -34,6 +34,11 @@ class SyslogLogger extends AbstractLogger
 {
        const IDENT = 'Friendica';
 
+       /** @var int The default syslog flags */
+       const DEFAULT_FLAGS = LOG_PID | LOG_ODELAY | LOG_CONS;
+       /** @var int The default syslog facility */
+       const DEFAULT_FACILITY = LOG_USER;
+
        /**
         * Translates LogLevel log levels to syslog log priorities.
         * @var array
@@ -101,7 +106,7 @@ class SyslogLogger extends AbstractLogger
         * @throws LogLevelException
         * @throws LoggerException
         */
-       public function __construct($channel, Introspection $introspection, string $level = LogLevel::NOTICE, int $logOpts = LOG_PID, int $logFacility = LOG_USER)
+       public function __construct($channel, Introspection $introspection, string $level = LogLevel::NOTICE, int $logOpts = self::DEFAULT_FLAGS, int $logFacility = self::DEFAULT_FLAGS)
        {
                parent::__construct($channel, $introspection);
                $this->logOpts     = $logOpts;
index f114b5a74af5ec74c5224365a44989c032b4fead..2df279bbd6b6a38879646408da91c0d06f7f9a72 100644 (file)
@@ -325,6 +325,14 @@ return [
                // Sets the logging adapter of Friendica globally (monolog, syslog, stream)
                'logger_config' => 'stream',
 
+               // syslog flags (Integer)
+               // Sets the syslog flags in case 'logger_config' is set to 'syslog'
+               'syslog_flags' => LOG_CONS | LOG_PID | LOG_ODELAY,
+
+               // syslog flags (Integer)
+               // Sets the syslog facility in case 'logger_config' is set to 'syslog'
+               'syslog_facility' => LOG_USER,
+
                // maintenance_start (String)
                // Start of the window for the daily maintenance cron call.
                // The system timezone is used when no timezone is defined here.
index 98c11afc270ee845e4123009059b9f901b21db93..c0590ff8c8207215f2d3137b719df5d75feec936 100644 (file)
@@ -45,6 +45,9 @@ return [
        'FRIENDICA_LOGFILE' => ['system', 'logfile'],
        'FRIENDICA_LOGLEVEL'=> ['system', 'loglevel'],
        'FRIENDICA_PROFILING' => ['system', 'profiler'],
+       'FRIENDICA_LOGGER' => ['system', 'logger_config'],
+       'FRIENDICA_SYSLOG_FLAGS' => ['system', 'syslog_flags'],
+       'FRIENDICA_SYSLOG_FACILITY' => ['system', 'syslog_facility'],
 
        // Caching
        'FRIENDICA_CACHE_DRIVER' => ['system', 'cache_driver'],