How to use the winston-transport.prototype function in winston-transport

To help you get started, we’ve selected a few winston-transport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github satoripop / thesuperlogger / src / transports / winston-mongodb.js View on Github external
* @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));
github satoripop / thesuperlogger / src / transports / winston-mongodb.js View on Github external
// 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

winston-transport

Base stream implementations for winston@3 and up.

MIT
Latest version published 17 days ago

Package Health Score

89 / 100
Full package analysis