# console-files

> Simple package to handle console output to files

Latest version **2.3.1** (published 2019-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install console-files
pnpm add console-files
yarn add console-files
bun add console-files
```

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.3.1 |
| Published | 2019-06-14 |
| First published | 2018-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Leonardo Matos de Paula |
| Maintainers | leomp12 |
| Keywords | console, logger, files, debug, output |

## Links

- npm: https://www.npmjs.com/package/console-files
- Repository: https://github.com/leomp12/console-files
- Homepage: https://github.com/leomp12/console-files#readme
- Issues: https://github.com/leomp12/console-files/issues
- npm.io page: https://npm.io/package/console-files

## 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

- 2.3.1 (latest) — 2019-06-14
- 2.3.0 — 2019-06-14
- 2.2.0 — 2018-11-27
- 2.1.0 — 2018-11-12
- 2.0.0 — 2018-11-12
- 1.0.0 — 2018-11-10

## README

# console-files

Simple Node.js package to write application outputs to files.

It works as a default JavaScript
[`Console`](https://developer.mozilla.org/en-US/docs/Web/API/Console) object,
but with special handlers for `.log` and `.error` methods,
saving output to configured files.

It also treats application fatal errors
(`uncaughtException`), appending error message to file
before exiting process.

## Using

```bash
npm i --save console-files
```

```js
const logger = require('console-files')

/*
Do the stuff
*/

logger.log('Hello console-files!')

/*
More work to do
*/

logger.error(new Error('Keep calm, it is just a test ;)'))
```

## Configuration

It's configurable through the following
environment variables:

Environment variable  | Method   | Default
---                   | ---      | ---
`LOGGER_OUTPUT`       | `.log`   | `./logger.out`
`LOGGER_ERRORS`       | `.error` | `./logger.err`
`LOGGER_FATAL_ERRORS` | -        | `./_stderr`
`LOGGER_SKIP_FATAL`   | -        | -

## Development and production

`console-files` checks the `NODE_ENV`
to work differently for production and development modes:

```js
const devMode = process.env.NODE_ENV !== 'production'
```

- On dev mode it'll output to default console,
unless the `LOGGER_OUTPUT` or `LOGGER_FATAL_ERRORS`
env variable is explicitly set;

- On production mode it'll output only to files;

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