Skip to content

This module is designed to follow a file which is being appended to by something like a syslog server. It will reopen the file if the file is truncated.

License

Notifications You must be signed in to change notification settings

wolfeidau/follow-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

follow-file

This module is designed to follow a file which is being appended to by something like a syslog server. It will reopen the file if the file is truncated and recover from file being removed and recreated.

Example

This module comes with a small command which will follow the file, this is used for demonstration and testing purposes.

follow-file -f /var/log/syslog

API

As illustrated in the following example program this module can be used as an endless stream. Note in this example I am using through to inject new lines for presentations sake.

ff(argv.file).stream.pipe(through(function write(data) {
     log('data', data)
     this.emit('data', data + '\n')
   },
   function end() { //optional
     log('end')
     this.emit('end')
   }))
   .pipe(process.stdout)

Copyright © 2013 Mark Wolfe

MIT License

About

This module is designed to follow a file which is being appended to by something like a syslog server. It will reopen the file if the file is truncated.

Resources

License

Stars

Watchers

Forks

Packages

No packages published