@google-cloud/pino-logging-gcp-config
v1.0.1
Published
Module to create a basic Pino LoggerConfig to support Google Cloud structured logging
Downloads
7,481
Readme
Pino Google Cloud Logging configuration for Node.JS
This library contains the code to generate a Pino configuration which outputs JSON structured logs for Google Cloud Logging.
This can be used with any Google Cloud service that captures logs written to stdout (such as Cloud Run, Cloud Run Functions and Google Kubernetes Engine workloads), so that the logging is formatted correctly in Google Cloud Logging. This then alllows filtering by log level, the ability to include structured data in the logs, and reporting of errors with stack traces to Google Cloud Error Reporting
Features
- Converts Pino log levels to Google Cloud Logging log levels.
- Adds a millisecond-granularity timestamp in a format recognised by Google Cloud Logging.
- Adds an insertId to ensure log messages with identical timestamps are ordered correctly.
- Logs including an Error object have the stack_trace property set so that the error is forwarded to Google Cloud Error Reporting.
- Includes a ServiceContext object in the logs for Google Cloud Error Reporting.
- Maps the OpenTelemetry properties
span_id
,trace_id
,trace_flags
to the equivalent Google Cloud Logging fields.
See the full documentation on Github.