當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript winston.remove函數代碼示例

本文整理匯總了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
    }));
  }
開發者ID:andwoo,項目名稱:grouptube2,代碼行數:39,代碼來源:Logger.ts

示例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')));
}
開發者ID:radotzki,項目名稱:bullshit-server,代碼行數:22,代碼來源:app.ts

示例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();

開發者ID:Mandosis,項目名稱:2MEAN,代碼行數:29,代碼來源:server.ts


注:本文中的winston.remove函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。