本文整理匯總了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());