# always-tail

> continuous file tail. robust enough to survive rollovers.

Latest version **0.2.0** (published 2015-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install always-tail
pnpm add always-tail
yarn add always-tail
bun add always-tail
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-09-27 |
| First published | 2013-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 57 |
| Author | Jen Andre |
| Maintainers | jandre |
| Keywords | tail |

## Links

- npm: https://www.npmjs.com/package/always-tail
- Repository: http://github.com/jandre/always-tail
- Homepage: https://github.com/jandre/always-tail
- Issues: https://github.com/jandre/always-tail/issues
- npm.io page: https://npm.io/package/always-tail

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ~0.7.2

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads
- [@modern-js/plugin-swc](https://npm.io/package/@modern-js/plugin-swc.md) — 3.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2015-09-27
- 0.1.1 — 2014-03-13
- 0.1.0 — 2013-07-26

## README

# 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

```js
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 

```js
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

---
_Source: https://npm.io/package/always-tail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
