logging
This commit is contained in:
@@ -26,7 +26,12 @@ function formatTimestamp(): string {
|
||||
|
||||
function formatContext(context?: LogContext): string {
|
||||
if (!context || Object.keys(context).length === 0) return '';
|
||||
return ' ' + JSON.stringify(context);
|
||||
|
||||
const lines = Object.entries(context)
|
||||
.map(([key, value]) => ` ${key}=${value}`)
|
||||
.join('\n');
|
||||
|
||||
return '\n' + lines;
|
||||
}
|
||||
|
||||
function log(level: LogLevel, message: string, context?: LogContext) {
|
||||
|
||||
@@ -146,8 +146,8 @@ piRestRouter.get('/pi/sessions/:sessionId', async (ctx: Context) => {
|
||||
messages,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error('Failed to get session', { sessionId, email: ctx.get('email'), error: String(err) });
|
||||
} catch {
|
||||
// Session not found - this is expected for new sessions, don't log as error
|
||||
return ctx.json({ error: 'Session not found' }, 404);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user