nodejs-logging-winston icon indicating copy to clipboard operation
nodejs-logging-winston copied to clipboard

Using Winston logging library locally (on MAC) prints same error too many times when cloud credentials are not provided

Open losalex opened this issue 4 years ago • 0 comments

  1. Is this a client library issue or a product issue? When running locally on my MAC, I got too many errors:

(node:11479) UnhandledPromiseRejectionWarning: Error: Unable to detect a Project Id in the current environment.

Ideally this should be printed only once as warning and ignored later, since otherwise logs printed into console become a mess. Also worth mentioning that locally I might not need to use any project ID if I don't want to use Cloud Logging, so printing warning once good enough.

  1. Did someone already solve this? No

  2. Do you have a support contract? No

Environment details

  • OS: Mac
  • Node.js version: v14.17.6
  • npm version: 6.14.15
  • @google-cloud/logging-winston version: ^4.1.1

Steps to reproduce

Just create logger by code below and use it by callingAPIs like logger.info while credentials are not set, e.g.:

function createLogger() {
  return winston.createLogger({
    level: 'info',
    transports: [
      new winston.transports.Console(),
      // Add Stackdriver Logging
      new LoggingWinston(),
    ],
  });
}

losalex avatar Nov 04 '21 23:11 losalex