Skip to content

Commit

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

$this->path = $config['path'] ?? WRITEPATH . 'logs/';
if (! isset($config['path']))
{
$this->path = config('Logger')->path ?: WRITEPATH . 'logs/';
}
else
{
$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 3169889

Please sign in to comment.