UNPKG

@code-nl/cloud-logging

Version:

Interface over @google-cloud/logging

36 lines (22 loc) 1.01 kB
# Cloud logging This cloud logging package is an interface for [@google-cloud/logging](https://www.npmjs.com/package/@google-cloud/logging). Once initialized, you might use it as simple as: `log.info("order processed", {orderId: "1209235823"});`. The first argument is the message, the second argument is an object to create log labels with. Those labels are very helpfull in order to filter you log messages afterwards. You'd better use them! ## Install ```bash npm i @code-nl/cloud-logging --save ``` ## Usage In order to make use of the cloud logging, you need to initialize the logger. It takes 2 arguments: 1. Google Cloud project id 2. Log name which is the grouper ```javascript const log = require("@code-nl/cloud-logging"); // initialize with: // project id: "my-gcp-project-id" // log name: "some-log-name" log.init("my-gcp-project-id", "some-log-name"); // create a log message with severity "info" log.info("My log message with useful context", {id: "1234", test: "ABC"}); ```