當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。