1.0.0 • Published 5 years ago

@churchill/file v1.0.0

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

File transport

Log to a file on the same machine. You must specify a filename where to store the logs. Note that the folder must exists before hand.

file

npm install @churchill/file

Usage

const churchill = require("@churchill/core");
const File = require("@churchill/file");

const errorFileLog = File.create({ filename: "temp/error.log", maxLevel: "error" }),
fileTransport.on("error", (err) => {
  // ... you should handle errors
});

const combinedFileLog = File.create({ filename: "temp/combined.log", maxLevel: "info" })
combinedFileLog.on("error", (err) => {
  // ... you should handle errors
});

const createNamespace = churchill({
  transports: [errorFileLog, combinedFileLog]
});

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

Options

OptionDescriptionExample
filenameFilename to log into{ filename: "error.log" }
formatCustom formatting function.{ format: (info, out, logger) => ... }
maxLevelMax level to log into this transport.{ maxLevel: "warn" }

Events

NameParamsDescription
errorerror: ErrorEmited when the destination emits an Error or there is backpressure from the destination stream
drainstreamName: stringWhen the destination stream is able to accept new messages

Methods

NameDescription
end(): PromiseCloses the destination stream