23 lines
755 B
PHP
23 lines
755 B
PHP
<?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);
|
|
}
|
|
} |