当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript winston.Logger类代码示例

本文整理汇总了TypeScript中winston.Logger的典型用法代码示例。如果您正苦于以下问题:TypeScript Logger类的具体用法?TypeScript Logger怎么用?TypeScript Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logger类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: log

    export function log(msg: any) {
        const infoLog = new (winston.Logger)({
            transports: [
                new (winston.transports.Console)({
                    colorize: true,
                    level: 'info'
                })
            ]
        });

        infoLog.info(msg);
    };
开发者ID:jgkim7,项目名称:blog,代码行数:12,代码来源:logger.ts

示例2: errorLog

    export function errorLog(msg: any) {
        const errorLog = new (winston.Logger)({
            transports: [
                new (winston.transports.Console)({
                    colorize: true,
                    level: 'error'
                })
            ]
        });

        errorLog.error(msg);
    }
开发者ID:jgkim7,项目名称:blog,代码行数:12,代码来源:logger.ts

示例3: new

const init = () => {

  let quipLevels = {
    levels: {
      error: 0,
      warn: 1,
      info: 2,
      verbose: 3,
      debug: 4,
      silly: 5
    },
    colors: {
      error: 'red',
      warn: 'yellow',
      info: 'green',
      verbose: 'blue',
      debug: 'purple',
      silly: 'pink'
    }
  };

  let quipTransports = [
    new (winston.transports.Console) ({ 
      colorize: true,
      level: (process.env.NODE_ENV == 'development') ? 'debug' : 'info',
      handleExceptions: true,
      json: false
    }),
    new (winston.transports.File) ({ 
      colorize: false,
      filename: 'log/quip.log', 
      handleExceptions: true,
      json: true,
      level: 'warn', 
      maxsize: 5242880,
      maxFiles: 5
    })
  ];

  logger = new (winston.Logger) ({ 
    levels: quipLevels.levels, 
    transports: quipTransports 
  });

  logger.debug("Initiated logging.");
};
开发者ID:thinkrise,项目名称:Quip,代码行数:46,代码来源:index.ts

示例4: setVerbosity

 setVerbosity (v: LoggerOptions["level"]) {
     this.logger.configure({
         level: v,
         transports: [new winston.transports.Console()],
         format: winston.format.combine(
             winston.format.colorize({ all: true }),
             logFmt
         )
     })
 }
开发者ID:0mkara,项目名称:remix,代码行数:10,代码来源:logger.ts

示例5: stopped

 server.close((e: any) => {
   if (e) {
     logger.error(e);
     process.exit(1);
   }
   logger.warn(`Server stopped (${signal}).`);
   process.exit();
 });
开发者ID:easygenerator,项目名称:lrs,代码行数:8,代码来源:app.ts

示例6: getAllOfRunNumber

/**
 * Functions for retrieving data from DB
 */

// get all items in the run number given a hash
// if following is true, get only future predictions from the timestamp
async function getAllOfRunNumber(hash, following) {
  // calculate a range of values. run numbers are per day,
  // so this gets us a list of all other predictions given the run number and a timestamp

  let unixTime = Number(hash.prdt) * 1000

  let min = new Date(unixTime)
  min.setHours(0, 0, 0)

  let max = new Date(unixTime) // have to set this again here to get us another object to operate on
  max.setHours(0, 0, 0)
  max.setDate(max.getDate() + 1)

  // only get the following predictions
  if (following) {
    min = new Date(unixTime)
  }

  var params = {
      TableName : 'cta-trains',
      KeyConditionExpression: 'rn = :rn and prdt BETWEEN :min AND :max',
      ExpressionAttributeValues: {
          ':min': min.getTime() / 1000,
          ':max': max.getTime() / 1000,
          ':rn': Number(hash.rn)
      }
  };

  try {
    let query = await dynamo.queryAsync(params)
    return query.Items
  } catch (error) {
    logger.warning(error)
  }
};
开发者ID:open-cta,项目名称:wss-api,代码行数:41,代码来源:app.ts

示例7:

process.on('exit', () => {
	logger.info('Hello stopping');

	if(server !== undefined) {
		server.close();
	}
});
开发者ID:LionsPhil,项目名称:typescript-service-container-template,代码行数:7,代码来源:server.ts

示例8: saveErrorLogFile

    export function saveErrorLogFile(err, req, res, next) {
        if(!fs.existsSync('logs')){
            fs.mkdirSync('logs');
        }
        if(!fs.existsSync('logs/error')){
            fs.mkdirSync('logs/error');
        }
        if(err.status >= 400) {
            let meta: any = {
                ip:  req.headers['x-forwarded-for'] || req.connection.remoteAddress,
                req: {},
                res: {}
            };

            meta.req.url = req.originalUrl || req.url;
            meta.req.method = req.method;
            meta.req.httpVersion = req.httpVersion;
            meta.req.query = req.query || '';
            meta.req.params = req.params || '';
            meta.req.body = req.body || '';
            meta.req['accept-language'] = req.headers['accept-language'];
            meta.req['accept-language'] = req.headers['user-agent'];
            meta.responseTime = res.responseTime;
            meta.res.statusCode = res.statusCode;
            meta.error = err;

            errorFileLog.log('error', '', meta);
        }

        next(err);
    }
开发者ID:jgkim7,项目名称:blog,代码行数:31,代码来源:logger.ts

示例9: info

export function info(args:Array) {
    var text = '';
    for (var i = 0; i < args.length; i++) {
        var obj = args[i];
        text += colors.magenta(obj);
    }
    logger2.info(text);
}
开发者ID:MirekSz,项目名称:expressik,代码行数:8,代码来源:lib.ts


注:本文中的winston.Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。