本文整理汇总了TypeScript中winston.configure函数的典型用法代码示例。如果您正苦于以下问题:TypeScript configure函数的具体用法?TypeScript configure怎么用?TypeScript configure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了configure函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createLogger
export function createLogger(options: LoggerOptions): void {
const { logType, logLevel } = options;
configure({
exitOnError: false,
format: combine(
timestamp({
format: 'YYYY-MM-DD HH:mm:ss'
}),
splat(),
myFormat
),
level: logLevel,
transports:
logType === 'file'
? [
new transports.File({
filename: 'error.log',
level: 'error'
}),
new transports.File({ filename: 'combined.log' })
]
: [new transports.Console()]
});
}
开发者ID:mshick,项目名称:arrivals-osx,代码行数:25,代码来源:logger.ts
示例2: initializeWinston
/**
* Initializes winston and returns a subset of the available log level
* methods (debug, info, error). This method should only be called once
* during an application's lifetime.
*
* @param path The path where to write log files. This path will have
* the current date prepended to the basename part of the
* path such that passing a path '/logs/foo' will end up
* writing to '/logs/2017-05-17.foo'
*/
function initializeWinston(path: string): winston.LogMethod {
const fileLogger = new winston.transports.DailyRotateFile({
filename: path,
// We'll do this ourselves, thank you
handleExceptions: false,
json: false,
datePattern: 'yyyy-MM-dd.',
prepend: true,
// log everything interesting (info and up)
level: 'info',
maxFiles: MaxLogFiles,
})
const consoleLogger = new winston.transports.Console({
level: process.env.NODE_ENV === 'development' ? 'debug' : 'error',
})
winston.configure({
transports: [consoleLogger, fileLogger],
})
return winston.log
}
开发者ID:Ahskys,项目名称:desktop,代码行数:33,代码来源:log.ts
示例3: glob
classTransformer: true,
validation: true,
/**
* We can add options about how routing-controllers should configure itself.
* Here we specify what controllers should be registered in our express server.
*/
controllers: env.app.dirs.controllers,
middlewares: env.app.dirs.middlewares,
});
winston.configure({
transports: [
new winston.transports.Console({
level: env.log.level,
handleExceptions: true,
json: env.log.json,
timestamp: env.node !== "development",
colorize: env.node === "development",
}),
],
});
routingUseContainer(Container);
ormUseContainer(Container);
classValidatorUseContainer(Container);
// Register validator schemes
env.app.dirs.validatorSchemes.forEach((pattern) => {
glob(pattern, (err: any, files: Array<string>) => {
for (const file of files) {
const schemas = require(file);
开发者ID:LogansUA,项目名称:jest-import-error,代码行数:31,代码来源:app.ts
示例4: require
// Read config
// tslint:disable-next-line:no-var-requires
const config: Config = require('/data/config.json')
// Set winston config
winston.configure({
transports: [
// Console logging
new (winston.transports.Console)({
level: config.logLevel,
prettyPrint: true
}),
// Rotated file logging
new (winston.transports.File)({
filename: '/data/logs/debug.log',
json: false,
level: 'debug',
maxFiles: 5,
maxSize: 1000000,
prettyPrint: true,
tailable: true,
timestamp: () => moment().format('YYYY-MM-DD HH:mm:ss.SSS')
})
]
})
// Instantiate commando client
const client: CommandoClient = new CommandoClient({
commandPrefix: config.prefix,
invite: config.inviteUrl,
owner: config.owner
开发者ID:tinnvec,项目名称:stonebot,代码行数:31,代码来源:app.ts
示例5: async
export const bootstrapApp = async (): Promise<BootstrapSettings> => {
/**
* We create a new express server instance.
*/
const app: express.Application = express();
app.use(json({ limit: "50mb" }));
app.use(urlencoded({ extended: true }));
useExpressServer(app, {
cors: true,
routePrefix: env.app.routePrefix,
defaultErrorHandler: false,
classTransformer: true,
validation: true,
/**
* We can add options about how routing-controllers should configure itself.
* Here we specify what controllers should be registered in our express server.
*/
controllers: env.app.dirs.controllers,
middlewares: env.app.dirs.middlewares,
});
winston.configure({
transports: [
new winston.transports.Console({
level: env.log.level,
handleExceptions: true,
json: env.log.json,
timestamp: env.node !== "development",
colorize: env.node === "development",
}),
],
});
routingUseContainer(Container);
ormUseContainer(Container);
classValidatorUseContainer(Container);
// Register validator schemes
env.app.dirs.validatorSchemes.forEach((pattern) => {
glob(pattern, (err: any, files: Array<string>) => {
for (const file of files) {
const schemas = require(file);
Object.keys(schemas).forEach((key) => {
registerSchema(schemas[key]);
});
}
});
});
env.app.dirs.subscribers.forEach((pattern) => {
glob(pattern, (err: any, files: Array<string>) => {
for (const file of files) {
require(file);
}
});
});
const initTypeORM = async () => {
const loadedConnectionOptions = await getConnectionOptions();
const connectionOptions = Object.assign(loadedConnectionOptions, {
type: env.db.type as any, // See createConnection options for valid types
host: env.db.host,
port: env.db.port,
username: env.db.username,
password: env.db.password,
database: env.db.database,
synchronize: env.db.synchronize,
logging: env.db.logging,
entities: env.app.dirs.entities,
migrations: env.app.dirs.migrations,
});
return createConnection(connectionOptions);
};
app.get(
env.app.routePrefix,
(req: express.Request, res: express.Response) => {
return res.json({
name: env.app.name,
version: env.app.version,
description: env.app.description,
});
},
);
const log = new Logger(__filename);
try {
const connection = await initTypeORM();
const server: http.Server = app.listen(env.app.port);
banner(log);
return {
app,
//.........这里部分代码省略.........
开发者ID:LogansUA,项目名称:jest-import-error,代码行数:101,代码来源:bootstrap.ts
注:本文中的winston.configure函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论