diff options
author | Frédéric Guillot <fred@kanboard.net> | 2018-03-05 13:34:04 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2018-03-05 13:34:04 -0800 |
commit | 95ac11a6aad8238a8349d8bda421739307987cae (patch) | |
tree | ebd4c8ff1bfa8ea9db74a1e7c1b8ea62336d2d6b | |
parent | 299198f7181fccf1e9a684649d173a1ebbdfbd1e (diff) |
Add system log driver and use it by default
-rw-r--r-- | app/Core/Log/System.php | 25 | ||||
-rw-r--r-- | app/ServiceProvider/LoggingProvider.php | 4 | ||||
-rw-r--r-- | app/constants.php | 4 | ||||
-rw-r--r-- | config.default.php | 4 | ||||
-rw-r--r-- | doc/en_US/config.markdown | 7 | ||||
-rw-r--r-- | doc/en_US/installation.markdown | 2 | ||||
-rw-r--r-- | docker/var/www/app/config.php | 2 |
7 files changed, 39 insertions, 9 deletions
diff --git a/app/Core/Log/System.php b/app/Core/Log/System.php new file mode 100644 index 00000000..ce801a02 --- /dev/null +++ b/app/Core/Log/System.php @@ -0,0 +1,25 @@ +<?php + +namespace Kanboard\Core\Log; + +/** + * Built-in PHP Logger + * + * @package Kanboard\Core\Log + * @author Frédéric Guillot + */ +class System extends Base +{ + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return null + */ + public function log($level, $message, array $context = []) + { + error_log('['.$level.'] '.$this->interpolate($message, $context)); + } +} diff --git a/app/ServiceProvider/LoggingProvider.php b/app/ServiceProvider/LoggingProvider.php index eba9d0c4..2ff6ba4f 100644 --- a/app/ServiceProvider/LoggingProvider.php +++ b/app/ServiceProvider/LoggingProvider.php @@ -10,6 +10,7 @@ use Kanboard\Core\Log\Stderr; use Kanboard\Core\Log\Stdout; use Kanboard\Core\Log\Syslog; use Kanboard\Core\Log\File; +use Kanboard\Core\Log\System; /** * Class LoggingProvider @@ -37,6 +38,9 @@ class LoggingProvider implements ServiceProviderInterface case 'file': $driver = new File(LOG_FILE); break; + case 'system': + $driver = new System(); + break; } if ($driver !== null) { diff --git a/app/constants.php b/app/constants.php index 35d651e8..c47f8e87 100644 --- a/app/constants.php +++ b/app/constants.php @@ -26,8 +26,8 @@ defined('PLUGIN_INSTALLER') or define('PLUGIN_INSTALLER', true); // Enable/disable debug defined('DEBUG') or define('DEBUG', strtolower(getenv('DEBUG')) === 'true'); -// Logging drivers: syslog, stdout, stderr or file -defined('LOG_DRIVER') or define('LOG_DRIVER', ''); +// Logging drivers: syslog, stdout, stderr, system or file +defined('LOG_DRIVER') or define('LOG_DRIVER', 'system'); // Logging file defined('LOG_FILE') or define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log'); diff --git a/config.default.php b/config.default.php index 31849160..c9a387e0 100644 --- a/config.default.php +++ b/config.default.php @@ -10,8 +10,8 @@ define('DATA_DIR', __DIR__.DIRECTORY_SEPARATOR.'data'); // Enable/Disable debug define('DEBUG', false); -// Available log drivers: syslog, stderr, stdout or file -define('LOG_DRIVER', ''); +// Available log drivers: syslog, stderr, stdout, system or file +define('LOG_DRIVER', 'system'); // Log filename if the log driver is "file" define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log'); diff --git a/doc/en_US/config.markdown b/doc/en_US/config.markdown index 20ef03b3..a5497d64 100644 --- a/doc/en_US/config.markdown +++ b/doc/en_US/config.markdown @@ -9,14 +9,15 @@ Enable/Disable debug mode ```php define('DEBUG', true); -define('LOG_DRIVER', 'file'); // Other drivers are: syslog, stdout, stderr or file +define('LOG_DRIVER', 'file'); // Other drivers are: syslog, stdout, stderr, system or file // By default, the log file is in data/debug.log but you can change the path: define('LOG_FILE', '/path/to/debug.log'); ``` -The log driver must be defined if you enable the debug mode. -The debug mode logs all SQL queries and the time taken to generate pages. +- The log driver must be defined if you enable the debug mode. +- The debug mode logs all SQL queries and the time taken to generate pages. +- The `system` driver use the built-in PHP logger which could be configured in the [php.ini](http://php.net/manual/en/errorfunc.configuration.php#ini.error-log). By default, log messages are sent to the web server logs. Plugins ------- diff --git a/doc/en_US/installation.markdown b/doc/en_US/installation.markdown index 543ca4d0..aaa93f7d 100644 --- a/doc/en_US/installation.markdown +++ b/doc/en_US/installation.markdown @@ -17,7 +17,7 @@ From the archive (stable version) The `data` folder is used to store: - Sqlite database: `db.sqlite` -- Debug file: `debug.log` (if debug mode is enabled) +- Debug file: `debug.log` (if debug mode is enabled with the `file` driver) - Uploaded files: `files/*` - Image thumbnails: `files/thumbnails/*` diff --git a/docker/var/www/app/config.php b/docker/var/www/app/config.php index 58daff48..f8fb11e9 100644 --- a/docker/var/www/app/config.php +++ b/docker/var/www/app/config.php @@ -1,4 +1,4 @@ <?php define('ENABLE_URL_REWRITE', true); -define('LOG_DRIVER', 'stderr'); +define('LOG_DRIVER', 'system'); |