1.0.0 • Published 10 months ago

lgfl v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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.