Skip to content

Commit 5078ed8

Browse files
authored
Merge pull request #10 from nguyenanhung/v3.1.14-develop
Update Storage Logging
2 parents 9f02a58 + f320b20 commit 5078ed8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

hungng/HungNG_CI_Base_Controllers.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,14 @@ protected function log($name = '', $message = '', $context = array(), $inputLeve
344344
default:
345345
$keyLevel = Monolog\Logger::INFO;
346346
}
347-
if (defined('APPPATH')) {
348-
$applicationPath = APPPATH . '/logs-data/';
347+
if (directory_exists(__DIR__ . '/../../../../storage/logs')) {
348+
$logPath = realpath(__DIR__ . '/../../../../storage/logs') . '/';
349+
} elseif (defined('APPPATH')) {
350+
$logPath = APPPATH . '/logs-data/';
349351
} else {
350-
$applicationPath = dirname(__DIR__) . '/logs-data/';
352+
$logPath = dirname(__DIR__) . '/logs-data/';
351353
}
352-
$fileName = $applicationPath . 'Log-' . date('Y-m-d') . '.log';
354+
$fileName = $logPath . 'Log-' . date('Y-m-d') . '.log';
353355
$formatter = new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n", "Y-m-d H:i:s u");
354356
$stream = new Monolog\Handler\StreamHandler($fileName, $keyLevel, true, 0777);
355357
$stream->setFormatter($formatter);

hungng/HungNG_CI_Base_Module.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,14 @@ protected function log($name = '', $message = '', $context = array(), $inputLeve
344344
default:
345345
$keyLevel = Monolog\Logger::INFO;
346346
}
347-
if (defined('APPPATH')) {
348-
$applicationPath = APPPATH . '/logs-data/';
347+
if (directory_exists(__DIR__ . '/../../../../storage/logs')) {
348+
$logPath = realpath(__DIR__ . '/../../../../storage/logs') . '/';
349+
} elseif (defined('APPPATH')) {
350+
$logPath = APPPATH . '/logs-data/';
349351
} else {
350-
$applicationPath = dirname(__DIR__) . '/logs-data/';
352+
$logPath = dirname(__DIR__) . '/logs-data/';
351353
}
352-
$fileName = $applicationPath . 'Log-' . date('Y-m-d') . '.log';
354+
$fileName = $logPath . 'Log-' . date('Y-m-d') . '.log';
353355
$formatter = new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n", "Y-m-d H:i:s u");
354356
$stream = new Monolog\Handler\StreamHandler($fileName, $keyLevel, true, 0777);
355357
$stream->setFormatter($formatter);

0 commit comments

Comments
 (0)