로그 생성이 안되어 테스트 및 수정본
This commit is contained in:
27
app/Controllers/LogTest.php
Normal file
27
app/Controllers/LogTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class LogTest extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
log_message('error', '===== WEB LOG TEST ===== ' . date('Y-m-d H:i:s'));
|
||||
log_message('info', 'Info from web');
|
||||
log_message('debug', 'Debug from web');
|
||||
|
||||
$logFile = WRITEPATH . 'logs/log-' . date('Y-m-d') . '.log';
|
||||
|
||||
echo "ENVIRONMENT: " . ENVIRONMENT . "<br>";
|
||||
echo "Log file: " . $logFile . "<br>";
|
||||
echo "Exists: " . (file_exists($logFile) ? 'YES' : 'NO') . "<br>";
|
||||
echo "Writable: " . (is_writable(dirname($logFile)) ? 'YES' : 'NO') . "<br>";
|
||||
|
||||
if (file_exists($logFile)) {
|
||||
echo "<h3>Last 20 lines:</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(shell_exec('tail -20 ' . escapeshellarg($logFile)));
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user