From 3169889b26eb16da1a5231195a48b095ee06f047 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Mar 2020 15:52:17 +0700 Subject: [PATCH] Fixes #2725 : use config("Logger")->path to read config path in FileHandler logger --- app/Controllers/Home.php | 1 + system/Log/Handlers/FileHandler.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 8798cdd8e4c0..d40d20bfeb17 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -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'); } diff --git a/system/Log/Handlers/FileHandler.php b/system/Log/Handlers/FileHandler.php index 78a321862728..0e29069cd373 100644 --- a/system/Log/Handlers/FileHandler.php +++ b/system/Log/Handlers/FileHandler.php @@ -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, '.');