@google-cloud/pino-logging-gcp-config
v1.0.2
Published
Module to create a basic Pino LoggerConfig to support Google Cloud structured logging
Downloads
38,364
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.
- Uses
message
instead ofmsg
for the message key. - Adds a millisecond-granularity timestamp in a
format recognised by Google Cloud Logging,
eg:
"timestamp":{"seconds":1445470140,"nanos":123000000}
. - Adds a sequential 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.