Comparing version 1.0.1 to 1.1.0
@@ -9,3 +9,3 @@ { | ||
"description": "tail a file in node", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"homepage": "http://www.lucagrulla.com/node-tail", | ||
@@ -12,0 +12,0 @@ "repository": { |
@@ -5,3 +5,3 @@ #tail | ||
To install: | ||
# Installation | ||
@@ -12,3 +12,3 @@ ```bash | ||
#Use: | ||
# Use: | ||
```javascript | ||
@@ -26,25 +26,43 @@ Tail = require('tail').Tail; | ||
}); | ||
```` | ||
The only mandatory parameter is the path to the file to tail. You can pass optional parameters passed via a hash: | ||
``` | ||
If you want to stop tail: | ||
```javascript | ||
tail.unwatch() | ||
``` | ||
To start watching again: | ||
```javascript | ||
tail.watch() | ||
``` | ||
# Configuration | ||
The only mandatory parameter is the path to the file to tail. | ||
```javascript | ||
var fileToTail = "/path/to/fileToTail.txt"; | ||
new Tail(fileToTail) | ||
``` | ||
or | ||
Optional parameters can be passed via a hash: | ||
```javascript | ||
var options= {lineSeparator= /[\r]{0,1}\n/, fromBeginning = false, watchOptions = {}, follow = true} //default value, equivalent to not passing | ||
var options= {lineSeparator: /[\r]{0,1}\n/, fromBeginning: false, watchOptions: {}, follow: true, logger: console} | ||
new Tail(fileToTail, options) | ||
``` | ||
* `fileToTail` is the name (inclusive of the path) of the file to tail | ||
* `options` is a hash. The following keys are accepted: | ||
* `lineSeparator`: the line separator token (default `/[\r]{0,1}\n/` to handle linux/mac (9+)/windows) | ||
* `watchOptions`: the full set of options that can be passed to `fs.watch` as per node documentation (default: {}) | ||
* `fromBeginning`: forces the tail of the file from the very beginning of it instead of from the first new line that will be appended (default: `false`) | ||
* `follow`: simulate `tail -F` option. In the case the file is moved/renamed (or logrotated) if set to `true` `tail` will try to start tailing again after a 1 second delay, if set to `false` it will just emit an error event (default: `true`) | ||
# Available parameters: | ||
Tail emits two type of events: | ||
* `lineSeparator`: the line separator token (default `/[\r]{0,1}\n/` to handle linux/mac (9+)/windows) | ||
* `watchOptions`: the full set of options that can be passed to `fs.watch` as per node documentation (default: {}) | ||
* `fromBeginning`: forces the tail of the file from the very beginning of it instead of from the first new line that will be appended (default: `false`) | ||
* `follow`: simulate `tail -F` option. In the case the file is moved/renamed (or logrotated), if set to `true` `tail` will try to start tailing again after a 1 second delay, if set to `false` it will just emit an error event (default: `true`) | ||
* `logger`: a logger object(default: no logger). The passed logger has to respond to two methods: | ||
* `info([data][, ...])` | ||
* `error([data][, ...])` | ||
# Emitted events | ||
`Tail` emits two events: | ||
* line | ||
@@ -61,15 +79,4 @@ ``` | ||
If you want to stop the tail: | ||
# Want to fork? | ||
```javascript | ||
tail.unwatch() | ||
``` | ||
To start watching again: | ||
```javascript | ||
tail.watch() | ||
``` | ||
#Want to fork ? | ||
Tail is written in [CoffeeScript](http://jashkenas.github.com/coffee-script/). | ||
@@ -80,2 +87,2 @@ | ||
#License | ||
MIT. Please see License file for more details. | ||
MIT. Please see License file for more details. |
9728
83