Skip to content

Commit

Permalink
feat: child loggers from frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-run committed Feb 28, 2024
1 parent b823cb4 commit eb720d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/loggingRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ export const pinoLoggingRoute = (req: NextApiRequest, res: NextApiResponse): voi
}

const messages: [objOrMsg: unknown, msgOrArgs?: string] = req.body.messages
const bindings: Record<string, string>[] = req.body.bindings ?? []

logger
.child({
...bindings,
x_timestamp: ts,
x_isFrontend: true,
x_userAgent: req.headers['user-agent'],
Expand Down
2 changes: 2 additions & 0 deletions src/loggingRouteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export const POSTLoggingRouteHandler = async (request: Request): Promise<Respons
}

const messages: [objOrMsg: unknown, msgOrArgs?: string] = body.messages
const bindings: Record<string, string>[] = body.bindings ?? []

logger
.child({
...bindings,
x_timestamp: ts,
x_isFrontend: true,
x_userAgent: request.headers.get('user-agent'),
Expand Down

0 comments on commit eb720d5

Please sign in to comment.