MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / requestLogger

Function requestLogger

run/idp-sql/middleware.js:54–63  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

52// Add logging field with trace ID for logging correlation
53// For more info, see https://cloud.google.com/run/docs/logging#correlate-logs
54const requestLogger = (req, res, next) => {
55 const traceHeader = req.header('X-Cloud-Trace-Context');
56 let trace;
57 if (traceHeader) {
58 const [traceId] = traceHeader.split('/');
59 trace = `projects/${project}/traces/${traceId}`;
60 }
61 req.logger = logger.child({'logging.googleapis.com/trace': trace});
62 next();
63};
64
65module.exports = {
66 authenticateJWT,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected