로그 생성이 안되어 테스트 및 수정본
This commit is contained in:
32
app/Commands/TestLog.php
Normal file
32
app/Commands/TestLog.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
class TestLog extends BaseCommand
|
||||
{
|
||||
protected $group = 'Test';
|
||||
protected $name = 'test:log';
|
||||
protected $description = 'Test log_message function';
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('Testing log_message()...', 'yellow');
|
||||
|
||||
log_message('error', '===== TEST LOG MESSAGE FROM CLI ===== ' . date('Y-m-d H:i:s'));
|
||||
log_message('debug', 'Debug level test');
|
||||
log_message('info', 'Info level test');
|
||||
|
||||
$logFile = WRITEPATH . 'logs/log-' . date('Y-m-d') . '.log';
|
||||
|
||||
CLI::write('Log file: ' . $logFile);
|
||||
CLI::write('Exists: ' . (file_exists($logFile) ? 'YES' : 'NO'));
|
||||
|
||||
if (file_exists($logFile)) {
|
||||
CLI::write('Last 10 lines:');
|
||||
CLI::write(shell_exec('tail -10 ' . escapeshellarg($logFile)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user