本文整理汇总了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);
}
}
示例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;
}
示例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;
}