Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rotating-file-stream

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rotating-file-stream

Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.

  • 3.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
129K
decreased by-3.98%
Maintainers
2
Weekly downloads
 
Created

What is rotating-file-stream?

The rotating-file-stream npm package is used to create a stream that writes to a file and rotates the file based on a specified condition, such as file size or time interval. This is particularly useful for logging purposes where you want to manage log file sizes and avoid having a single, ever-growing log file.

What are rotating-file-stream's main functionalities?

Time-based rotation

This feature allows you to rotate the log file based on a time interval. In this example, the log file 'access.log' will be rotated daily and stored in the '/var/log' directory.

const rfs = require('rotating-file-stream');
const stream = rfs.createStream('access.log', {
  interval: '1d', // rotate daily
  path: '/var/log'
});

Size-based rotation

This feature allows you to rotate the log file based on its size. In this example, the log file 'access.log' will be rotated every time it reaches 10MB and stored in the '/var/log' directory.

const rfs = require('rotating-file-stream');
const stream = rfs.createStream('access.log', {
  size: '10M', // rotate every 10 MegaBytes written
  path: '/var/log'
});

Compression

This feature allows you to compress the rotated log files. In this example, the log file 'access.log' will be rotated daily and compressed using gzip, then stored in the '/var/log' directory.

const rfs = require('rotating-file-stream');
const stream = rfs.createStream('access.log', {
  interval: '1d', // rotate daily
  compress: 'gzip', // compress rotated files
  path: '/var/log'
});

Custom rotation

This feature allows you to specify a custom rotation policy. In this example, the log file 'access.log' will be rotated and up to 7 rotated files will be kept in the '/var/log' directory.

const rfs = require('rotating-file-stream');
const stream = rfs.createStream('access.log', {
  rotate: 7, // keep 7 rotated files
  path: '/var/log'
});

Other packages similar to rotating-file-stream

Keywords

FAQs

Package last updated on 08 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc