Juul / tail-stream

Like `tail -f` but a stream. Like fs.createReadStream but keeps reading as the file grows.
Other
33 stars 13 forks source link

fixes for onMove: stay & follow, more tests #7

Closed msimerson closed 7 years ago

msimerson commented 9 years ago
$ mocha

  tail-stream
    file is appended
      ✓ detects two appends (91ms)

  tail-stream all events
    - has all events

  tail-stream
    file is rotated
      ✓ detects rotation (44ms)
      ✓ detects rotation concurrently (45ms)
    onMove
      ✓ follow, emits append to new file after rotation (91ms)
      ✓ stay, emits append to old file after rotation (1147ms)

  tail-stream
    file is truncated
      ✓ truncation is detected (52ms)
      ✓ write after truncation is read 

  7 passing (1s)
  1 pending
Juul commented 9 years ago

Thanks for the patches!

I'll be happy to merge #4, #5 and #6 (once it's modified) but I'm not able to replicate the following bugs from your comments:

// On Mac OS X and Linux, watchFile doesn't report the (re)appearance of
// the file. Watch the enclosing dir and then compare the filename of events
// On Mac OS X & Linux (Docker), currently results in ENOENT error
// fs.watchFile(this.path, {persistent:true, inverval: 500}, this.watchFileCallback);
// this.watcher = true;

I have not tried on Mac OS X, but I'm running lubuntu 14.04 and watchFile does report the reappearance of the file and I don't get an ENOENT error. Could you give me code snippets and info on the exact OS versions you're using so I can replicate the errors?

msimerson commented 9 years ago

On Mac OS X and Linux, watchFile doesn't report

Mac OS 10.10.4 and 10.11 public beta 2.

Linux version: worker-linux-docker-b01f9959.prod.travis-ci.org:travis-linux-4

Build system information
Build language: node_js
Build image provisioning date and time
Thu Feb  5 15:09:33 UTC 2015
Operating System Details
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:    12.04
Codename:   precise
Linux Version
3.13.0-29-generic
Cookbooks Version
a68419e https://github.com/travis-ci/travis-cookbooks/tree/a68419e
GCC version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

It's testing against Node 0.10, 0.12, and iojs.

If you're happy with the other PRs, go ahead and merge them and I'll rebase this one against master.

Juul commented 9 years ago

I'll give a test on OS X when I get home.

megastef commented 7 years ago

Are there any plans to merge this and release on npm?

msimerson commented 7 years ago

Hey @megastef, I'd encourage you to check out safe-log-reader.

Juul commented 7 years ago

For some reason I completely missed this. My apologies to @msimerson and thanks for the suggestion on safe-log-reader.

Juul commented 7 years ago

@megastef merged and published on npm