Socket
Book a DemoInstallSign in
Socket

tail-forever

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tail-forever

a node.js library to implement tail -F

latest
Source
npmnpm
Version
0.3.16
Version published
Maintainers
2
Created
Source

tailF

a node.js library to implement tail -F. The power than tail -F is: it can watch a not exist file, also can continue watch file after file was removed.

install

npm install tail-forever

Use

simple case

Tail = require('tail-forever');

tail = new Tail("fileToTail");
tail.on("line", function(line) {
  console.log(line);
});
tail.on("error", function(error) {
  console.log('ERROR: ', error);
});

save postion can continue watch next time

if you applicaiton down or have to restart, you want to continue watch file from last postion to avoid lost data during down time. you can do it like this:

// unwatch return opsition which has two attributes: inode and pos. inode is the file's inode and pos is position where watched. you can save it on persistent file or database.
position = tail.unwatch()

// watch file after application restart. 
new Tail('/file/path', {start: position.pos, inode: position.inode})

Keywords

tail

FAQs

Package last updated on 23 Apr 2019

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