php_worker 수정

This commit is contained in:
2025-12-23 16:19:22 +09:00
parent 454bb77a07
commit 76e79ea4cf
3 changed files with 52 additions and 13 deletions

View 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);
}
}