当前位置: 首页>>代码示例>>PHP>>正文


PHP Logger::useMicrosecondTimestamps方法代码示例

本文整理汇总了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;
     };
 }
开发者ID:ansas,项目名称:php-component,代码行数:46,代码来源:ConsoleLoggerProvider.php

示例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'));
 }
开发者ID:jorjoh,项目名称:Varden,代码行数:15,代码来源:LoggerTest.php


注:本文中的Monolog\Logger::useMicrosecondTimestamps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。