# node-filelog

> Easily log your data to files, with this module.

Latest version **1.0.15** (published 2015-04-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install node-filelog
pnpm add node-filelog
yarn add node-filelog
bun add node-filelog
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2015-04-30 |
| First published | 2015-04-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tommy Vercety |
| Maintainers | donvercety |
| Keywords | log, logger, node, node-logger, logging, file, file-logger |

## Links

- npm: https://www.npmjs.com/package/node-filelog
- Repository: https://github.com/donvercety/node-filelog
- Issues: https://github.com/donvercety/node-filelog/issues
- npm.io page: https://npm.io/package/node-filelog

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.15 (latest) — 2015-04-30
- 1.0.1 — 2015-04-30
- 1.0.0 — 2015-04-29

## README

### log your data to files

This module gives you the ability to log to files, it uses two logging methods: `msg()` and `err()`. As expected `msg()` is for normal logging, you should use `err()` to log critical system errors. The logger makes a filename with the current date, this way it separates a different log file for each day. Each file row starts with a timestamp when the log occurred, followed by the keyword in brackets. All this makes it extremely easy for filtering the files with tools like `grep`.

#### Simple Usage:
```js
var logger = require('node-filelog'),
    log = new logger();

log.msg('test', 'this is a test log message'); // <163751[test]> this is a test log message

log.err('database', 'authentication error');   // <163751[database]> authentication error
```

By default the module uses the location of the file that is run from to log your data, for both log and err files. You can custom add your own folders to log just by adding two parameters when instantiating the logger object. ( **Folders must exist!** )

```js
log = new logger('/path/to/msg-folder', '/path/to/err-folder');
```

The first parameter is the so called 'keyword', helpful for tagging different logs. If you just want the plain log with no keywords only time and log data use.

```js
log.useShortLog();
 
log.msg('this is a test log message'); // <164924> this is a test log message
log.err('authentication error');       // <164924> authentication error
```

The format of the date and time is not really readable, but once you understand it it makes sense. Nonetheless there is a possibility to add separators, to make it more human readable:


```js
log.setTimeSeparator(':');

log.msg('test', 'this is a test log message'); // <16:58:31[test]> this is a test log message
log.err('database', 'authentication error');   // <16:58:31[database]> authentication error
```

The same is applicable for the filename using: `log.setDateSeparator(separator)`

---
_Source: https://npm.io/package/node-filelog · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
