From 95ac11a6aad8238a8349d8bda421739307987cae Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Mon, 5 Mar 2018 13:34:04 -0800 Subject: Add system log driver and use it by default --- app/Core/Log/System.php | 25 +++++++++++++++++++++++++ app/ServiceProvider/LoggingProvider.php | 4 ++++ app/constants.php | 4 ++-- config.default.php | 4 ++-- doc/en_US/config.markdown | 7 ++++--- doc/en_US/installation.markdown | 2 +- docker/var/www/app/config.php | 2 +- 7 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 app/Core/Log/System.php 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 @@ +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 @@