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


TypeScript winston.Logger類代碼示例

本文整理匯總了TypeScript中winston.Logger的典型用法代碼示例。如果您正苦於以下問題:TypeScript Logger類的具體用法?TypeScript Logger怎麽用?TypeScript Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Logger類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: log

    export function log(msg: any) {
        const infoLog = new (winston.Logger)({
            transports: [
                new (winston.transports.Console)({
                    colorize: true,
                    level: 'info'
                })
            ]
        });

        infoLog.info(msg);
    };
開發者ID:jgkim7,項目名稱:blog,代碼行數:12,代碼來源:logger.ts

示例2: errorLog

    export function errorLog(msg: any) {
        const errorLog = new (winston.Logger)({
            transports: [
                new (winston.transports.Console)({
                    colorize: true,
                    level: 'error'
                })
            ]
        });

        errorLog.error(msg);
    }
開發者ID:jgkim7,項目名稱:blog,代碼行數:12,代碼來源:logger.ts

示例3: new

const init = () => {

  let quipLevels = {
    levels: {
      error: 0,
      warn: 1,
      info: 2,
      verbose: 3,
      debug: 4,
      silly: 5
    },
    colors: {
      error: 'red',
      warn: 'yellow',
      info: 'green',
      verbose: 'blue',
      debug: 'purple',
      silly: 'pink'
    }
  };

  let quipTransports = [
    new (winston.transports.Console) ({ 
      colorize: true,
      level: (process.env.NODE_ENV == 'development') ? 'debug' : 'info',
      handleExceptions: true,
      json: false
    }),
    new (winston.transports.File) ({ 
      colorize: false,
      filename: 'log/quip.log', 
      handleExceptions: true,
      json: true,
      level: 'warn', 
      maxsize: 5242880,
      maxFiles: 5
    })
  ];

  logger = new (winston.Logger) ({ 
    levels: quipLevels.levels, 
    transports: quipTransports 
  });

  logger.debug("Initiated logging.");
};
開發者ID:thinkrise,項目名稱:Quip,代碼行數:46,代碼來源:index.ts

示例4: setVerbosity

 setVerbosity (v: LoggerOptions["level"]) {
     this.logger.configure({
         level: v,
         transports: [new winston.transports.Console()],
         format: winston.format.combine(
             winston.format.colorize({ all: true }),
             logFmt
         )
     })
 }
開發者ID:0mkara,項目名稱:remix,代碼行數:10,代碼來源:logger.ts

示例5: stopped

 server.close((e: any) => {
   if (e) {
     logger.error(e);
     process.exit(1);
   }
   logger.warn(`Server stopped (${signal}).`);
   process.exit();
 });
開發者ID:easygenerator,項目名稱:lrs,代碼行數:8,代碼來源:app.ts

示例6: getAllOfRunNumber

/**
 * Functions for retrieving data from DB
 */

// get all items in the run number given a hash
// if following is true, get only future predictions from the timestamp
async function getAllOfRunNumber(hash, following) {
  // calculate a range of values. run numbers are per day,
  // so this gets us a list of all other predictions given the run number and a timestamp

  let unixTime = Number(hash.prdt) * 1000

  let min = new Date(unixTime)
  min.setHours(0, 0, 0)

  let max = new Date(unixTime) // have to set this again here to get us another object to operate on
  max.setHours(0, 0, 0)
  max.setDate(max.getDate() + 1)

  // only get the following predictions
  if (following) {
    min = new Date(unixTime)
  }

  var params = {
      TableName : 'cta-trains',
      KeyConditionExpression: 'rn = :rn and prdt BETWEEN :min AND :max',
      ExpressionAttributeValues: {
          ':min': min.getTime() / 1000,
          ':max': max.getTime() / 1000,
          ':rn': Number(hash.rn)
      }
  };

  try {
    let query = await dynamo.queryAsync(params)
    return query.Items
  } catch (error) {
    logger.warning(error)
  }
};
開發者ID:open-cta,項目名稱:wss-api,代碼行數:41,代碼來源:app.ts

示例7:

process.on('exit', () => {
	logger.info('Hello stopping');

	if(server !== undefined) {
		server.close();
	}
});
開發者ID:LionsPhil,項目名稱:typescript-service-container-template,代碼行數:7,代碼來源:server.ts

示例8: 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);
    }
開發者ID:jgkim7,項目名稱:blog,代碼行數:31,代碼來源:logger.ts

示例9: info

export function info(args:Array) {
    var text = '';
    for (var i = 0; i < args.length; i++) {
        var obj = args[i];
        text += colors.magenta(obj);
    }
    logger2.info(text);
}
開發者ID:MirekSz,項目名稱:expressik,代碼行數:8,代碼來源:lib.ts


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