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

file-stream-rotator

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-stream-rotator

Automated stream rotation useful for log files

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
647K
decreased by-13.32%
Maintainers
1
Weekly downloads
 
Created

What is file-stream-rotator?

The file-stream-rotator npm package is used for rotating log files based on a specified time interval or file size. It is commonly used in logging systems to manage log file sizes and ensure that logs are archived and rotated properly.

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

Time-based rotation

This feature allows you to rotate log files based on a specified time interval, such as daily. The log files will be named with the current date.

const FileStreamRotator = require('file-stream-rotator');
const fs = require('fs');

const logStream = FileStreamRotator.getStream({
  filename: 'logs/logfile-%DATE%.log',
  frequency: 'daily',
  verbose: false,
  date_format: 'YYYYMMDD'
});

logStream.write('This is a log message.\n');

Size-based rotation

This feature allows you to rotate log files based on a specified file size. Once the log file reaches the specified size, it will be rotated, and a new log file will be created.

const FileStreamRotator = require('file-stream-rotator');
const fs = require('fs');

const logStream = FileStreamRotator.getStream({
  filename: 'logs/logfile-%DATE%.log',
  size: '10M',
  max_logs: '10',
  audit_file: 'logs/audit.json'
});

logStream.write('This is a log message.\n');

Custom rotation

This feature allows you to define custom rotation strategies, combining both time and size-based rotation. You can specify the frequency, size, and other parameters to control the rotation behavior.

const FileStreamRotator = require('file-stream-rotator');
const fs = require('fs');

const logStream = FileStreamRotator.getStream({
  filename: 'logs/logfile-%DATE%.log',
  frequency: 'custom',
  verbose: false,
  date_format: 'YYYYMMDD',
  size: '5M',
  max_logs: '5',
  audit_file: 'logs/audit.json',
  end_stream: true
});

logStream.write('This is a log message.\n');

Other packages similar to file-stream-rotator

Keywords

FAQs

Package last updated on 13 Nov 2022

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