2.0.0 • Published 7 months ago

@ert78gb/pino-google-cloud-run-options v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

pino Google Cloud Run options

The package contains default configuration of the pino logger in the Google Cloud Run.

Google Cloud Run collects the logs from the standard output and standard error. If 1 log line is a valid json then the log aggregator parse it as a json and extract/move the severity and message properties to relevant p the LogEntry.

Pino has 6 log level by default. The Google Log has 9. The following table contains the mapping

pinoGoogle Log
traceDEBUG
debugDEBUG
infoINFO
warnWARNING
errorERROR
fatalCRITICAL

The custom log levels map to the DEFAULT Google Log level if you don't write custom formatter.

It does not log the hostname and pid information, because Google Cloud Run logs the instance id and other context information.

import pinoOptions from '@ert78gb/pino-google-cloud-run-options'
import pino from 'pino'

const logger = pino(pinoOptions)
// or extend
const logger = pino({
  ...pinoOptions,
  level: process.env.LOG_LEVEL
})