
# Log File

[![npm version](https://badge.fury.io/js/log-file.svg)](https://badge.fury.io/js/log-file)

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

## Installation

```bash
npm install lgfl
```

## Usage

```javascript
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.