當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。