How to use the @google-cloud/logging-bunyan.express function in @google-cloud/logging-bunyan

To help you get started, we’ve selected a few @google-cloud/logging-bunyan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-logging-bunyan / samples / express.js View on Github external
async function startServer() {
  const {logger, mw} = await lb.express.middleware({
    logName: 'samples_express',
  });
  const app = express();

  // Install the logging middleware. This ensures that a Bunyan-style `log`
  // function is available on the `request` object. This should be the very
  // first middleware you attach to your app.
  app.use(mw);

  // Setup an http route and a route handler.
  app.get('/', (req, res) => {
    // `req.log` can be used as a bunyan style log method. All logs generated
    // using `req.log` use the current request context. That is, all logs
    // corresponding to a specific request will be bundled in the Stackdriver
    // UI.
    req.log.info('this is an info log message');

@google-cloud/logging-bunyan

Cloud Logging stream for Bunyan

Apache-2.0
Latest version published 1 month ago

Package Health Score

84 / 100
Full package analysis