Skip to content

Wrapper for Google Cloud structured logging on stdout

License

Notifications You must be signed in to change notification settings

philsch/gcp-logging

Repository files navigation

GCP logging for nodeJS

Based on the idea of mr-pascal/nestjs-gcp-logging without nestjs references.

Motivation

Google suggests to use Bunyan or Winston as logging framework for nodeJS. This module is a more lightweight approach and utilizes the structured logging format via normal stdout, so GCP parses the log information correctly.

gcp log example

Usage

import Logger from '@philsch/gcp-logging';
import {Severity} from '@philsch/gcp-logging'; // optional: if you need additional severities

// init once (for example at the location where you init your server)
Logger.init();

// use the Logger
Logger.log("Info message");
Logger.warn("Warning message");
Logger.error("Error message");

// you can set any severity manually
Logger.log("This is an emergency", Severity.EMERGENCY);

// if you pass an Error object, a Google Cloud Error Reporting entry will be created
Logger.error(new Error("Report this in Error Reporting"));

About

Wrapper for Google Cloud structured logging on stdout

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published