mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:31:13 -05:00
Fix logging and robots.txt
This commit is contained in:
33
api/utils/logger.ts
Normal file
33
api/utils/logger.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user