watchfolder-jet

2.1.59 • Public • Published

Usage (I hope...)

Tails all logs in a directory including those created when the program is running.

    const jet = require("watchfolder-jet").watch(
        "/var/log/my-logs/"
    ).filter(
        (file) => (file.action === 'add' || file.action === 'create') && file.isReadable
    ).map(
        (file) => tail(file).pipe(new scramjet.StringStream())
            .split("\n")
    ).reduceNow(
        (acc, file) => (acc.add(file)),
        new scramjet.MultiStream([])
    ).mux(
        // comparator for log lines (just for the example, there should be no need for this except for a couple first lines)
        (lineA, lineB) => new Date(lineA.split(" ").slice(0,2).join(" ")) - new Date(lineB.split(" ").slice(0,2).join(" "))
    ).pipe(
        process.stdout
    );

API

require("watchfolder-jet").watch(directory);

Watches a directrory for changes

require("watchfolder-jet").finished(directory, {/* options */ timeout: 10000});

Watches a directory for completed files only.

Stream objects

The streamed objects have the following structure:

    {
        action: "",    // The action that happened on the file, one of the following:
                       //     ["add", "create", "remove", "change"];
        filename: "",  // The changed filename (full path)
        stat: {},      // The up to date stat
        prevstat: {}   // The previous stat (only on "change")
    }

License and contributions

The module is released under the condition of the MIT license. Please see the attached LICENSE.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.1.591latest

Version History

VersionDownloads (Last 7 Days)Published
2.1.591
2.1.580
2.1.570
2.1.560
2.1.550
2.1.540
2.1.530
2.1.520
2.1.510
2.1.500
2.1.490
2.1.480
2.1.470
2.1.460
2.1.450
2.1.440
2.1.430
2.1.420
2.1.410
2.1.400
2.1.390
2.1.380
2.1.370
2.1.360
2.1.350
2.1.340
2.1.330
2.1.320
2.1.310
2.1.300
2.1.290
2.1.280
2.1.270
2.1.250
2.1.240
2.1.230
2.1.220
2.1.210
2.1.200
2.1.190
2.1.180
2.1.170
2.1.160
2.1.150
2.1.140
2.1.130
2.1.120
2.1.110
2.1.100
2.1.90
2.1.80
2.1.60
2.1.50
2.1.40
2.1.30
2.1.20
2.1.10
2.1.00
2.0.00
1.2.00
1.1.00
1.0.00

Package Sidebar

Install

npm i watchfolder-jet

Weekly Downloads

1

Version

2.1.59

License

MIT

Unpacked Size

15.3 kB

Total Files

14

Last publish

Collaborators

  • patu
  • scramjetorg
  • michalcz
  • stoq