# winston-rotating-file

> Transport for winston based on rotating-file-stream

Latest version **0.2.0** (published 2020-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install winston-rotating-file
pnpm add winston-rotating-file
yarn add winston-rotating-file
bun add winston-rotating-file
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-06-18 |
| First published | 2020-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniele Ricci |
| Maintainers | cicci |
| Keywords | log, rotate, logrotate, winston |

## Links

- npm: https://www.npmjs.com/package/winston-rotating-file
- Repository: https://github.com/iccicci/winston-rotating-file
- Homepage: https://github.com/iccicci/winston-rotating-file#readme
- Issues: https://github.com/iccicci/winston-rotating-file/issues
- npm.io page: https://npm.io/package/winston-rotating-file

## Dependencies (3)

- [triple-beam](https://npm.io/package/triple-beam.md) 1.3.0
- [winston-transport](https://npm.io/package/winston-transport.md) 4.3.0
- [rotating-file-stream](https://npm.io/package/rotating-file-stream.md) 2.x

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

- 0.2.0 (latest) — 2020-06-18
- 0.1.0 — 2020-06-04

## README

# winston-rotating-file

[![Build Status][travis-badge]][travis-url]
[![Code Climate][code-badge]][code-url]
[![Test Coverage][cover-badge]][code-url]
[![Donate][donate-badge]][donate-url]

[![NPM version][npm-badge]][npm-url]
[![Types][types-badge]][npm-url]
[![NPM downloads][npm-downloads-badge]][npm-url]

[![Dependencies][dep-badge]][dep-url]
[![Dev Dependencies][dev-dep-badge]][dev-dep-url]
[![Dependents][deps-badge]][npm-url]

[code-badge]: https://codeclimate.com/github/iccicci/winston-rotating-file/badges/gpa.svg
[code-url]: https://codeclimate.com/github/iccicci/winston-rotating-file
[cover-badge]: https://codeclimate.com/github/iccicci/winston-rotating-file/badges/coverage.svg
[dep-badge]: https://david-dm.org/iccicci/winston-rotating-file.svg
[dep-url]: https://david-dm.org/iccicci/winston-rotating-file
[deps-badge]: https://badgen.net/npm/dependents/winston-rotating-file?icon=npm
[dev-dep-badge]: https://david-dm.org/iccicci/winston-rotating-file/dev-status.svg
[dev-dep-url]: https://david-dm.org/iccicci/winston-rotating-file?type=dev
[donate-badge]: https://badgen.net/badge/donate/bitcoin?icon=bitcoin
[donate-url]: https://blockchain.info/address/12p1p5q7sK75tPyuesZmssiMYr4TKzpSCN
[npm-downloads-badge]: https://badgen.net/npm/dw/winston-rotating-file?icon=npm
[npm-badge]: https://badgen.net/npm/v/winston-rotating-file?color=green&icon=npm
[npm-url]: https://www.npmjs.com/package/winston-rotating-file
[travis-badge]: https://badgen.net/travis/iccicci/winston-rotating-file?icon=travis
[travis-url]: https://travis-ci.org/iccicci/winston-rotating-file?branch=master
[types-badge]: https://badgen.net/npm/types/winston-rotating-file?color=green&icon=typescript

### Description

Transport for winston based on [rotating-file-stream](https://www.npmjs.com/package/rotating-file-stream).

### Usage

```javascript
const { WinstonRotatingFile } = require("winston-rotating-file");
const winston = require("winston");

const logger = winston.createLogger({
  format: winston.format.combine(
    winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
    winston.format.printf(info => `${info.timestamp} ${info.message}\n`)
  ),
  transports: [
    new WinstonRotatingFile({
      filename: "file.log",
      rfsOptions: {
        size: "10M", // rotate every 10 MegaBytes written
        interval: "1d", // rotate daily
        compress: "gzip" // compress rotated files
      }
    })
  ]
});
```

or (if access to [rotating-file-stream](https://www.npmjs.com/package/rotating-file-stream) events is required)

```javascript
const { WinstonRotatingFile } = require("winston-rotating-file");
const winston = require("winston");

const transport = new WinstonRotatingFile({
  filename: "file.log",
  rfsOptions: {
    size: "10M", // rotate every 10 MegaBytes written
    interval: "1d", // rotate daily
    compress: "gzip" // compress rotated files
  }
});

transport.stream.on("rotated", filename => {});

const logger = winston.createLogger({
  format: winston.format.combine(
    winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
    winston.format.printf(info => `${info.timestamp} ${info.message}\n`)
  ),
  transports: [transport]
});
```

### Installation

With [npm](https://www.npmjs.com/package/winston-rotating-file):

```sh
$ npm install --save winston-rotating-file
```

# API

```javascript
const { WinstonRotatingFile } = require("winston-rotating-file");
```

## new WinstonRotatingFile(options)

Creates the _Transport_ for **winston**. Accepts all options for
[winston-transport](https://www.npmjs.com/package/winston-transport) (please refer to
[winston](https://www.npmjs.com/package/winston) for details) plus following specific options:

- `filename` (required)
- `rfsOptions`

both of them passed to
[`rfs.createStream`](https://www.npmjs.com/package/rotating-file-stream#rfscreatestreamfilename-options), please refer
to [rotating-file-stream](https://www.npmjs.com/package/rotating-file-stream) for detailed options description.

# TypeScript

Check [`index.d.ts`](https://github.com/iccicci/winston-rotating-file/blob/master/index.d.ts) for what is exported in
**TypeScript**.

# Compatibility

Requires **Node.js v10.x**.

The package is tested under [all Node.js versions](https://travis-ci.org/iccicci/winston-rotating-file)
currently supported accordingly to [Node.js Release](https://github.com/nodejs/Release#readme).

# Licence

[MIT Licence](https://github.com/iccicci/winston-rotating-file/blob/master/LICENSE)

# Bugs

Do not hesitate to report any bug or inconsistency [@github](https://github.com/iccicci/winston-rotating-file/issues).

# Donating

If you find useful this package, please consider the opportunity to donate some satoshis to this bitcoin address:
**12p1p5q7sK75tPyuesZmssiMYr4TKzpSCN**

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