https://github.com/thelicato/pino-rotating-file-stream
A transport for pino that rotates logs
https://github.com/thelicato/pino-rotating-file-stream
log-rotation logging pino pino-transport
Last synced: about 1 month ago
JSON representation
A transport for pino that rotates logs
- Host: GitHub
- URL: https://github.com/thelicato/pino-rotating-file-stream
- Owner: thelicato
- License: mit
- Created: 2023-05-17T08:05:49.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-17T10:16:11.000Z (almost 2 years ago)
- Last Synced: 2025-03-20T06:12:53.807Z (about 1 month ago)
- Topics: log-rotation, logging, pino, pino-transport
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/pino-rotating-file-stream
- Size: 31.3 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pino-rotating-file-stream
[](https://www.npmjs.com/package/pino-rotating-file-stream)
## Description
This module provides a **transport** for *pino* to automatically rotates logs. Under the hood, it uses [rotating-file-stream](https://www.npmjs.com/package/rotating-file-stream) even though some fields have been added to the default *Options*.
## CLI
The current version of this packages has only support for the module usage as described in the [Programmatic Integration](#programmatic-integration) section. This feature will be added in next versions of the package.
For now you can rely on [@vrbo/pino-rotating-file](https://www.npmjs.com/package/@vrbo/pino-rotating-file) for CLI integration.
## Programmatic Integration
Install ``pino-rotating-file-stream`` alongside ``pino`` and set the transport to ``pino-rotating-file-stream``:```js
const pino = require('pino')
const logger = pino({
transport: {
target: 'pino-rotating-file-stream',
options: {
filename: 'app.log', // Required
path: './logs', // Required
},
},
})logger.info('hi')
```See also the example in the ``examples`` folder.
### Options
The options are essentially the same provided by ``rotating-file-stream`` except form two new entries. The following list shows all the options with the default values:
```js
{
filename: string; // Specifies the name of the file. Required.
path: string // Specifies the base path for files. Required.
size: string // Specifies the file size to rotate the file. Default: '100M'.
maxSize: string // Specifies the maximum size of rotated files to keep. Default: '1G'.
interval: string // Specifies the time interval to rotate the file. Default: '7d'.
compress: boolean | string | Function // Specifies compression method of rotated files. Default: 'gzip'.
encoding: string // Specifies the default encoding. Default: 'utf8'.
history: string // Specifies the history filename. Default: null.
immutable: boolean // Never mutate file names. Default: null.
initialRotation: boolean // Initial rotation based on not-rotated file timestamp. Default: null.
intervalBoundary: boolean // Makes rotated file name with lower boundary of rotation period. Default: null.
maxFiles: number // Specifies the maximum number of rotated files to keep. Default: null.
mode: number // Proxied to fs.createWriteStream. Default: 0o666.
omitExtension: // boolean Omits the .gz extension from compressed rotated files. Default: null.
rotate: number // Enables the classical UNIX logrotate behaviour. Default: null.
teeToStdout: boolean // Writes file content to stdout as well. Default: null.
}
```## License
[MIT](./LICENSE) License © 2023 [Angelo Delicato](https://github.com/thelicato)