当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript express-winston.errorLogger函数代码示例

本文整理汇总了TypeScript中express-winston.errorLogger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript errorLogger函数的具体用法?TypeScript errorLogger怎么用?TypeScript errorLogger使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了errorLogger函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

export default function () {

  var expressWinston = require('express-winston');

  server
    .msg('Winston - Error Logging Enabled.');

  app.use(expressWinston.errorLogger({

    'transports': [

      new winston.transports.File({

        'name': 'request-error',

        'filename': server.cwd() + '/logs/errors.log',

        'handleExceptions': true,

        'json': true,

        'colorize': true

      })

    ],

    'expressFormat': true,

    'colorStatus': true

  }));

};
开发者ID:tybeck,项目名称:portfolio-v2,代码行数:34,代码来源:error-logging.ts

示例2: next

> = (context: interfaces.Context) => (app: express.Application) => {
  const settings = context.container.get<SettingsServiceAttributes>(
    registry.SettingsService
  );
  app.use(
    expressWinston.errorLogger({
      transports: settings.loggerTransports,
      requestWhitelist: [],
      msg: '{{req.method}} {{req.url}} => {{res.statusCode}}: {{err.message}}'
    })
  );

  /* tslint:disable:no-void-expression */
  /**
   * Add a final error handler that will prevent the Express final error handler from executing
   * when routing-controllers error handler or any other error handler has already sent headers
   * and data.
   * See https://github.com/pleerock/routing-controllers/issues/243
   */
  app.use(
    (
      error: Error,
      _req: express.Request,
      res: express.Response,
      next: express.NextFunction
    ) => {
      if (res.headersSent || res._header) {
        return next();
      }

      return next(error);
    }
  );
  /* tslint:enable:no-void-expression */

  return app;
};
开发者ID:patrickhousley,项目名称:xyzzy-mean,代码行数:37,代码来源:express-error-config.ts

示例3: errorLogger

export function errorLogger() {
    return expressWinston.errorLogger(winstonOptions)
}
开发者ID:nicholas-robson,项目名称:dkydev_webapp,代码行数:3,代码来源:logger.ts

示例4: new

import IAppLogger from './IAppLogger';

const logger = new (winston.Logger)({
  level: config.get('LOG_LEVEL')
});

if (config.get('NODE_ENV') !== 'test') {
  logger.add(winston.transports.Console);
}

export interface ILoggerMiddleware {
  logger: express.RequestHandler;
  errorLogger: express.ErrorRequestHandler;
}

const loggerSingleton: IAppLogger = logger;
const LoggerMiddleware: ILoggerMiddleware = {
  logger: expressWinston.logger({
    winstonInstance: logger
  }),
  errorLogger: expressWinston.errorLogger({
    winstonInstance: logger
  })
};

export default loggerSingleton;

export {
  LoggerMiddleware
};
开发者ID:vmlf01,项目名称:ts-painters-node,代码行数:30,代码来源:Logger.ts

示例5: winstonMongo

expressWinston.requestWhitelist.push('ips');
app.use(expressWinston.logger({
    transports: [
        new winstonMongo({
            db: config.winston.mongo.dbName,
            collection: config.winston.mongo.accessLogCollName
        })
    ]
}));

// Setup router
app.use('/', require('./route/index'));

// express-winston errorLogger makes sense AFTER the router.
// Send log to mongodb
app.use(expressWinston.errorLogger({
    transports: [
        new winstonMongo({
            db: config.winston.mongo.dbName,
            collection: config.winston.mongo.errLogCollName
        })
    ]
}));

// Start listening
app.listen(config.port, () => {
    console.log('Web server started at port ' + config.port);
});

module.exports = app;
开发者ID:overpower-doublej,项目名称:gcm-server-test,代码行数:30,代码来源:app.ts


注:本文中的express-winston.errorLogger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。