@philsch/gcp-logging
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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.

This is an image

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"));

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @philsch/gcp-logging

    Weekly Downloads

    1

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    7.66 kB

    Total Files

    15

    Last publish

    Collaborators

    • philsch