本文整理汇总了TypeScript中winston.add函数的典型用法代码示例。如果您正苦于以下问题:TypeScript add函数的具体用法?TypeScript add怎么用?TypeScript add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(type:string, params?: { name:string, test?: boolean, external?:boolean, network?:{ discover: any, ports: any, network:any }}){
this.type = type;
this.id = params.name;
if (params !== undefined && params.test !== undefined) this.test = params.test
else this.test = false
if (params !== undefined && params.external !== undefined) this.external = params.external
else this.external = false
if (!this.test) {
try {
winston.add(winston.transports.File, { filename: `./logs/${type}-${this.id}.log` , level:'info'});
/*winston.add(require('winston-graylog2'), {
name: 'Graylog',
level: 'warning',
silent: false,
handleExceptions: false,
graylog: {
servers: [{host: '127.0.0.1', port: 12201}],
hostname: this.id,
facility: "leader",
bufferSize: 1400
}
});*/
} catch (e){ }
if (params !== undefined && params.network !== undefined)
winston.info(type +" %s started in port %s ",this.id, params.network.ports.port);
}
if (params !== undefined && !this.test && params.network !== undefined) this.startNetwork(params.network);
}
开发者ID:Villaz,项目名称:Icarus,代码行数:31,代码来源:rol.ts
示例2: InitializeLogger
public static InitializeLogger() : void {
//initialize the winston logger with daily log rotates
let env : string = process.env.NODE_ENV || "development";
env = env.trim();
let logFilePath : string = path.join(__dirname, "../../logs");
//create the log file directory is it does not exist
if(!fs.existsSync(logFilePath)) {
fs.mkdirSync(logFilePath);
}
if(env == "development") {
Winston.add(winstonRotateFile, {
filename: path.join(logFilePath, "_info.log"),
datePattern: "yyyy-MM-dd",
prepend: true,
prettyPrint: true,
level: "info"
});
}
else {
Winston.add(winstonRotateFile, {
filename: path.join(logFilePath, "_error.log"),
datePattern: "yyyy-MM-dd",
prepend: true,
prettyPrint: true,
level: "warn"
});
//remove console output in production
Winston.remove(Winston.transports.Console);
}
Winston.handleExceptions(new winstonRotateFile({
filename: path.join(logFilePath, "_exceptions.log"),
datePattern: "yyyy-MM-dd",
prepend: true,
prettyPrint: true
}));
}
开发者ID:andwoo,项目名称:grouptube2,代码行数:39,代码来源:Logger.ts
示例3:
import * as winston from 'winston';
// set up the logger with a transport
const _logger = winston.add(new winston.transports.Console({
format: (winston as any).format.simple(),
}));
export const logger = _logger;
开发者ID:jmptr,项目名称:lost-sloth,代码行数:8,代码来源:logger.ts
示例4: express
const app = express();
const ROOT = path.join(path.resolve(''));
/*
* Configure Winston
*/
winston.addColors({
debug: 'green',
info: 'cyan',
silly: 'magenta',
warn: 'yellow',
error: 'red'
});
winston.remove(winston.transports.Console);
winston.add(winston.transports.Console, {
level: process.env.LOG_LEVEL,
colorize: true
});
/*
* Connect to database
* Info: See database.ts to configure settings
*/
import { ConnectToDatabase } from './database';
ConnectToDatabase();
/*
* Configure Express.js rendering engine
*/
开发者ID:Mandosis,项目名称:2MEAN,代码行数:32,代码来源:server.ts
示例5: parseFloat
var narrative : string = values[3];
var amount : number = parseFloat(values[4]);
if (isNaN(amount)) {
var errorMsg = "while parsing: '" + values[4] + "' is not a number. Line is ignored";
winston.log("error", errorMsg);
return null; // skip line
}
return new Transaction(date, origin, to, narrative, amount);
}
var transactionDict : Transaction[] = new Array();
var personDict = {};
winston.level = "debug"
winston.add(winston.transports.File, { filename: 'logFiles/log.txt' });
//winston.remove(winston.transports.Console);
loadCSV("res/DodgyTransactions2015.csv");
var stdin = process.stdin;
stdin.addListener("data", function(data) {
var answer = data.toString().trim();
if (answer === "listAll") listAll()
else if (answer.startsWith("listTransactions")) {
var args = answer.split(" ");
listTransactions(args[1] + " " + args[2]);
} else if (answer === "q" || answer === "quit") {
throw new Error("");
开发者ID:SimonGGit,项目名称:Softbank,代码行数:31,代码来源:ReadingCSV.ts
示例6: Promise
import fs from 'fs';
import http from 'http';
import path from 'path';
import util from 'util';
import winston from 'winston';
import writeFileAtomic from 'write-file-atomic';
import app from '../src/app';
import GitHub from '../src/github';
winston.remove(winston.transports.Console);
winston.add(winston.transports.Console, { timestamp: true });
const gh = new GitHub(process.env.GITHUB_TOKEN as string);
app.set('port', process.env.PORT || 3000);
const mkdir = util.promisify(fs.mkdir);
const dirExists = util.promisify(fs.exists);
const atomic = (file: string, data: any) => {
return new Promise((res, rej) => {
writeFileAtomic(file, JSON.stringify(data), err => (err ? rej(err) : res()));
});
};
async function updateShowcases() {
const dbPath = path.join(__dirname, '..', '.db');
const showcasePath = path.join(dbPath, 'showcase');
if (!await dirExists(dbPath)) {
开发者ID:thedillonb,项目名称:GitHub-Trending,代码行数:31,代码来源:main.ts
注:本文中的winston.add函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论