Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let Mail = exports.Mail = function(options) {
options = options || {}
Transport.call(this, options);
if (!options.to) {
throw new Error("super-logger(winston-email) requires 'to' property")
}
if (!options.transportOptions) {
throw new Error("super-logger(winston-email) requires 'transportOptions'")
}
this.to = options.to;
this.from = options.from || 'super-logger@' + os.hostname();
this.subject = options.subject || '';
this.html = options.html || false; // Send mail in html format
this.formatter = options.formatter || false;
this.level = options.level;
var Console = module.exports = function (options) {
options = options || {};
TransportStream.call(this, options);
this.stderrLevels = getStderrLevels(options.stderrLevels, options.debugStdout);
this.eol = os.EOL;
//
// Convert stderrLevels into an Object for faster key-lookup times than an Array.
//
// For backwards compatibility, stderrLevels defaults to ['error', 'debug']
// or ['error'] depending on whether options.debugStdout is true.
//
function getStderrLevels(levels, debugStdout) {
var defaultMsg = 'Cannot have non-string elements in stderrLevels Array';
if (debugStdout) {
if (levels) {
//
// Don't allow setting both debugStdout and stderrLevels together,
// since this could cause behaviour a programmer might not expect.
var DailyRotateFile = function (options) {
options = options || {};
Transport.call(this, options);
function throwIf(target /* , illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {
if (options[name]) {
throw new Error('Cannot set ' + name + ' and ' + target + ' together');
}
});
}
function getMaxSize(size) {
if (size && typeof size === 'string') {
var _s = size.toLowerCase().match(/^((?:0\.)?\d+)([k|m|g])$/);
if (_s) {
return size;
}
} else if (size && Number.isInteger(size)) {
let MongoDB = exports.MongoDB = function(options) {
Transport.call(this, options);
options = (options || {});
if (!options.db) {
throw new Error('You should provide db to log to.');
}
this.on('error', (err) => {
console.error('super-logger(winston-mongodb), error on logging in database: ', err);
});
this.name = options.name || 'mongodb';
this.db = options.db;
this.options = options.options;
if (!this.options) {
this.options = {
poolSize: 2,
autoReconnect: true,
};
}
let MongoDB = exports.MongoDB = function(options) {
Transport.call(this, options);
options = (options || {});
if (!options.db) {
throw new Error('You should provide db to log to.');
}
this.name = options.name || 'mongodb';
this.db = options.db;
this.options = options.options;
if (!this.options) {
this.options = {
poolSize: 2,
autoReconnect: true,
useNewUrlParser: true
};
}
this.collection = (options.collection || 'log');
this.level = (options.level || 'info');