(level: 'info' | 'error' | 'warn', message: string, data?: Record<string, unknown>)
| 27 | |
| 28 | // Diagnostic logging helper with timestamp and process info |
| 29 | function logLock(level: 'info' | 'error' | 'warn', message: string, data?: Record<string, unknown>): void { |
| 30 | const timestamp = new Date().toISOString() |
| 31 | const pid = process.pid |
| 32 | const prefix = `[${timestamp}] [PID:${pid}] [advisory-lock]` |
| 33 | const dataStr = data ? ` ${JSON.stringify(data)}` : '' |
| 34 | if (level === 'error') { |
| 35 | console.error(`${prefix} ${message}${dataStr}`) |
| 36 | } else if (level === 'warn') { |
| 37 | console.warn(`${prefix} ${message}${dataStr}`) |
| 38 | } else { |
| 39 | console.log(`${prefix} ${message}${dataStr}`) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | export interface LockHandle { |
| 44 | /** Register a callback to be called if the lock is lost (connection dies) */ |
no outgoing calls
no test coverage detected