1.2.0 • Published 5 years ago

@hrgui/bunyan-cloud-logging-stdout-format v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

@hrgui/bunyan-cloud-logging-stdout-format

Formats Bunyan logs that output to stdout to be easily picked up by Google Cloud Logging.

Quickstart

npm install @hrgui/bunyan-cloud-logging-stdout-format
const {
  CloudLoggingStream,
} = require("@hrgui/bunyan-cloud-logging-stdout-format");
const bunyan = require("bunyan");

const logger = bunyan.createLogger({
  name: "myapp",
  streams: [new CloudLoggingStream().stream("info")],
});

logger.info("hello world");
{"timestamp":"2020-09-22T06:58:46.564Z","severity":"INFO","name":"myapp","hostname":"harman-comp.local","pid":20499,"level":30,"time":"2020-09-22T06:58:46.564Z","v":0,"message":"hello world"}

bunyan-cli doesn't work.

This is because Cloud Logging prefers message over msg. This module supports writing to both message and msg via flag called bunyanReadable.

Example

const {
  CloudLoggingStream,
} = require("@hrgui/bunyan-cloud-logging-stdout-format");
const bunyan = require("bunyan");

const logger = bunyan.createLogger({
  name: "myapp",
  streams: [new CloudLoggingStream({ bunyanReadable: true }).stream("info")],
});

logger.info("hello world");
node index.js | bunyan
[2020-09-22T07:19:05.642Z]  INFO: myapp/21716 on harmans-comp.local: hello world (timestamp=2020-09-22T07:19:05.642Z, severity=INFO, message="hello world")

Note that to support both Cloud Logging and bunyan, "hello world" was printed to both msg and message.

What's the difference between @google-cloud/logging-bunyan and this?

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago