當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Logger.add方法代碼示例

本文整理匯總了TypeScript中winston.Logger.add方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Logger.add方法的具體用法?TypeScript Logger.add怎麽用?TypeScript Logger.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在winston.Logger的用法示例。


在下文中一共展示了Logger.add方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: moment

logger.unmute = () => {
  if (muted) {
    muted = false
    logger.add(winston.transports.Console, {
      level: 'trace',
      levels: customLevels.levels,
      handleExceptions: false,
      colorize: true,
      timestamp: function() {
        return moment().format();
      }
    })
  }
}
開發者ID:duniter,項目名稱:duniter,代碼行數:14,代碼來源:logger.ts

示例2: getLogger

export function getLogger (file: string): LoggerInstance {
  let filepath = join(__dirname, `../../log/${file}`)

  let logger = new Logger({
    exitOnError: false,
    transports: [
      new transports.Console({
        colorize: true,
        handleExceptions: true,
        json: false,
        level: 'error'
      })
    ]
  })

  // second logger for all logs on files daily rotated
  logger.add(require('winston-daily-rotate-file'), {
    colorize: false,
    filename: filepath,
    handleExceptions: true,
    json: false,
    level: 'silly',
    maxFiles: 10,
    maxsize: 100000000,
    prepend: true,
    prettyPrint: true,
    timestamp: function (): string { return (new Date()).toTimeString() }
  })

  // stream to pipe with morgan
  logger['morganStream'] = {
    write: (message): void => {
      logger.info(message)
    }
  }

  return logger
}
開發者ID:chipp972,項目名稱:stock_manager_api,代碼行數:38,代碼來源:logger.ts

示例3: require

            filename: logDir+'log.txt',
            colorize: false,
            timestamp: true,
            maxsize: 1024*1024*5 //5MB
      })
    ]
});

require('winston-mongodb').MongoDB;

import parameters = require('../../core/parameters');
var disabled = parameters.getParameter('logger-db-disable', false);
if (!disabled) {
    var conf =  parameters.getDBParameter('logger-db', 'mongodb://localhost/portallogs');
    logger.add(winston.transports.MongoDB, {
        db: conf
    });
}


// Uncomment this if you want to enable logzio logs!
// var logzioWinstonTransport = require('winston-logzio');
// var loggerOptions = {
//     token: 'Your-token-here'
// };
// logger.add(logzioWinstonTransport, loggerOptions);




/**
開發者ID:portalTS,項目名稱:portalTS,代碼行數:31,代碼來源:loggerAPI.ts

示例4: new

import * as express from 'express';
import * as expressWinston from 'express-winston';
import * as winston from 'winston';

import config from './Config';
import IAppLogger from './IAppLogger';

const logger = new (winston.Logger)({
  level: config.get('LOG_LEVEL')
});

if (config.get('NODE_ENV') !== 'test') {
  logger.add(winston.transports.Console);
}

export interface ILoggerMiddleware {
  logger: express.RequestHandler;
  errorLogger: express.ErrorRequestHandler;
}

const loggerSingleton: IAppLogger = logger;
const LoggerMiddleware: ILoggerMiddleware = {
  logger: expressWinston.logger({
    winstonInstance: logger
  }),
  errorLogger: expressWinston.errorLogger({
    winstonInstance: logger
  })
};

export default loggerSingleton;
開發者ID:vmlf01,項目名稱:ts-painters-node,代碼行數:31,代碼來源:Logger.ts

示例5: Copyright

*/

/* TypeScript headers */
/// <reference path="../typings/node/node.d.ts" />


var GPLv3Message =
"TPC.js  Copyright (C) 2014  Gurjeet Singh, http://gurjeet.singh.im"
+ "\n" + "This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you"
+ "\n" + "are welcome to redistribute it under terms of GNU General Public License version 3.";

var blessed = require('blessed');
var winston = require('winston');
var g_logger = new (winston.Logger)({ exitOnError: false })
g_logger.handleExceptions(new winston.transports.File({ filename: '/tmp/tpcc_exceptions.log' }))    /* XXX This doesn't seem to do anything when an exception occurs! */
g_logger.add(winston.transports.File, { filename: uvp_log_file });

g_logger.log('info', 'Beginning TPC-C run.');

/* Create a screen */
/*
 * XXX: For some inexplicable reason, if this variable is named 'screen', it
 * causes `tsc` to emit an error, and no amount of diagnosis resolved the error.
 *
 * TODO: Create a definition file for blessed and contribute it to
 * DefinitelyTyped repo.
 */
var mainScreen: any = blessed.screen();

/*
 * Create a box in top-left corner of the screen, sized just enough to hold a
開發者ID:llcoolchak,項目名稱:DBYardstick,代碼行數:31,代碼來源:tpcc.ts

示例6: function

import * as winston from 'winston';
import * as config from 'config';

export const logger = new winston.Logger();

const env = config.util.getEnv('NODE_ENV');

// Development Logger
if(env === 'development') {
  logger.add(winston.transports.Console, {
    type: 'verbose',
    colorize: true,
    prettyPrint: true,
    handleExceptions: true,
    humanReadableUnhandledException: true
  });
}

process.on('unhandledRejection', function (reason, p) {
  logger.warn('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
});
開發者ID:efueger,項目名稱:node-microservice-demo,代碼行數:21,代碼來源:logging.ts

示例7: void

import * as winston from 'winston';
import 'winston-fast-rabbitmq';

const logger = new winston.Logger();
const options: winston.WinstonFastRabbitMqTransportOptions = {
    appId: '',
    durable: false,
    exceptionsLevel: 'error',
    exchangeName: 'winston-log',
    exchangeType: 'topic',
    handleError: (err: any) => void(0),
    handleExceptions: true,
    host: 'localhost',
    humanReadableUnhandledException: true,
    level: 'debug',
    password: 'guest',
    port: 5672,
    protocol: 'amqp',
    raw: false,
    routingKey: 'log.*',
    silent: true,
    username: 'guest',
    virtualHost: '%2f',
};
logger.add(winston.transports.WinstonFastRabbitMq, options);
開發者ID:TBear79,項目名稱:winston-fast-rabbitmq,代碼行數:25,代碼來源:typings.example.ts


注:本文中的winston.Logger.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。