Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

lgfl

Aethera11MIT1.0.0

A lightweight Node.js library for file-based logging (Console.log and errors).

log-file, error-log, logging, file-logging, log-error

readme

Log File

npm version

"log-file" is a lightweight Node.js library for file-based logging.

Installation

npm install lgfl

Usage

const log = require("lgfl");

const consoleLog = log("./path/to/console.log");
consoleLog("Log message");

function onError(err) {
  log.onError(err, "./path/to/errors.log");
}

try {
  // Your code that may generate an error
} catch (err) {
  onError(err);
}

API

log(filePath: string): Function

Creates a log function that appends messages to the specified file path.

  • filePath (string): The path to the log file.

onError(err: Error, filePath: string): void

Logs error details to the specified file path.

  • err (Error): The error object to log.
  • filePath (string): The path to the error log file.