Skip to content

Commit

Permalink
Fixes codeigniter4#2725 : move logging directory path config to CodeI…
Browse files Browse the repository at this point in the history
…gniter\Log\Handlers\FileHandler config
  • Loading branch information
samsonasik committed Mar 20, 2020
1 parent 84b9cc7 commit a01ab8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion system/Log/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(array $config = [])
{
parent::__construct($config);

$this->path = $config['path'] ?? WRITEPATH . 'logs/';
$this->path = $config['path'] ?: WRITEPATH . 'logs/';

$this->fileExtension = empty($config['fileExtension']) ? 'log' : $config['fileExtension'];
$this->fileExtension = ltrim($this->fileExtension, '.');
Expand Down

0 comments on commit a01ab8d

Please sign in to comment.