story-generator/supabase/functions/process-audio/logger.ts
2024-12-27 15:56:41 -03:00

37 lines
784 B
TypeScript

export interface LogContext {
requestId: string
recordId: string
step: string
timestamp: string
}
export function createLogger(recordId: string) {
const requestId = crypto.randomUUID()
return {
info: (step: string, message: string, data?: any) => {
console.log(JSON.stringify({
level: 'info',
requestId,
recordId,
step,
message,
data,
timestamp: new Date().toISOString()
}))
},
error: (step: string, error: Error, data?: any) => {
console.error(JSON.stringify({
level: 'error',
requestId,
recordId,
step,
message: error.message,
stack: error.stack,
data,
timestamp: new Date().toISOString()
}))
}
}
}