本文整理汇总了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);
}
示例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)
};
示例3: log
log (level: string | object, message?: any, ...logArguments: any[]): this {
this.adapter.log(level as string, message, ...logArguments);
return this;
}
示例4: log
export function log(level, str) {
return logger.log(level, str);
}
示例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.
*/