Add system log driver and use it by default
This commit is contained in:
parent
299198f718
commit
95ac11a6aa
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ use Kanboard\Core\Log\Stderr;
|
||||||
use Kanboard\Core\Log\Stdout;
|
use Kanboard\Core\Log\Stdout;
|
||||||
use Kanboard\Core\Log\Syslog;
|
use Kanboard\Core\Log\Syslog;
|
||||||
use Kanboard\Core\Log\File;
|
use Kanboard\Core\Log\File;
|
||||||
|
use Kanboard\Core\Log\System;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LoggingProvider
|
* Class LoggingProvider
|
||||||
|
|
@ -37,6 +38,9 @@ class LoggingProvider implements ServiceProviderInterface
|
||||||
case 'file':
|
case 'file':
|
||||||
$driver = new File(LOG_FILE);
|
$driver = new File(LOG_FILE);
|
||||||
break;
|
break;
|
||||||
|
case 'system':
|
||||||
|
$driver = new System();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($driver !== null) {
|
if ($driver !== null) {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ defined('PLUGIN_INSTALLER') or define('PLUGIN_INSTALLER', true);
|
||||||
// Enable/disable debug
|
// Enable/disable debug
|
||||||
defined('DEBUG') or define('DEBUG', strtolower(getenv('DEBUG')) === 'true');
|
defined('DEBUG') or define('DEBUG', strtolower(getenv('DEBUG')) === 'true');
|
||||||
|
|
||||||
// Logging drivers: syslog, stdout, stderr or file
|
// Logging drivers: syslog, stdout, stderr, system or file
|
||||||
defined('LOG_DRIVER') or define('LOG_DRIVER', '');
|
defined('LOG_DRIVER') or define('LOG_DRIVER', 'system');
|
||||||
|
|
||||||
// Logging file
|
// Logging file
|
||||||
defined('LOG_FILE') or define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');
|
defined('LOG_FILE') or define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ define('DATA_DIR', __DIR__.DIRECTORY_SEPARATOR.'data');
|
||||||
// Enable/Disable debug
|
// Enable/Disable debug
|
||||||
define('DEBUG', false);
|
define('DEBUG', false);
|
||||||
|
|
||||||
// Available log drivers: syslog, stderr, stdout or file
|
// Available log drivers: syslog, stderr, stdout, system or file
|
||||||
define('LOG_DRIVER', '');
|
define('LOG_DRIVER', 'system');
|
||||||
|
|
||||||
// Log filename if the log driver is "file"
|
// Log filename if the log driver is "file"
|
||||||
define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');
|
define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,15 @@ Enable/Disable debug mode
|
||||||
|
|
||||||
```php
|
```php
|
||||||
define('DEBUG', true);
|
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:
|
// By default, the log file is in data/debug.log but you can change the path:
|
||||||
define('LOG_FILE', '/path/to/debug.log');
|
define('LOG_FILE', '/path/to/debug.log');
|
||||||
```
|
```
|
||||||
|
|
||||||
The log driver must be defined if you enable the debug mode.
|
- 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 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
|
Plugins
|
||||||
-------
|
-------
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ From the archive (stable version)
|
||||||
The `data` folder is used to store:
|
The `data` folder is used to store:
|
||||||
|
|
||||||
- Sqlite database: `db.sqlite`
|
- 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/*`
|
- Uploaded files: `files/*`
|
||||||
- Image thumbnails: `files/thumbnails/*`
|
- Image thumbnails: `files/thumbnails/*`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('ENABLE_URL_REWRITE', true);
|
define('ENABLE_URL_REWRITE', true);
|
||||||
define('LOG_DRIVER', 'stderr');
|
define('LOG_DRIVER', 'system');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue