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
8 changes: 8 additions & 0 deletions app/Config/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ class Logger extends BaseConfig
* integer notation (i.e. 0700, 0644, etc.)
*/
'filePermissions' => 0644,

/*
* Logging Directory Path
*
* By default, logs are written to WRITEPATH . 'logs/'
* Specify a different destination here, if desired.
*/
'path' => '',
],

/**
Expand Down
1 change: 1 addition & 0 deletions app/Controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Home extends BaseController
{
public function index()
{
$this->logger->emergency('This will not be written to a file in the WRITEPATH/uploads folder');
return view('welcome_message');
}

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