@hrgui/winston-cloud-logging-json-format
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@hrgui/winston-cloud-logging-json-format

Returns a winston formatter that formats it as per Google Cloud Logging LogEntry. https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity

Usage

npm install @hrgui/winston-cloud-logging-json-format
const winston = require("winston");
const CloudLoggingFormat = require("@hrgui/winston-cloud-logging-json-format");

const logger = winston.createLogger({
  level: "debug",
  format: CloudLoggingFormat(),
  transports: [new winston.transports.Console()],
});

logger.error("error");
logger.warn("warn");
logger.info("info");
logger.http("http");
logger.verbose("verbose");
logger.debug("debug");
logger.silly("silly");

Support for multiple formatters:

const logger = winston.createLogger({
  level: "debug",
  format: winston.format.combine(
    winston.format.timestamp({
      format: "YYYY-MM-DD HH:mm:ss",
    }),
    CloudLoggingFormat()
  ),
  transports: [new winston.transports.Console()],
});

logger.error("error");
logger.warn("warn");
logger.info("info");
logger.http("http");
logger.verbose("verbose");
logger.debug("debug");
logger.silly("silly");

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

  • This is just a formatter, not a transport. It formats the output. It's up to the transport on how this gets transferred.
  • This is not a official Google package - @google-cloud/logging-winston is.

Credits

printf inspired by https://www.npmjs.com/package/@google-cloud/logging-winston's Transport, but it does not make use of @google-cloud/logging. It is up to the user to provide those details.

Readme

Keywords

none

Package Sidebar

Install

npm i @hrgui/winston-cloud-logging-json-format

Weekly Downloads

105

Version

2.0.0

License

MIT

Unpacked Size

12.2 kB

Total Files

6

Last publish

Collaborators

  • hrgui