Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/serayaeryn/fast-file-rotate
A performant file transport providing daily log rotation for winston.
https://github.com/serayaeryn/fast-file-rotate
Last synced: 20 days ago
JSON representation
A performant file transport providing daily log rotation for winston.
- Host: GitHub
- URL: https://github.com/serayaeryn/fast-file-rotate
- Owner: SerayaEryn
- License: mit
- Created: 2018-07-31T17:11:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-07T04:01:16.000Z (almost 2 years ago)
- Last Synced: 2024-11-06T10:53:36.768Z (about 2 months ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fast-file-rotate
![Build Status](https://github.com/SerayaEryn/fast-file-rotate/workflows/ci/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/SerayaEryn/fast-file-rotate/badge.svg?branch=master)](https://coveralls.io/github/SerayaEryn/fast-file-rotate?branch=master)
[![NPM version](https://img.shields.io/npm/v/fast-file-rotate.svg?style=flat)](https://www.npmjs.com/package/fast-file-rotate)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)A performant file transport providing daily log rotation for winston.
## Install
```bash
npm install fast-file-rotate
```## Example
```js
const FileRotateTransport = require('fast-file-rotate');
const winston = require('winston');const logger = winston.createLogger({
transports: [
new FileRotateTransport({
fileName: __dirname + '/console%DATE%.log',
dateFormat: 'DDMMYYYY'
})
]
})
```## API
### FileRotateTransport(options)
#### fileName
The name of the log file(s). Must contain a `%DATE%` placeholder.
#### dateFormat (optional)
The format of the date that will replace the placeholder `%DATE%` in the file name. Defaults to `DDMMYYYY`.
Supports all formating options of [fast-date-format](https://github.com/SerayaEryn/fast-date-format).#### bufferSize (optional)
The size of the internal buffer that is used to store the logs before writing them to the file. Defaults to `4096`.
## Benchmark
The benchmark compares to the [winston-daily-rotate-file](https://github.com/winstonjs/winston-daily-rotate-file) module:
```
benchFastFileRotate*10000: 175.397ms
benchWinstonDailyRotateFile*10000: 580.341ms
benchFastFileRotate*10000: 141.746ms
benchWinstonDailyRotateFile*10000: 545.736ms
```## License
[MIT](./LICENSE)