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

always-tail

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

always-tail

continuous file tail. robust enough to survive rollovers.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27K
decreased by-12.47%
Maintainers
1
Weekly downloads
 
Created
Source

always-tail

Node.js module for continuously tailing a file.

It differs from other tail modules in that it survives truncates, file rollovers (e.g. mv /var/log/test /var/log/test.1), and unlink.

It does this by monitoring the filename, and when the inode changes, it will continue to read to the end of the existing file descriptor, then automatically read from the newly created file with the same name.

It emits a 'line' event when a new line is read.

Installation

npm install always-tail

Example

var Tail = require('always-tail');
var fs = require('fs');
var filename = "/tmp/testlog";

if (!fs.existsSync(filename)) fs.writeFileSync(filename, "");

var tail = new Tail(filename, '\n');

tail.on('line', function(data) {
  console.log("got line:", data);
});


tail.on('error', function(data) {
  console.log("error:", data);
});

tail.watch();

// to unwatch and close all file descriptors, tail.unwatch();

Usage

var tail = new Tail(filename, separator, options); 

filename - filename to monitor

separator - optional separator for each line (default: \n)

options.interval - optional interval to check for changes

options.start - optional start byte to start reading from

options.blockSize - maximum reading block size (default is 1 MB)

Credits

Code is heavily modified from the node-tail module (https://github.com/forward/node-tail)

License

MIT

Keywords

FAQs

Package last updated on 27 Sep 2015

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