當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LoggerLoggingEvent::getMDCMap方法代碼示例

本文整理匯總了PHP中LoggerLoggingEvent::getMDCMap方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoggerLoggingEvent::getMDCMap方法的具體用法?PHP LoggerLoggingEvent::getMDCMap怎麽用?PHP LoggerLoggingEvent::getMDCMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LoggerLoggingEvent的用法示例。


在下文中一共展示了LoggerLoggingEvent::getMDCMap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: convert

 public function convert(LoggerLoggingEvent $event)
 {
     if (isset($this->key)) {
         return $event->getMDC($this->key);
     } else {
         $buff = array();
         $map = $event->getMDCMap();
         foreach ($map as $key => $value) {
             $buff[] = "{$key}={$value}";
         }
         return implode(', ', $buff);
     }
 }
開發者ID:gustavoghioldi,項目名稱:Plugin-opencart2,代碼行數:13,代碼來源:LoggerPatternConverterMDC.php

示例2: format

 /**
  * Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd.
  *
  * @param LoggerLoggingEvent $event        	
  * @return string
  */
 public function format(LoggerLoggingEvent $event)
 {
     $ns = $this->namespacePrefix;
     $loggerName = $event->getLoggerName();
     $timeStamp = number_format((double) ($event->getTimeStamp() * 1000), 0, '', '');
     $thread = $event->getThreadName();
     $level = $event->getLevel()->toString();
     $buf = "<{$ns}:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL;
     $buf .= "<{$ns}:message>";
     $buf .= $this->encodeCDATA($event->getRenderedMessage());
     $buf .= "</{$ns}:message>" . PHP_EOL;
     $ndc = $event->getNDC();
     if (!empty($ndc)) {
         $buf .= "<{$ns}:NDC><![CDATA[";
         $buf .= $this->encodeCDATA($ndc);
         $buf .= "]]></{$ns}:NDC>" . PHP_EOL;
     }
     $mdcMap = $event->getMDCMap();
     if (!empty($mdcMap)) {
         $buf .= "<{$ns}:properties>" . PHP_EOL;
         foreach ($mdcMap as $name => $value) {
             $buf .= "<{$ns}:data name=\"{$name}\" value=\"{$value}\" />" . PHP_EOL;
         }
         $buf .= "</{$ns}:properties>" . PHP_EOL;
     }
     if ($this->getLocationInfo()) {
         $locationInfo = $event->getLocationInformation();
         $buf .= "<{$ns}:locationInfo " . "class=\"" . $locationInfo->getClassName() . "\" " . "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " . "line=\"" . $locationInfo->getLineNumber() . "\" " . "method=\"" . $locationInfo->getMethodName() . "\" ";
         $buf .= "/>" . PHP_EOL;
     }
     $buf .= "</{$ns}:event>" . PHP_EOL;
     return $buf;
 }
開發者ID:josefd8,項目名稱:dashboardWeb,代碼行數:39,代碼來源:LoggerLayoutXml.php

示例3: getEventMDCFields

 /**
  * Returns event MDC data as array
  * @param LoggerLoggingEvent $event
  * @return array
  */
 public function getEventMDCFields(LoggerLoggingEvent $event)
 {
     $fields = array();
     foreach ($event->getMDCMap() as $key => $value) {
         $fieldName = "_" . $key;
         if ($this->isAdditionalFieldNameValid($fieldName)) {
             $fields[$fieldName] = $value;
         }
     }
     return $fields;
 }
開發者ID:wikimart,項目名稱:log4php-graylog2,代碼行數:16,代碼來源:LoggerLayoutGelf.php


注:本文中的LoggerLoggingEvent::getMDCMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。