A Node.js package for automatic log correlation in Google Cloud Platform using trace context
npm install nodejs-gcp-log-correlationA Node.js package for automatic log correlation in Google Cloud Platform with zero configuration.
``bash`
npm install nodejs-gcp-log-correlation
`typescript
import express from 'express';
import { logger, loggerMiddleware } from 'nodejs-gcp-log-correlation';
const app = express();
app.use(loggerMiddleware());
app.get('/', (req, res) => {
logger.info('Request processed'); // Automatically correlated with trace
res.json({ status: 'ok' });
});
`
`typescript
import { wrapCloudFunction, logger } from 'nodejs-gcp-log-correlation';
export const handler = wrapCloudFunction((req, res) => {
logger.info('Function executed'); // Automatically correlated with trace
res.send('Done!');
});
`
- NODE_ENVGOOGLE_CLOUD_PROJECT`
-
MIT