本文整理汇总了TypeScript中inversify-logger-middleware.makeLoggerMiddleware函数的典型用法代码示例。如果您正苦于以下问题:TypeScript makeLoggerMiddleware函数的具体用法?TypeScript makeLoggerMiddleware怎么用?TypeScript makeLoggerMiddleware使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeLoggerMiddleware函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getLogger
function getLogger(
addLogEntry: (entry: interfaces.SelectableLogEntry, logSize: number) => void,
initSettings: (settings: interfaces.UserSettings) => void,
dispatch: Redux.Dispatch
): inversify.interfaces.Middleware {
let settings = getSettings();
dispatch(initSettings(settings));
let reduxRenderer = function(entry: inversifyLoggerMiddleware.interfaces.LogEntry) {
dispatch(addLogEntry(new SelectableLogEntry(entry), getSettings().size));
};
let middleware = makeLoggerMiddleware(settings, reduxRenderer);
return middleware;
}
示例2: makeLoggerMiddleware
factory: true,
implementationType: true,
onActivation: true,
provider: true,
scope: true,
serviceIdentifier: true,
type: true
},
serviceIdentifier: true,
target: {
metadata: true,
name: true,
serviceIdentifier: true
}
},
time: true
};
let logger = makeLoggerMiddleware();
kernel.applyMiddleware(logger);
let loggerOutput1: LoggerOutput<string> = { entry: null };
let stringRenderer1 = makeStringRenderer(loggerOutput1);
let logger1 = makeLoggerMiddleware(options, stringRenderer1);
kernel.applyMiddleware(logger1);
let loggerOutput2: LoggerOutput<inversifyLoggerMiddleware.interfaces.LogEntry> = { entry: null };
let objRenderer2 = makeObjRenderer(loggerOutput2);
let logger2 = makeLoggerMiddleware(options, objRenderer2);
kernel.applyMiddleware(logger2);
示例3: Kernel
import { Kernel } from 'inversify';
import { makeLoggerMiddleware } from 'inversify-logger-middleware';
import * as bodyParser from 'body-parser';
import * as helmet from 'helmet';
import TYPES from './constant/types';
import TAGS from './constant/tags';
import { HomeController } from './controller/home';
import { MongoDBClient } from './utils/mongodb/client';
import { UserController } from './controller/user';
import { UserService } from './service/user';
// load everything needed to the kernel
let kernel = new Kernel();
if (process.env.NODE_ENV === 'development') {
let logger = makeLoggerMiddleware();
kernel.applyMiddleware(logger);
}
kernel.bind<interfaces.Controller>(TYPE.Controller).to(HomeController).whenTargetNamed(TAGS.HomeController);
kernel.bind<interfaces.Controller>(TYPE.Controller).to(UserController).whenTargetNamed(TAGS.UserController);
kernel.bind<MongoDBClient>(TYPES.MongoDBClient).to(MongoDBClient);
kernel.bind<UserService>(TYPES.UserService).to(UserService);
// start the server
let server = new InversifyExpressServer(kernel);
server.setConfig((app) => {
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());