Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2725 : move logging directory path config to CodeIgniter\Log\Handlers\FileHandler config #2726

Merged
merged 10 commits into from
Mar 22, 2020
17 changes: 8 additions & 9 deletions app/Config/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ class Logger extends BaseConfig
*/
public $threshold = 3;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
| By default, logs are written to WRITEPATH . 'logs/'
| Specify a different destination here, if desired.
*/
public $path = '';

/*
|--------------------------------------------------------------------------
| Date Format for Logs
Expand Down Expand Up @@ -116,6 +107,14 @@ class Logger extends BaseConfig
* integer notation (i.e. 0700, 0644, etc.)
*/
'filePermissions' => 0644,

/*
* Error Logging Directory Path
samsonasik marked this conversation as resolved.
Show resolved Hide resolved
*
* By default, logs are written to WRITEPATH . 'logs/'
* Specify a different destination here, if desired.
*/
'path' => '',
],

/**
Expand Down
3 changes: 2 additions & 1 deletion system/Log/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function __construct(array $config = [])
{
parent::__construct($config);

$this->path = $config['path'] ?? WRITEPATH . 'logs/';
$config['path'] = $config['path'] ?? WRITEPATH . 'logs/';
$this->path = $config['path'] ?: WRITEPATH . 'logs/';
samsonasik marked this conversation as resolved.
Show resolved Hide resolved

$this->fileExtension = empty($config['fileExtension']) ? 'log' : $config['fileExtension'];
$this->fileExtension = ltrim($this->fileExtension, '.');
Expand Down
15 changes: 5 additions & 10 deletions system/Test/Mock/MockLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ class MockLogger

public $threshold = 9;

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
|
|
*/
public $path = '';

/*
|--------------------------------------------------------------------------
| Date Format for Logs
Expand Down Expand Up @@ -97,6 +87,11 @@ class MockLogger
'notice',
'warning',
],

/*
* Error Logging Directory Path
*/
'path' => '',
],
];

Expand Down