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


PHP Logger::getLevelName方法代码示例

本文整理汇总了PHP中Monolog\Logger::getLevelName方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::getLevelName方法的具体用法?PHP Logger::getLevelName怎么用?PHP Logger::getLevelName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monolog\Logger的用法示例。


在下文中一共展示了Logger::getLevelName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write

 /**
  * {@inheritDoc}
  */
 protected function write(array $record)
 {
     $data = $record['context'];
     $data['level'] = Logger::getLevelName($record['level']);
     $data['message'] = $record['message'];
     $this->logger->post($record['channel'], $data);
 }
开发者ID:yegortokmakov,项目名称:monolog-fluentd,代码行数:10,代码来源:FluentdHandler.php

示例2: testHandlerUsesLineFormatterWhichIgnoresEmptyArrays

 /**
  * @covers ::getDefaultFormatter
  */
 public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays()
 {
     $record = array('message' => 'msg', 'context' => array(), 'level' => Logger::DEBUG, 'level_name' => Logger::getLevelName(Logger::DEBUG), 'channel' => 'channel', 'datetime' => new \DateTime(), 'extra' => array());
     $expectedFormatter = new LineFormatter(null, null, true, true);
     $expected = $expectedFormatter->format($record);
     $handlerFormatter = $this->handler->getFormatter();
     $actual = $handlerFormatter->format($record);
     $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered');
 }
开发者ID:EyeStorm,项目名称:tn-huan-it,代码行数:12,代码来源:FleepHookHandlerTest.php

示例3: testWrite

 public function testWrite()
 {
     $data = $this->record;
     $data['level'] = Logger::getLevelName($data['level']);
     $tag = $data['channel'] . '.' . $data['message'];
     $loggerMock = $this->getMockBuilder('Fluent\\Logger\\FluentLogger')->disableOriginalConstructor()->getMock();
     $loggerMock->expects($this->once())->method('post')->with('debug.monolog.fluent', $data);
     $handler = new FluentHandler($loggerMock);
     $handler->write($this->record);
 }
开发者ID:jojihere,项目名称:monolog-fluent,代码行数:10,代码来源:FluentHandlerTest.php

示例4: testWritingAndFormatting

 public function testWritingAndFormatting()
 {
     $output = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface');
     $output->expects($this->any())->method('getVerbosity')->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG));
     $output->expects($this->once())->method('write')->with('<info>[2013-05-29 16:21:54] app.INFO:</info> My info message  ' . "\n");
     $handler = new ConsoleHandler(null, false);
     $handler->setOutput($output);
     $infoRecord = array('message' => 'My info message', 'context' => array(), 'level' => Logger::INFO, 'level_name' => Logger::getLevelName(Logger::INFO), 'channel' => 'app', 'datetime' => new \DateTime('2013-05-29 16:21:54'), 'extra' => array());
     $this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.');
 }
开发者ID:ayoah,项目名称:symfony,代码行数:10,代码来源:ConsoleHandlerTest.php

示例5: testWrite

 public function testWrite()
 {
     $fluentLogger = $this->getMock('Fluent\\Logger\\FluentLogger', array(), array(), '', false);
     $record = $this->getRecord();
     $expectedContext = $record['context'];
     $expectedContext['level'] = Logger::getLevelName($record['level']);
     $expectedContext['message'] = $record['message'];
     $fluentLogger->expects($this->once())->method('post')->with($record['channel'], $expectedContext);
     $handler = new FluentdHandler($fluentLogger);
     $handler->handle($record);
 }
开发者ID:yegortokmakov,项目名称:monolog-fluentd,代码行数:11,代码来源:FluentdHandlerTest.php

示例6: getRecord

 /**
  * @return array Record
  */
 protected function getRecord($level = Logger::WARNING, $message = 'test')
 {
     return array(
         'message' => $message,
         'context' => array(),
         'level' => $level,
         'level_name' => Logger::getLevelName($level),
         'channel' => 'test',
         'datetime' => new \DateTime(),
         'extra' => array(),
     );
 }
开发者ID:usefulthink,项目名称:symfony,代码行数:15,代码来源:WebProcessorTest.php

示例7: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if (isset($record['context']) && isset($record['context']['tag'])) {
         $tag = $record['context']['tag'];
     } else {
         $tag = $this->tag;
     }
     $tag = $tag . '.' . $this->env;
     $data = $record;
     $data['level'] = Logger::getLevelName($record['level']);
     $this->logger->post($tag, $data);
 }
开发者ID:elcweb,项目名称:monolog-fluentd-bundle,代码行数:15,代码来源:MonologFluentdHandler.php

示例8: save

 /**
  * Save records into database in batch
  *
  * @param array $records
  *
  * @throws \Exception
  */
 protected function save(array $records)
 {
     if ($this->hasError === true) {
         $this->fallback->handleBatch($records);
         return;
     }
     $data = [];
     foreach ($records as $record) {
         // ['message', 'context', 'level', 'channel', 'created_at', 'extra'] <= Single row format
         $data[] = [Log::FIELD_MESSAGE => $record['message'], Log::FIELD_CONTEXT => serialize((array) $record['context']), Log::FIELD_LEVEL => Logger::getLevelName($record['level']), Log::FIELD_CHANNEL => $record['channel'], Log::FIELD_CREATED_AT => $record['datetime'] instanceof \DateTime ? Carbon::instance($record['datetime']) : Carbon::now(), Log::FIELD_EXTRA => serialize((array) $record['extra'])];
     }
     try {
         $this->container->make('db')->connection()->table((new Log())->getTable())->insert($data);
     } catch (\Exception $ex) {
         $this->hasError = true;
         $this->fallback->handleBatch($records);
         throw $ex;
     }
 }
开发者ID:vi-kon,项目名称:laravel-db-log,代码行数:26,代码来源:LaravelDbHandler.php

示例9: testProvidingNullLineFormatToGetMonologDefault

 public function testProvidingNullLineFormatToGetMonologDefault()
 {
     $logfileName = 'nullFormatterTest.log';
     $this->cleanUpLogFile($logfileName);
     $command = $this->registerCommand(new LoggingCommand());
     EncapsulationViolator::invokeMethod($command, 'setLogFilename', array($logfileName));
     EncapsulationViolator::invokeMethod($command, 'setConsoleLogLineFormat', array(null));
     EncapsulationViolator::invokeMethod($command, 'setFileLogLineFormat', array(null));
     $commandTester = $this->executeCommand($command);
     // Generate what the default format looks like
     $lineFormatter = new \Monolog\Formatter\LineFormatter(null);
     $record = array('message' => 'The quick brown fox jumps over the lazy dog', 'context' => array(), 'level' => Logger::EMERGENCY, 'level_name' => Logger::getLevelName(Logger::EMERGENCY), 'channel' => $command->getLogger()->getName(), 'datetime' => new \DateTime('1970-01-01 00:00:00'), 'extra' => array());
     $exampleLine = $lineFormatter->format($record);
     $exampleLine = trim(str_replace('[1970-01-01 00:00:00]', '', $exampleLine));
     // strip out date as this wont match
     // Test  console format
     $this->assertRegExp('/' . $exampleLine . '/', $commandTester->getDisplay(), 'Console log line format does not seem to match the Monolog default');
     // Test default logfile format
     $this->assertRegExp('/' . $exampleLine . '/', $this->getLogfileContents($logfileName), 'File log line format does not seem to match the Monolog default');
     $this->cleanUpLogFile($logfileName);
 }
开发者ID:sarelvdwalt,项目名称:BaseCommandBundle,代码行数:21,代码来源:LoggingEnhancementTest.php

示例10: parseLogLevel

 /**
  * Converts a given log level string to a log level integer.
  *
  * @param string $logLevelStr Values could be DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY
  * @return int
  * @throws \Exception
  */
 public static function parseLogLevel($logLevelStr)
 {
     if (is_numeric($logLevelStr)) {
         return (int) $logLevelStr;
     } else {
         switch (strtoupper($logLevelStr)) {
             case Logger::getLevelName(Logger::DEBUG):
                 $logLevel = Logger::DEBUG;
                 break;
             case Logger::getLevelName(Logger::INFO):
                 $logLevel = Logger::INFO;
                 break;
             case Logger::getLevelName(Logger::NOTICE):
                 $logLevel = Logger::NOTICE;
                 break;
             case Logger::getLevelName(Logger::WARNING):
                 $logLevel = Logger::WARNING;
                 break;
             case Logger::getLevelName(Logger::ERROR):
                 $logLevel = Logger::ERROR;
                 break;
             case Logger::getLevelName(Logger::CRITICAL):
                 $logLevel = Logger::CRITICAL;
                 break;
             case Logger::getLevelName(Logger::ALERT):
                 $logLevel = Logger::ALERT;
                 break;
             case Logger::getLevelName(Logger::EMERGENCY):
                 $logLevel = Logger::EMERGENCY;
                 break;
             default:
                 throw new \Exception("Log level '{$logLevelStr}' is not supported!'");
         }
         return $logLevel;
     }
 }
开发者ID:awdn,项目名称:vigilant-queue,代码行数:43,代码来源:ConsoleLog.php

示例11: getRecord

 /**
  * @return array Record
  */
 protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
 {
     return array('message' => $message, 'context' => $context, 'level' => $level, 'level_name' => Logger::getLevelName($level), 'channel' => 'test', 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))), 'extra' => array());
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:7,代码来源:StatsDHandlerTest.php

示例12: logLevel

 /**
  * Convert a Monolog log level to textual equivalent.
  *
  * @param integer $level
  *
  * @return string
  */
 public function logLevel($level)
 {
     if (!is_numeric($level)) {
         return $level;
     }
     try {
         return ucfirst(strtolower(\Monolog\Logger::getLevelName($level)));
     } catch (\Exception $e) {
         return $level;
     }
 }
开发者ID:Twiebie,项目名称:bolt,代码行数:18,代码来源:AdminHandler.php

示例13: getRecord

 protected function getRecord($level = Logger::WARNING)
 {
     return array('level' => $level, 'level_name' => Logger::getLevelName($level), 'channel' => 'log', 'Record' => 'foo', 'datetime' => new \DateTime(), 'extra' => array());
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:4,代码来源:BufferHandlerTest.php

示例14: getLevelName

 public static function getLevelName($level)
 {
     return Logger::getLevelName($level);
 }
开发者ID:nook-ru,项目名称:monolog-viewer,代码行数:4,代码来源:LogFile.php

示例15: getRecord

 /**
  * @return array Record
  */
 protected function getRecord($level = Logger::WARNING, $message = 'test', $context = [])
 {
     return ['message' => $message, 'context' => $context, 'level' => $level, 'level_name' => Logger::getLevelName($level), 'channel' => 'test', 'datetime' => new DateTimeImmutable(true), 'extra' => []];
 }
开发者ID:earncef,项目名称:monolog,代码行数:7,代码来源:TestCase.php


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