• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript winston.add函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript winston.configure函数代码示例发布时间:2022-05-25
下一篇:
TypeScript winreg.keys函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap