本文整理汇总了TypeScript中winston.remove函数的典型用法代码示例。如果您正苦于以下问题:TypeScript remove函数的具体用法?TypeScript remove怎么用?TypeScript remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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
}));
}
示例2: winstonConfiguration
function winstonConfiguration() {
function consoleConfiguration() {
return {
stringify: obj => JSON.stringify(obj, null, '\t'),
json: true
};
}
function fileConfiguration(fileName) {
return {
filename: path.join(__dirname, fileName),
stringify: obj => JSON.stringify(obj, null, '\t')
};
}
winston
.remove(winston.transports.Console)
.add(winston.transports.Console, consoleConfiguration())
.add(winston.transports.File, fileConfiguration('bullshit.json'));
winston.handleExceptions(new winston.transports.File(fileConfiguration('exceptions.json')));
}
示例3: enableProdMode
enableProdMode();
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();