1.0.0 • Published 4 years ago

@churchill/console v1.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

Console transport

Log to a terminal. Uses chalk to colorize the output. By setting the errorLevel you can change which levels are logged to the standard error (stderr) instead of standard output (stdout). Usually best for local development.

console

npm install @churchill/console

Usage

const churchill = require("@churchill/core");
const Console = require("@churchill/console");

const consoleTransport = Console.create()
consoleTransport.on("error", (err) => {
  // ... you should handle errors
});

const createNamespace = churchill({
  transports: [consoleTransport]
});

const logger = createNamespace("worker:1");
logger.info("...");

Options

NameDescriptionExample
errorLevelMax log level to stream to stderr{ errorLevel: "error" }
formatCustom formatting function.{ format: (info, out, logger) => ... }
maxLevelMax level to log into this transport.{ maxLevel: "warn" }

Events

NameParamsDescription
errorerror: ErrorEmited when you encounter backpreassure for the output stream (stdout/stderr)
drainstreamName: stringWhen a stream is able to accept new messages