php_worker 수정
This commit is contained in:
23
app/Helpers/log_helper.php
Normal file
23
app/Helpers/log_helper.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
if (! function_exists('write_custom_log')) {
|
||||
/**
|
||||
* 전용 로그 기록 함수 (Worker, API 리시버 등 어디서나 사용 가능)
|
||||
*/
|
||||
function write_custom_log($message, $level = 'INFO', $type = 'service')
|
||||
{
|
||||
$logDir = WRITEPATH . 'logs/worker';
|
||||
if (!is_dir($logDir)) {
|
||||
@mkdir($logDir, 0777, true);
|
||||
}
|
||||
|
||||
$suffix = ($type === 'failed') ? '_failed' : '';
|
||||
$logFile = $logDir . '/' . date('Y-m-d') . $suffix . '.log';
|
||||
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$singleLine = str_replace(["\r", "\n", "\t"], " ", $message);
|
||||
$formatted = "[$timestamp] [$level] $singleLine" . PHP_EOL;
|
||||
|
||||
@file_put_contents($logFile, $formatted, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user