getLogLevelMap() публичный статический Метод

Returns the log level map.
public static getLogLevelMap ( )
 public function getLogger()
 {
     $connection = $this->prophesize(ConnectionInterface::class);
     $connection->writeEntries(Argument::any())->will(function ($entries) {
         $map = Logger::getLogLevelMap();
         $entry = $entries[0]['entries'][0];
         $severity = is_int($entry['severity']) ? strtolower($map[$entry['severity']]) : $entry['severity'];
         self::$logs[] = sprintf('%s %s', $severity, $entry['jsonPayload']['message']);
     });
     $logger = new Logger($connection->reveal(), 'my-log', 'projectId');
     return new PsrLogger($logger);
 }
Пример #2
0
 /**
  * @param array $entry
  * @return LogEntry
  */
 private function buildEntry(array $entry)
 {
     if (isset($entry['jsonPayload'])) {
         $entry['jsonPayload'] = $this->formatStructForApi($entry['jsonPayload']);
     }
     if (isset($entry['labels'])) {
         $entry['labels'] = $this->formatLabelsForApi($entry['labels']);
     }
     if (isset($entry['resource']['labels'])) {
         $entry['resource']['labels'] = $this->formatLabelsForApi($entry['resource']['labels']);
     }
     if (isset($entry['severity']) && is_string($entry['severity'])) {
         $entry['severity'] = array_flip(Logger::getLogLevelMap())[$entry['severity']];
     }
     return (new LogEntry())->deserialize($entry, $this->codec);
 }
 /**
  * @dataProvider levelProvider
  */
 public function testWritesEntryWithDefinedLevels($level)
 {
     $this->connection->writeEntries(['entries' => [['severity' => array_flip(Logger::getLogLevelMap())[$level], 'jsonPayload' => ['message' => $this->textPayload], 'logName' => $this->formattedName, 'resource' => $this->resource]]])->willReturn([])->shouldBeCalledTimes(1);
     $psrLogger = $this->getPsrLogger($this->connection);
     $this->assertNull($psrLogger->{$level}($this->textPayload));
 }