/*1* winston.js: Top-level include defining Winston.2*3* (C) 2010 Charlie Robbins4* MIT LICENCE5*6*/78var winston = exports;910//11// Expose version using `pkginfo`12//13require('pkginfo')(module, 'version');1415//16// Include transports defined by default by winston17//18winston.transports = require('./winston/transports');1920//21// Expose utility methods22//23var common = require('./winston/common');24winston.hash = common.hash;25winston.clone = common.clone;26winston.longestElement = common.longestElement;27winston.exception = require('./winston/exception');28winston.config = require('./winston/config');29winston.addColors = winston.config.addColors;3031//32// Expose core Logging-related prototypes.33//34winston.Container = require('./winston/container').Container;35winston.Logger = require('./winston/logger').Logger;36winston.Transport = require('./winston/transports/transport').Transport;3738//39// We create and expose a default `Container` to `winston.loggers` so that the40// programmer may manage multiple `winston.Logger` instances without any additional overhead.41//42// ### some-file1.js43//44// var logger = require('winston').loggers.get('something');45//46// ### some-file2.js47//48// var logger = require('winston').loggers.get('something');49//50winston.loggers = new winston.Container();5152//53// We create and expose a 'defaultLogger' so that the programmer may do the54// following without the need to create an instance of winston.Logger directly:55//56// var winston = require('winston');57// winston.log('info', 'some message');58// winston.error('some error');59//60var defaultLogger = new winston.Logger({61transports: [new winston.transports.Console()]62});6364//65// Pass through the target methods onto `winston.66//67var methods = [68'log',69'query',70'stream',71'add',72'remove',73'profile',74'startTimer',75'extend',76'cli',77'handleExceptions',78'unhandleExceptions'79];80common.setLevels(winston, null, defaultLogger.levels);81methods.forEach(function (method) {82winston[method] = function () {83return defaultLogger[method].apply(defaultLogger, arguments);84};85});8687//88// ### function cli ()89// Configures the default winston logger to have the90// settings for command-line interfaces: no timestamp,91// colors enabled, padded output, and additional levels.92//93winston.cli = function () {94winston.padLevels = true;95common.setLevels(winston, defaultLogger.levels, winston.config.cli.levels);96defaultLogger.setLevels(winston.config.cli.levels);97winston.config.addColors(winston.config.cli.colors);9899if (defaultLogger.transports.console) {100defaultLogger.transports.console.colorize = true;101defaultLogger.transports.console.timestamp = false;102}103104return winston;105};106107//108// ### function setLevels (target)109// #### @target {Object} Target levels to use110// Sets the `target` levels specified on the default winston logger.111//112winston.setLevels = function (target) {113common.setLevels(winston, defaultLogger.levels, target);114defaultLogger.setLevels(target);115};116117//118// Define getters / setters for appropriate properties of the119// default logger which need to be exposed by winston.120//121['emitErrs', 'exitOnError', 'padLevels', 'level', 'levelLength', 'stripColors'].forEach(function (prop) {122Object.defineProperty(winston, prop, {123get: function () {124return defaultLogger[prop];125},126set: function (val) {127defaultLogger[prop] = val;128}129});130});131132//133// @default {Object}134// The default transports and exceptionHandlers for135// the default winston logger.136//137Object.defineProperty(winston, 'default', {138get: function () {139return {140transports: defaultLogger.transports,141exceptionHandlers: defaultLogger.exceptionHandlers142};143}144});145146147