refactor: structured logging across server
Create server/src/lib/logger.ts with info/warn/error methods that add [botfights:tag] timestamps. Replace bare console.log/warn/error calls in index.ts, seed.ts, routes/fights.ts, engine/queue.ts, engine/mock.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
7bd110684d
commit
f62323c59f
@@ -0,0 +1,19 @@
|
||||
function ts(): string {
|
||||
return new Date().toISOString()
|
||||
}
|
||||
|
||||
export const logger = {
|
||||
info(tag: string, message: string) {
|
||||
console.log(`[botfights:${tag}] ${ts()} ${message}`)
|
||||
},
|
||||
warn(tag: string, message: string) {
|
||||
console.warn(`[botfights:${tag}] ${ts()} ${message}`)
|
||||
},
|
||||
error(tag: string, message: string, err?: unknown) {
|
||||
if (err) {
|
||||
console.error(`[botfights:${tag}] ${ts()} ${message}`, err)
|
||||
} else {
|
||||
console.error(`[botfights:${tag}] ${ts()} ${message}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user