本文整理汇总了TypeScript中pino类的典型用法代码示例。如果您正苦于以下问题:TypeScript pino类的具体用法?TypeScript pino怎么用?TypeScript pino使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pino类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: logger
"use strict";
import * as logger from "pino";
export default logger();
开发者ID:coderfox,项目名称:Another-SS-Panel,代码行数:5,代码来源:log.ts
示例2: pino
import { Server } from 'hapi';
import * as pino from 'pino';
import * as HapiPino from 'hapi-pino';
const pinoLogger = pino();
const server = new Server();
server.register({
plugin: HapiPino,
options: {
logPayload: false,
logRouteTags: false,
stream: process.stdout,
prettyPrint: process.env.NODE_ENV !== 'PRODUCTION',
levelTags: {
trace: 'trace',
debug: 'debug',
info: 'info',
warn: 'warn',
error: 'error'
},
allTags: 'info',
serializers: {
req: (req: any) => console.log(req)
},
instance: pinoLogger,
logEvents: false,
mergeHapiLogData: false,
ignorePaths: ['/testRoute'],
level: 'debug',
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:hapi-pino-tests.ts
示例3: pinoms
import * as fs from 'fs';
import * as pino from 'pino';
import * as pinoms from 'pino-multi-stream';
const streams: pinoms.Streams = [
{ stream: process.stdout }, // an "info" level destination stream
{ level: 'error', stream: process.stderr }, // an "error" level destination stream
{ stream: fs.createWriteStream('/tmp/info.stream.out') },
{ level: 'fatal', stream: fs.createWriteStream('/tmp/fatal.stream.out') }
];
const logger = pinoms({
level: 'warn',
streams
});
const log = pino({
level: 'debug' // this MUST be set at the lowest level of the
// destinations
}, pinoms.multistream(streams));
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:19,代码来源:pino-multi-stream-tests.ts
示例4: pino
import * as _ from 'lodash';
import * as pino from 'pino';
import * as util from 'util';
export const options = { enabled: process.env.NODE_ENV === 'test' ? false : true };
export interface Logger {
debug: (s: string, ...args: any[]) => void;
info: (s: string, ...args: any[]) => void;
warn: (s: string, ...args: any[]) => void;
error: (s: string, ...args: any[]) => void;
}
const logger = pino({ level: 'debug' });
const cache = new Map();
export function getLogger(name: string): Logger {
if (!options.enabled) {
return new Proxy({}, { get: () => _.noop }) as Logger;
}
const label = _.trimEnd(name, 'Impl');
if (cache.has(label)) {
return cache.get(label);
}
const childLogger = logger.child({ label });
const wrappedLogger = {
debug: (s: string, ...args) => childLogger.debug(util.format(s, ...args)),
info: (s: string, ...args) => childLogger.info(util.format(s, ...args)),
warn: (s: string, ...args) => childLogger.warn(util.format(s, ...args)),
error: (s: string, ...args) => childLogger.error(util.format(s, ...args))
};
开发者ID:HarryTmetic,项目名称:r2,代码行数:31,代码来源:index.ts
示例5: Pino
import * as Pino from 'pino'
import Server from './server'
import Config from './config'
const pino = Pino({
prettyPrint: ['dev', 'test'].indexOf(Config.node_env) > -1,
level: Config.node_env === 'test' ? 'error' : 'info',
})
function warnEnvironment(vars: string[]) {
const missing = vars.filter((val) => process.env[val] === undefined)
missing.forEach((name) => pino.warn(`Environment variable ${name} is not set`))
}
warnEnvironment([
'HACKBOT_PASSWORD',
'ADMIN_USERNAME',
'ADMIN_PASSWORD',
'PUSHER_URL',
'SLACK_API_TOKEN',
])
const server = new Server(pino)
server.start().then((info) => {
pino.info(`Server started on port ${info.Port}`)
if (process.send !== undefined) {
process.send('started')
}
}).catch((err) => {
pino.error('Server could not be started')
pino.error(err)
开发者ID:TechNottingham,项目名称:Hack24-API,代码行数:31,代码来源:start.ts
示例6: main
async function main() {
console.log('Running Po.et Node')
console.log('')
console.log('Loading Configuration...')
const configuration = loadConfigurationWithDefaults()
console.log('Switching to Structured Logging')
console.log('Logging Level:', configuration.loggingLevel)
console.log('')
const logger: Pino.Logger = Pino({
level: configuration.loggingLevel,
prettyPrint: configuration.loggingPretty,
})
logger.info(configuration, 'Loaded Configuration and merged with defaults')
const loggingConfiguration = {
loggingLevel: configuration.loggingLevel,
loggingPretty: configuration.loggingPretty,
}
const api = new API({
...loggingConfiguration,
port: configuration.apiPort,
dbUrl: configuration.mongodbUrl,
rabbitmqUrl: configuration.rabbitmqUrl,
})
try {
await api.start()
} catch (exception) {
logger.error({ exception }, 'API was unable to start')
}
const view = new View({
...loggingConfiguration,
dbUrl: configuration.mongodbUrl,
rabbitmqUrl: configuration.rabbitmqUrl,
})
try {
await view.start()
} catch (exception) {
logger.error({ exception }, 'View was unable to start')
}
const storage = new Storage({
...loggingConfiguration,
dbUrl: configuration.mongodbUrl,
ipfsUrl: configuration.ipfsUrl,
rabbitmqUrl: configuration.rabbitmqUrl,
downloadIntervalInSeconds: configuration.downloadIntervalInSeconds,
downloadRetryDelayInMinutes: configuration.downloadRetryDelayInMinutes,
downloadMaxAttempts: configuration.downloadMaxAttempts,
downloadTimeoutInSeconds: configuration.downloadTimeoutInSeconds,
})
try {
await storage.start()
} catch (exception) {
logger.error({ exception }, 'Storage was unable to start')
}
if (configuration.enableTimestamping) {
const blockchainWriter = new BlockchainWriter({
...loggingConfiguration,
dbUrl: configuration.mongodbUrl,
rabbitmqUrl: configuration.rabbitmqUrl,
insightUrl: configuration.insightUrl,
bitcoinAddress: configuration.bitcoinAddress,
bitcoinAddressPrivateKey: configuration.bitcoinAddressPrivateKey,
poetNetwork: configuration.poetNetwork,
poetVersion: configuration.poetVersion,
timestampIntervalInSeconds: configuration.timestampIntervalInSeconds,
})
try {
await blockchainWriter.start()
} catch (exception) {
logger.error({ exception }, 'BlockchainWriter was unable to start')
}
}
const blockchainReader = new BlockchainReader({
...loggingConfiguration,
dbUrl: configuration.mongodbUrl,
rabbitmqUrl: configuration.rabbitmqUrl,
insightUrl: configuration.insightUrl,
poetNetwork: configuration.poetNetwork,
poetVersion: configuration.poetVersion,
minimumBlockHeight: configuration.minimumBlockHeight,
forceBlockHeight: configuration.forceBlockHeight,
blockchainReaderIntervalInSeconds: configuration.blockchainReaderIntervalInSeconds,
})
try {
await blockchainReader.start()
} catch (exception) {
logger.error({ exception }, 'BlockchainReader was unable to start')
}
}
开发者ID:GuilhermeCaruso,项目名称:node,代码行数:98,代码来源:index.ts
示例7: createModuleLogger
export function createModuleLogger(configuration: LoggingConfiguration, dirname: string): Pino.Logger {
return childWithModuleName(Pino(loggingConfigurationToPinoConfiguration(configuration)), dirname)
}
开发者ID:GuilhermeCaruso,项目名称:node,代码行数:3,代码来源:Logging.ts
注:本文中的pino类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论