New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bunyan-merge-files

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunyan-merge-files - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

21

lib/mix_logs.js
var crypto = require('crypto'),
fs = require('fs'),
util = require('util');
fs = require('fs'),
util = require('util'),
events = require("events");

@@ -47,9 +48,19 @@ function* logMixer(logs_to_mix) {

module.exports = function mixLogs(log_files) {
function Mixer(log_files) {
this.log_files = log_files;
}
util.inherits(Mixer, events.EventEmitter);
Mixer.prototype.mix = function() {
var mixed_logs = [];
for( var log_line of logMixer( log_files ) ) {
mixed_logs.push( log_line )
for( var log_line of logMixer( this.log_files ) ) {
this.emit('line', log_line);
mixed_logs.push( log_line );
}
return mixed_logs;
}
module.exports = {
Mixer: Mixer
};
{
"name": "bunyan-merge-files",
"version": "0.0.1",
"version": "0.0.2",
"description": "merge bunyan log files using Generators",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,6 +15,9 @@ # bunyan-merge-files

```javascript
var mergeLogs = require('bunyan-merge-files');
var Mixer = require('bunyan-merge-files');
var mixer = new Mixer(["file1", "file2"]);
mixer.on('line', function lineEventHandler(evt) {
console.log(evt.message);
});
var mergedLogs = mixer.mix();
var mergedLogs = mergeLogs([ "file1", "file2" ]);
console.log(mergedLogs);

@@ -27,6 +30,11 @@ ```

`mergeLogs(arrayOfFilenames)` - merges specified logs files
`Mixer(arrayOfFilenames)` - constructor for Mixer object
`Mixer#mix()` - merges files, returns results as array
## Events
`line` - emitted when a line has been merged
- - -
NOTE: Add some possible note

@@ -8,2 +8,5 @@ var should = require('should'),

var NUMBER_OF_ENTRIES = 10,
NUMBER_OF_LOGFILES = 100;
function verifyMerge(lines) {

@@ -16,7 +19,14 @@ var lastTime = lines[lines.length-1].time;

describe("mix_logs", function suite() {
var NUMBER_OF_ENTRIES = 10,
NUMBER_OF_LOGFILES = 100,
logs = [];
function mergeFiles(filesArray) {
var Mixer = require('../lib/mix_logs').Mixer,
mixer = new Mixer(filesArray), mixedLogs;
mixedLogs = mixer.mix();
mixedLogs.should.be.an.instanceOf(Array);
mixedLogs.length.should.equal(NUMBER_OF_ENTRIES*filesArray.length);
verifyMerge( mixedLogs );
}
describe("Mixer", function suite() {
var logs = [];
this.timeout(10000);

@@ -59,47 +69,51 @@

it("should throw an error if constructed with a string", function doTest(done) {
var mixLogs=require('../lib/mix_logs');
(function() {
mixLogs("./data/test.log");
}).should.throw();
done();
describe("#mix", function() {
it("should throw an error if constructed with a string", function doTest(done) {
var Mixer = require('../lib/mix_logs').Mixer,
mixer = new Mixer("./data/test.log");
(function() {
mixer.mix();
}).should.throw();
done();
});
it("should throw an error if constructed without an argument", function doTest(done) {
var Mixer = require('../lib/mix_logs').Mixer,
mixer = new Mixer();
(function() {
mixer.mix();
}).should.throw();
done();
});
it("should return an array of the merged files - 1 file", function doTest(done) {
mergeFiles(logs.slice(0,1));
done();
});
it("should return an array of the merged files - 10 files", function doTest(done) {
mergeFiles(logs.slice(0,10));
done();
});
it("should return an array of the merged files - 100 files", function doTest(done) {
mergeFiles(logs.slice(0,100));
done();
});
it("should emit a line event each time a line is merged", function doTest(done) {
var Mixer = require('../lib/mix_logs').Mixer,
mixer = new Mixer(logs.slice(0,100)), mixedLogs,
lineEventCount = 0;
mixer.on('line', function eventHandler(evt) {
lineEventCount++;
});
mixedLogs = mixer.mix();
mixedLogs.should.be.an.instanceOf(Array);
mixedLogs.length.should.equal(NUMBER_OF_ENTRIES*100);
lineEventCount.should.equal(NUMBER_OF_ENTRIES*100);
verifyMerge( mixedLogs );
done();
});
});
it("should throw an error if constructed without an argument", function doTest(done) {
var mixLogs=require('../lib/mix_logs');
(function() {
mixLogs();
}).should.throw();
done();
});
it("should return an array of the merged files - 1 file", function doTest(done) {
var mixLogs=require('../lib/mix_logs'),
mixedLogs;
mixedLogs = mixLogs(logs.slice(0,1));
mixedLogs.should.be.an.instanceOf(Array);
mixedLogs.length.should.equal(NUMBER_OF_ENTRIES*1);
verifyMerge( mixedLogs );
done();
});
it("should return an array of the merged files - 10 files", function doTest(done) {
var mixLogs=require('../lib/mix_logs'),
mixedLogs;
mixedLogs = mixLogs(logs.slice(0,10));
mixedLogs.should.be.an.instanceOf(Array);
mixedLogs.length.should.equal(NUMBER_OF_ENTRIES*10);
verifyMerge( mixedLogs );
done();
});
it("should return an array of the merged files - 100 files", function doTest(done) {
var mixLogs=require('../lib/mix_logs'),
mixedLogs;
mixedLogs = mixLogs(logs.slice(0,100));
mixedLogs.should.be.an.instanceOf(Array);
mixedLogs.length.should.equal(NUMBER_OF_ENTRIES*100);
verifyMerge( mixedLogs );
done();
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc