mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 11:31:11 -05:00
34 lines
864 B
TypeScript
34 lines
864 B
TypeScript
/**
|
|
* Vercel Serverless Function Logger
|
|
* Provides structured JSON logging for Vercel API routes
|
|
* Matches the edge function logging pattern for consistency
|
|
*/
|
|
|
|
type LogLevel = 'info' | 'warn' | 'error';
|
|
|
|
interface LogContext {
|
|
[key: string]: unknown;
|
|
}
|
|
|
|
function formatLog(level: LogLevel, message: string, context?: LogContext): string {
|
|
return JSON.stringify({
|
|
timestamp: new Date().toISOString(),
|
|
level,
|
|
message,
|
|
service: 'vercel-ssrog',
|
|
...context
|
|
});
|
|
}
|
|
|
|
export const vercelLogger = {
|
|
info: (message: string, context?: LogContext) => {
|
|
console.info(formatLog('info', message, context));
|
|
},
|
|
warn: (message: string, context?: LogContext) => {
|
|
console.warn(formatLog('warn', message, context));
|
|
},
|
|
error: (message: string, context?: LogContext) => {
|
|
console.error(formatLog('error', message, context));
|
|
}
|
|
};
|