本文整理汇总了TypeScript中express-winston.logger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript logger函数的具体用法?TypeScript logger怎么用?TypeScript logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了logger函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
const initializeServer = function() {
const favicon = require("serve-favicon");
const serveStatic = require("serve-static");
const winston = require("winston");
const expressWinston = require("express-winston");
const loggerSettings = {
transports: [
new winston.transports.Console({
level: "error",
json: true,
colorize: true,
}),
],
};
const prefix: string = staticFolder + "-" + serverConfig.MATH_PROGRAM + "/";
const getList: reader.GetListFunction = reader.tutorialReader(prefix, fs);
const admin = require("./admin")(clients, serverConfig.MATH_PROGRAM);
app.use(favicon(staticFolder + "-" +
serverConfig.MATH_PROGRAM + "/favicon.ico"));
app.use(SocketIOFileUpload.router);
app.use(serveStatic(staticFolder + "-" + serverConfig.MATH_PROGRAM));
app.use(serveStatic(staticFolder + "-common"));
app.use(expressWinston.logger(loggerSettings));
app.use("/admin", admin.stats);
app.use("/getListOfTutorials", getList);
app.use(unhandled);
};
开发者ID:fhinkel,项目名称:InteractiveShell,代码行数:29,代码来源:server.ts
示例2: makeHttpServer
export function makeHttpServer(config: Config) {
const app = express()
const server = new AdminAPI(config)
app.use(expressWinston.logger({
winstonInstance: logger
}))
app.use(cors())
app.post(/\/v1\/admin\/reload/, (req: express.Request, res: express.Response) => {
return server.checkAuthorization(req.headers['authorization'])
.then((authResult) => {
if (!authResult) {
return { statusCode: 403, status: { error: 'forbidden' } }
}
return server.handleReload()
})
.then(reloadStatus => writeResponse(res, reloadStatus.status, reloadStatus.statusCode))
})
app.get(/\/v1\/admin\/config/, (req: express.Request, res: express.Response) => {
return server.checkAuthorization(req.headers['authorization'])
.then((authResult) => {
if (!authResult) {
return { statusCode: 403, status: { error: 'forbidden' } }
}
return server.handleGetConfig()
})
.then((configData) => writeResponse(res, configData.status, configData.statusCode))
})
app.post(
/\/v1\/admin\/config/, express.json(),
(req: express.Request, res: express.Response) => {
return server.checkAuthorization(req.headers['authorization'])
.then((authResult) => {
if (!authResult) {
return { statusCode: 403, status: { error: 'forbidden' } }
}
const newConfig = req.body
return server.handleSetConfig(newConfig)
})
.then((configStatus) => writeResponse(res, configStatus.status, configStatus.statusCode))
})
return app
}
开发者ID:blockstack,项目名称:blockstack-registrar,代码行数:51,代码来源:http.ts
示例3: makeHttpServer
export function makeHttpServer(config: Config) {
const app = express()
const server = new GaiaDiskReader(config)
app.use(expressWinston.logger({
winstonInstance: logger
}))
app.use(cors())
app.get(/\/([a-zA-Z0-9-_]+)\/(.+)/, (req, res) => {
let filename = req.params[1]
if (filename.endsWith('/')) {
filename = filename.substring(0, filename.length - 1)
}
const address = req.params[0]
if (config.cacheControl) {
res.set('Cache-Control', config.cacheControl)
}
return server.handleGet(address, filename)
.then((fileInfo) => {
const exists = fileInfo.exists
const contentType = fileInfo.contentType
if (!exists) {
return res.status(404).send('File not found')
}
const opts = {
root: config.diskSettings.storageRootDirectory,
headers: {
'content-type': contentType
}
}
const path = Path.join(address, filename)
return res.sendFile(path, opts)
})
.catch((err) => {
logger.error(err)
return res.status(400).send('Could not return file')
})
})
return app
}
开发者ID:blockstack,项目名称:blockstack-registrar,代码行数:48,代码来源:http.ts
示例4:
> = (context: interfaces.Context) => (app: express.Application) => {
const settings = context.container.get<SettingsServiceAttributes>(
registry.SettingsService
);
app.use(helmet());
app.use(compression());
app.use(
expressWinston.logger({
transports: settings.loggerTransports,
expressFormat: true,
colorize: false,
meta: false
})
);
return app;
};
开发者ID:patrickhousley,项目名称:xyzzy-mean,代码行数:17,代码来源:express-config.ts
示例5: load
@InitPhase
@Inject(['logger', 'config', 'express'])
@Before('BodyParser:load', false)
@Before('StaticRoutes:load', false)
load(logger, config, app) {
logger.debug('load ExpressWinston');
config.defaults({
expressWinston: {
template: '{{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms ',
metaLog: process.env.NODE_ENV === 'production',
expressLog: process.env.NODE_ENV !== 'production',
statusLevels: true
}
});
app.use(expressWinston.logger({
winstonInstance: logger,
statusLevels: !!config.get('expressWinston:statusLevels'),
expressFormat: !!config.get('expressWinston:expressLog'),
msg: config.get('expressWinston:template')
}));
}
开发者ID:HallM,项目名称:poc-fw2,代码行数:23,代码来源:index.ts
示例6: installMiddlewares
function installMiddlewares(app: express.Application) {
app.use(serverTiming());
app.use((req, res, next) => {
TimingManager.reset(res);
next();
});
app.use(
expressWinston.logger({
// expressFormat: true,
meta: false,
msg:
'{{req.method}}: {{res.statusCode}} ({{res.responseTime}}ms)\t{{req.url}}',
transports: [
new winston.transports.Console({
colorize: true
})
],
skip(req: express.Request, res: express.Response) {
return /^\/static\//.test(req.path);
}
})
);
}
开发者ID:qjac,项目名称:sql-fundamentals,代码行数:23,代码来源:express-server.ts
示例7: function
export default function () {
var expressWinston = require('express-winston');
server
.msg('Winston - Request Logging Enabled.');
app.use(expressWinston.logger({
'transports': [
new winston.transports.File({
'name': 'request-success',
'filename': server.cwd() + '/logs/requests.log',
'level': 'info',
'handleExceptions': true,
'json': true,
'colorize': true
})
],
'expressFormat': true,
'colorStatus': true
}));
};
开发者ID:tybeck,项目名称:portfolio-v2,代码行数:36,代码来源:request-logging.ts
示例8: logger
export function logger(): any {
return expressWinston.logger(winstonOptions)
}
开发者ID:nicholas-robson,项目名称:dkydev_webapp,代码行数:3,代码来源:logger.ts
示例9: 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
示例10:
},
colorize: true,
level: 'silly',
})
],
levels: {
silly: 0,
debug: 1,
info: 2,
warn: 3,
error: 4,
},
colors: {
silly: 'cyan',
debug: 'blue',
info: 'green',
warn: 'yellow',
error: 'red',
},
});
module.exports = logger;
module.exports.express = expressWinston.logger({
transports: [
logger
],
meta: false,
msg: "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}"
});
开发者ID:valtech,项目名称:valtech-shortie,代码行数:30,代码来源:log.ts
注:本文中的express-winston.logger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论