# winston-pnp-logger

> A Plug & Play solution for Winston.

Latest version **1.0.5** (published 2018-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install winston-pnp-logger
pnpm add winston-pnp-logger
yarn add winston-pnp-logger
bun add winston-pnp-logger
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2018-08-10 |
| First published | 2017-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jeroen Akkerman |
| Maintainers | ionaru |

## Links

- npm: https://www.npmjs.com/package/winston-pnp-logger
- Repository: https://github.com/Ionaru/winston-pnp-logger
- Homepage: https://github.com/Ionaru/winston-pnp-logger#readme
- Issues: https://github.com/Ionaru/winston-pnp-logger/issues
- npm.io page: https://npm.io/package/winston-pnp-logger

## Dependencies (3)

- [mkdirp](https://npm.io/package/mkdirp.md) 0.5.1
- [winston](https://npm.io/package/winston.md) 2.4.0
- [winston-daily-rotate-file](https://npm.io/package/winston-daily-rotate-file.md) 1.7.2

## Recent versions

- 1.0.5 (latest) — 2018-08-10
- 1.0.8 (next) — 2019-01-04
- 1.0.7 — 2019-01-04
- 1.0.4 — 2017-11-27
- 1.0.3 — 2017-11-27
- 1.0.2 — 2017-11-21
- 1.0.1 — 2017-09-19
- 1.0.0 — 2017-08-04

## README

# Winston Plug & Play Logger

[![winston-pnp-logger](https://img.shields.io/npm/v/winston-pnp-logger.svg)](https://www.npmjs.com/package/winston-pnp-logger)

Mainly built for my own projects, this package provides an Plug & Play solution for the [Winston](https://www.npmjs.com/package/winston) multi-transport async logging library with multiple transports and logging to file.
There's only a very minimal configuration required to start using the logger.

## Installation

Download package with
```bash
npm install winston-pnp-logger --save
```

Add it to your project with JavaScript:
```js
var WinstonPnPLogger = require('winston-pnp-logger').WinstonPnPLogger;
var logger = new WinstonPnPLogger();
logger.info('Hello!');
```

Or if you're using ES6 / TypeScript:
```js
import { WinstonPnPLogger } from 'winston-pnp-logger';
const logger = new WinstonPnPLogger();
logger.info('Hello!');
```

Also add this when you're using Typescript:
```bash
npm install @types/winston --save-dev
```

## API

### WinstonPnPLogger(options)
The plugin class you instantiate to make it all work.

options, all values can be changed or left out entirely:
```js
var options = {
    // Directory to write log files to. Omit to disable file logging.
    logDir: './logs',

    // Enable or disable logging to JSON files, requires logDir option to be set.
    enableJson: true,

    // Include or exclude timestamps.
    showTimestamp: true,

    // Show milliseconds in timestamps.
    showMilliSeconds: false,

    // Print a line on instantiation.
    announceSelf: true
};
```

Example usage:
```js
var WinstonPnPLogger = require('winston-pnp-logger').WinstonPnPLogger;
var logger = new WinstonPnPLogger(options);
logger.info('Hello!');
```

### logger
An exported instance of WinstonPnPLogger that will be available after the initial creation of a WinstonPnPLogger instance.

Example usage:
```js
var logger = require('winston-pnp-logger').logger;
logger.info('Hello!');
```

### WinstonPnPLogger.error
Logger on the 'error' level.

Example usage:
```js
logger.error('Does not compute!');
```

### WinstonPnPLogger.warn
Logger on the 'warn' level.

Example usage:
```js
logger.warn('Here be dragons.');
```

### WinstonPnPLogger.info
Logger on the 'info' level.
With standard settings. On default settings, the console will log this an above levels.

Example usage:
```js
logger.info('Information: stowaway.');
```

### WinstonPnPLogger.debug
Logger on the 'debug' level (4).

Enable by setting the environment variable LEVEL to `'debug'` or `'silly'`.

Example usage:
```js
logger.debug('foo bar');
```

### WinstonPnPLogger.silly
Logger on the 'silly' level (5). This will not be logged to file.

Enable by setting the environment variable LEVEL to `'silly'`.

Example usage:
```js
logger.silly('This line is rather silly.');
```

### WinstonPnPLogger.winston
Access to the Winston logger API

Example usage:
```js
logger.winston.log('info', 'blog it');
```
```js
logger.winston.profile('test');
```

## Environment Variables
This package will respond to several environment variables, these have to be set **before** instantiating WinstonPnPLogger for them to have any effect.

### LEVEL
Sets the console output level, default is `'info'`.

### SILENT
Disables all console and file logging, but will still log errors to the console.

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