MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / log

Function log

web/scripts/discord/index.ts:21–34  ·  view source on GitHub ↗
(level: 'info' | 'error' | 'warn', message: string, data?: Record<string, unknown>)

Source from the content-addressed store, hash-verified

19
20// Diagnostic logging helper with timestamp and process info
21function log(level: 'info' | 'error' | 'warn', message: string, data?: Record<string, unknown>): void {
22 const timestamp = new Date().toISOString()
23 const pid = process.pid
24 const hostname = os.hostname()
25 const prefix = `[${timestamp}] [PID:${pid}] [host:${hostname}] [discord-bot]`
26 const dataStr = data ? ` ${JSON.stringify(data)}` : ''
27 if (level === 'error') {
28 console.error(`${prefix} ${message}${dataStr}`)
29 } else if (level === 'warn') {
30 console.warn(`${prefix} ${message}${dataStr}`)
31 } else {
32 console.log(`${prefix} ${message}${dataStr}`)
33 }
34}
35
36function sleep(ms: number): Promise<void> {
37 return new Promise((resolve) => setTimeout(resolve, ms))

Callers 3

shutdownFunction · 0.70
mainFunction · 0.70
index.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected