Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @license MIT
* @author charlie@nodejitsu.com (Charlie Robbins)
* @author 0@39.yt (Yurij Mikhalevich)
* @author imen.ammar@satoripop.tn (Imen Ammar)
*/
const util = require('util');
const os = require('os');
const mongodb = require('mongodb');
const _ = require('lodash');
const { LEVEL } = require('triple-beam');
const Stream = require('stream').Stream;
const logTypes = require('../helpers/logTypes');
const helpers = require('./helpers');
let Transport = require('winston-transport');
Transport.prototype.normalizeQuery = function (options) { //
options = options || {};
// limit
options.rows = options.rows || options.limit || 10;
// starting row offset
options.start = options.start || 0;
// now
options.until = options.until || new Date();
if (typeof options.until !== 'object') {
options.until = new Date(options.until);
}
// now - 24
options.from = options.from || (options.until - (24 * 60 * 60 * 1000));
// now - 24
options.from = options.from || (options.until - (24 * 60 * 60 * 1000));
if (typeof options.from !== 'object') {
options.from = new Date(options.from);
}
// 'asc' or 'desc'
options.order = options.order || 'desc';
// which fields to select
options.fields = options.fields;
return options;
};
Transport.prototype.formatResults = function (results, options) {
return results;
};
/**
* Constructor for the MongoDB transport object.
* @constructor
* @param {Object} options
* @param {string=info} options.level Level of messages that this transport
* should log.
* @param {boolean=false} options.silent Boolean flag indicating whether to
* suppress output.
* @param {string|Object} options.db MongoDB connection uri or preconnected db
* object.
* @param {Object} options.options MongoDB connection parameters
* (optional, defaults to `{poolSize: 2, autoReconnect: true}`).
* @param {string=logs} options.collection The name of the collection you want