# console2file

> Simple module to override console functions and log it your way

Latest version **1.1.7** (published 2018-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install console2file
pnpm add console2file
yarn add console2file
bun add console2file
```

## 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.1.7 |
| Published | 2018-11-08 |
| First published | 2018-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 29.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rudellandy |
| Maintainers | rudellandy |
| Keywords | log, file, log2file, log to file, console, console.log, console2file, console to file, timestamp, labels |

## Links

- npm: https://www.npmjs.com/package/console2file
- Repository: https://github.com/Rudellandy/console2file
- Homepage: https://github.com/Rudellandy/console2file#readme
- Issues: https://github.com/Rudellandy/console2file/issues
- npm.io page: https://npm.io/package/console2file

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) ^2.22.2

## 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.1.7 (latest) — 2018-11-08
- 1.1.5 — 2018-03-24
- 1.1.4 — 2018-03-17
- 1.1.3 — 2018-03-16
- 1.1.2 — 2018-03-16
- 1.1.1 — 2018-03-16
- 1.1.0 — 2018-03-16
- 1.0.0 — 2018-03-15

## README

## Console2File
### Node module that allows you to log your console into file (and much more)


![GitHub package version](https://img.shields.io/github/package-json/v/rudellandy/console2file.svg)
![bitHound](https://img.shields.io/bithound/dependencies/github/rudellandy/console2file.svg)
![bitHound](https://img.shields.io/bithound/devDependencies/github/rudellandy/console2file.svg)
![npm](https://img.shields.io/npm/dt/console2file.svg)
![npm](https://img.shields.io/npm/v/console2file.svg)
![license](https://img.shields.io/github/license/rudellandy/console2file.svg)


## Note
Default `console.log`, `console.error`, etc. are overridden by this module to stay with familiar functions (only when configuring with default functions names - without params or one as `{Options}`)

## Table of Contents
* [Installation](#installation)
* [Usage](#usage)
* [Parameters](#parameters)
* [License](#license)

## Installation
```bash
npm install --save console2file
```
or (preferred)
```bash
yarn add console2file
```

## Usage
```javascript
var c2f = require('console2file').default;
// or
import c2f from 'console2file';

c2f({
    fileOnly: false,
    labels: true
}); // Overrides default console loggers (and debug)

c2f('rage', {
    labels: true
}); // Creates new function with default options

console.info('Hurray!'); // logs '[INFO] Hurray!' to file ./stdout.log and console

console.rage('quit'); // logs '[RAGE] quit' only to file ./stdout.log
```
or
```javascript
var c2f = require('console2file');
// or
import {c2f} from 'console2file';

c2f.config({
    fileOnly: false,
    labels: true
}); // Overrides default console loggers (and debug)

c2f.config('rage', {
    labels: true
}); // Creates new function with default options

console.info('Hurray!'); // logs '[INFO] Hurray!' to file ./stdout.log and console

console.rage('quit'); // logs '[RAGE] quit' only to file ./stdout.log
```

## Parameters
Parameter   | Default value    | Type                  | Description
----------- | ---------------- | --------------------- | -----------
filePath    | `'./stdout.log'` | `string`              | File path to log your console (set empty string or not string to disable)
fileOnly    | `true`           | `boolean`             | Log only to file or both (file and console)
labels      | `false`          | `boolean`             | Display labels (i.e. `[LOG]`, `[ERROR]`, ...)
timestamp   | `false`          | `boolean` or `string` | Display timestamp (i.e. `[2018-3-16 00:42:29]`). Format is from [moment.js](https://momentjs.com/docs/#/parsing/string-format/)
interpreter | `util.inspect`   | `function`            | Interpretation of non string values (allows to log full objects not as `[Object object]` etc.)

## License
MIT

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