Socket
Socket
Sign inDemoInstall

winston-daily-rotate-file

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-daily-rotate-file - npm Package Compare versions

Comparing version 3.1.4 to 3.2.0

87

daily-rotate-file.js

@@ -153,2 +153,6 @@ 'use strict';

if (!this.options.json) {
throw new Error('query() may not be used without the json option being set to true');
}
if (!this.filename) {

@@ -160,3 +164,2 @@ throw new Error('query() may not be used when initializing with a stream');

var results = [];
var row = 0;
options = self.normalizeQuery(options);

@@ -201,6 +204,3 @@

for (var i = 0; i < l; i++) {
if (!options.start || row >= options.start) {
add(data[i]);
}
row++;
add(data[i]);
}

@@ -216,9 +216,30 @@

if (options.order === 'desc') {
results = results.reverse();
}
if (logFiles.length) {
processLogFile(logFiles.shift());
} else if (callback) {
results.sort(function (a, b) {
var d1 = new Date(a.timestamp).getTime();
var d2 = new Date(b.timestamp).getTime();
return d1 > d2 ? 1 : d1 < d2 ? -1 : 0;
});
if (options.order === 'desc') {
results = results.reverse();
}
var start = options.start || 0;
var limit = options.limit || results.length;
results = results.slice(start, start + limit);
if (options.fields) {
results = results.map(function (log) {
var obj = {};
options.fields.forEach(function (key) {
obj[key] = log[key];
});
return obj;
});
}
callback(null, results);

@@ -231,5 +252,12 @@ }

var log = JSON.parse(buff);
if (check(log)) {
push(log);
if (!log || typeof log !== 'object') {
return;
}
var time = new Date(log.timestamp);
if ((options.from && time < options.from) || (options.until && time > options.until)) {
return;
}
results.push(log);
} catch (e) {

@@ -241,40 +269,3 @@ if (!attempt) {

}
function check(log) {
if (!log || typeof log !== 'object') {
return;
}
var time = new Date(log.timestamp);
if ((options.from && time < options.from) || (options.until && time > options.until)) {
return;
}
return true;
}
function push(log) {
if (options.rows && results.length >= options.rows && options.order !== 'desc') {
if (stream.readable) {
stream.destroy();
}
return;
}
if (options.fields) {
var obj = {};
options.fields.forEach(function (key) {
obj[key] = log[key];
});
log = obj;
}
if (options.order === 'desc') {
if (results.length >= options.rows) {
results.shift();
}
}
results.push(log);
}
})(logFiles.shift());
};
{
"name": "winston-daily-rotate-file",
"version": "3.1.4",
"version": "3.2.0",
"description": "A transport for winston which logs to a rotating file each day.",

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

"chai": "3.5.0",
"eslint": "^4.10.0",
"eslint": "^4.19.1",
"eslint-config-xo": "^0.19.0",
"mocha": "2.4.5",
"mocha": "^5.1.1",
"moment": "^2.19.1",

@@ -40,0 +40,0 @@ "rimraf": "2.5.2"

@@ -201,2 +201,11 @@ /* eslint-disable max-nested-callbacks,no-unused-expressions,handle-callback-err */

it('should raise error when calling with json set to false', function () {
expect(function () {
var opts = Object.assign({}, options);
opts.json = false;
var transport = new DailyRotateFile(opts);
transport.query(null);
}).to.throw();
});
it('should return log entries that match the query', function (done) {

@@ -203,0 +212,0 @@ sendLogItem(this.transport, 'info', randomString(1056));

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