本文整理汇总了PHP中Monolog\Logger::useMicrosecondTimestamps方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::useMicrosecondTimestamps方法的具体用法?PHP Logger::useMicrosecondTimestamps怎么用?PHP Logger::useMicrosecondTimestamps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::useMicrosecondTimestamps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* {@inheritDoc}
*/
public function register(Container $container)
{
// Append custom settings with missing params from default settings
$container['settings']['logger'] = self::mergeWithDefaultSettings($container['settings']['logger']);
/**
* Add dependency (DI).
*
* @param Container $c
*
* @return Logger
*/
$container['logger'] = function (Container $c) {
$settings = $c['settings']['logger'];
$loggerFormat = "[%datetime%] %level_name% %message% %context% %extra%\n";
$loggerTimeFormat = "Y-m-d H:i:s";
$loggerTimeZone = new DateTimeZone('Europe/Berlin');
$logger = new Logger($settings['name']);
if ($settings['color']) {
$logger->pushProcessor(new ConsoleColorProcessor());
}
$logger->pushProcessor(new CleanupProcessor($settings['trimPaths']));
$logger->pushProcessor(new IntrospectionProcessor(Logger::WARNING));
$logger->pushProcessor(new ProcessIdProcessor());
$logger->pushProcessor(new PsrLogMessageProcessor());
$logger->setTimezone($loggerTimeZone);
$logger->useMicrosecondTimestamps(false);
// Using microseconds is buggy (2016-08-04)
$formatter = new LineFormatter($loggerFormat, $loggerTimeFormat);
$formatter->ignoreEmptyContextAndExtra(true);
$defaultHandler = new StreamHandler('php://stdout', $settings['level'], $bubble = false);
$defaultHandler->setFormatter($formatter);
$logger->pushHandler($defaultHandler);
$errorHandler = new StreamHandler('php://stderr', Logger::ERROR, $bubble = false);
$errorHandler->setFormatter($formatter);
$logger->pushHandler($errorHandler);
// Register logger as default PHP error, exception and shutdown handler
// Note: Make sure only this handler handles errors (set $callPrevious to false)
$errorHandler = ErrorHandler::register($logger, $errorLevelMap = false, $exceptionLevelMap = false);
$errorHandler->registerErrorHandler($levelMap = [], $callPrevious = false);
$errorHandler->registerExceptionHandler($levelMap = [], $callPrevious = false);
return $logger;
};
}
示例2: testUseMicrosecondTimestamps
/**
* @dataProvider useMicrosecondTimestampsProvider
* @covers Monolog\Logger::useMicrosecondTimestamps
* @covers Monolog\Logger::addRecord
*/
public function testUseMicrosecondTimestamps($micro, $assert)
{
$logger = new Logger('foo');
$logger->useMicrosecondTimestamps($micro);
$handler = new TestHandler();
$logger->pushHandler($handler);
$logger->info('test');
list($record) = $handler->getRecords();
$this->{$assert}('000000', $record['datetime']->format('u'));
}