Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// automatically.
let emitRequestLog;
if (env !== GCPEnv.APP_ENGINE && env !== GCPEnv.CLOUD_FUNCTIONS) {
const loggingBunyanReq = new LoggingBunyan(options);
const requestLogger = bunyan.createLogger({
name: options.logName!,
streams: [loggingBunyanReq.stream(options.level as types.LogLevel)],
});
emitRequestLog = (httpRequest: HttpRequest, trace: string) => {
requestLogger.info({[LOGGING_TRACE_KEY]: trace, httpRequest});
};
}
return {
logger,
mw: commonMiddleware.express.makeMiddleware(
projectId,
makeChildLogger,
emitRequestLog
),
};
function makeChildLogger(trace: string) {
return logger.child({[LOGGING_TRACE_KEY]: trace}, true /* simple child */);
}
}