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


TypeScript Logger.log方法代码示例

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


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

示例1: 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

示例2:

        res.end = (chunk, encoding) => {
            res.end = end;
            res.end(chunk, encoding);

            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;
            if (chunk) {
                var isJson = (res._headers && res._headers['content-type']
                && res._headers['content-type'].indexOf('json') >= 0);
                meta.res.body =  isJson ? JSON.parse(chunk) : chunk.toString();
            }
            meta.res.statusCode = res.statusCode;

            infoFileLog.log('info', '', meta)
        };
开发者ID:jgkim7,项目名称:blog,代码行数:22,代码来源:logger.ts

示例3: log

  log (level: string | object, message?: any, ...logArguments: any[]): this {
    this.adapter.log(level as string, message, ...logArguments);

    return this;
  }
开发者ID:RWOverdijk,项目名称:stix,代码行数:5,代码来源:LoggerService.ts

示例4: log

export function log(level, str) {
    return logger.log(level, str);
}
开发者ID:portalTS,项目名称:portalTS,代码行数:3,代码来源:loggerAPI.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
 * TPC-C terminal's contents.
 */
开发者ID:llcoolchak,项目名称:DBYardstick,代码行数:31,代码来源:tpcc.ts


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