删除库存和旧回调管理
This commit is contained in:
@@ -35,7 +35,7 @@ const DATA_ROOT = resolveDataRoot()
|
||||
const LOG_DIR = path.join(DATA_ROOT, 'logs')
|
||||
const ACTIVE_LOG_LEVEL = normalizeLogLevel(runtimeConfig.logging?.level)
|
||||
const LOG_RETENTION_DAYS = 7
|
||||
const LEGACY_LOG_FILES = new Set(['app.log', 'webhook.log'])
|
||||
const LEGACY_LOG_FILES = new Set(['app.log', 'integration.log'])
|
||||
|
||||
let writeQueue = Promise.resolve()
|
||||
let lastCleanupDateKey = ''
|
||||
@@ -60,8 +60,8 @@ export function logError(scope, message, detail = undefined) {
|
||||
return writeLog('error', scope, message, detail)
|
||||
}
|
||||
|
||||
export function logWebhook(scope, message, detail = undefined, { level = 'info' } = {}) {
|
||||
return writeLog(level, scope, message, detail, { channel: 'webhook' })
|
||||
export function logIntegration(scope, message, detail = undefined, { level = 'info' } = {}) {
|
||||
return writeLog(level, scope, message, detail, { channel: 'integration' })
|
||||
}
|
||||
|
||||
function writeLog(level, scope, message, detail, { channel = 'app' } = {}) {
|
||||
@@ -167,7 +167,7 @@ export function formatLogEntry(entry, { color = false } = {}) {
|
||||
}
|
||||
|
||||
export function resolveLogFilePath(channel = 'app', time = new Date().toISOString()) {
|
||||
const normalizedChannel = String(channel || '').trim() === 'webhook' ? 'webhook' : 'app'
|
||||
const normalizedChannel = String(channel || '').trim() === 'integration' ? 'integration' : 'app'
|
||||
return path.join(LOG_DIR, `${normalizedChannel}-${extractLogDateKey(time)}.log`)
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ function shouldDeleteLogFileByDate(fileName, cutoffDateKey) {
|
||||
return true
|
||||
}
|
||||
|
||||
const matched = /^(app|webhook)-(\d{4}-\d{2}-\d{2})\.log$/.exec(String(fileName || '').trim())
|
||||
const matched = /^(app|integration)-(\d{4}-\d{2}-\d{2})\.log$/.exec(String(fileName || '').trim())
|
||||
|
||||
if (!matched) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user