本文整理汇总了PHP中LoggerLoggingEvent::getTimeStamp方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerLoggingEvent::getTimeStamp方法的具体用法?PHP LoggerLoggingEvent::getTimeStamp怎么用?PHP LoggerLoggingEvent::getTimeStamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerLoggingEvent
的用法示例。
在下文中一共展示了LoggerLoggingEvent::getTimeStamp方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* @param LoggerLoggingEvent $event
* @return string
*/
public function convert($event)
{
$timeStamp = $event->getTimeStamp();
$usecs = round(($timeStamp - (int) $timeStamp) * 1000);
$this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);
return date($this->df, $event->getTimeStamp());
}
示例2: convert
public function convert(LoggerLoggingEvent $event)
{
if ($this->useLocalDate) {
return $this->date($this->format, $event->getTimeStamp());
}
return date($this->format, $event->getTimeStamp());
}
示例3: testConstructWithTimestamp
public function testConstructWithTimestamp()
{
$l = LoggerLevel::getLevelDebug();
$timestamp = microtime(true);
$e = new LoggerLoggingEvent('fqcn', 'TestLogger', $l, 'test', $timestamp);
self::assertEquals($e->getTimeStamp(), $timestamp);
}
示例4: testRelative
public function testRelative()
{
$converter = new LoggerPatternConverterRelative($this->info);
$expected = number_format($this->event->getTimeStamp() - $this->event->getStartTime(), 4);
$actual = $converter->convert($this->event);
self::assertSame($expected, $actual);
}
示例5: append
public function append(LoggerLoggingEvent $event)
{
$log = new StdClass();
$log->time = $event->getTimeStamp();
$log->level = $event->getLevel()->toString();
$log->msg = $event->getMessage();
$log->logger = $event->getLoggerName();
$this->logBuffer[] = $log;
$this->emitter->emit('event', array($log));
if (count($this->logBuffer) > $this->logLimit) {
array_shift($this->logBuffer);
}
}
示例6: convert
/**
* @param LoggerLoggingEvent $event
* @return string
*/
public function convert($event)
{
switch ($this->type) {
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER:
$timeStamp = $event->getTimeStamp();
$startTime = LoggerLoggingEvent::getStartTime();
return (string) (int) ($timeStamp * 1000 - $startTime * 1000);
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER:
return $event->getThreadName();
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER:
$level = $event->getLevel();
return $level->toString();
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER:
return $event->getNDC();
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER:
return $event->getRenderedMessage();
default:
return '';
}
}
示例7: 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;
}
示例8: convert
/**
* @param LoggerLoggingEvent $event
* @return string
*/
function convert($event)
{
$timeStamp = $event->getTimeStamp();
$usecs = round(($timeStamp - (int) $timeStamp) * 1000);
$this->df = str_replace("\\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df));
return date($this->df, $event->getTimeStamp());
}
示例9: format
/**
* Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd.
*
* @param LoggerLoggingEvent $event
* @return string
*/
public function format(LoggerLoggingEvent $event)
{
$loggerName = $event->getLoggerName();
$timeStamp = number_format((double) ($event->getTimeStamp() * 1000), 0, '', '');
$thread = $event->getThreadName();
$level = $event->getLevel();
$levelStr = $level->toString();
$buf = "<{$this->_namespacePrefix}:event logger=\"{$loggerName}\" level=\"{$levelStr}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL;
$buf .= "<{$this->_namespacePrefix}:message><![CDATA[";
$this->appendEscapingCDATA($buf, $event->getRenderedMessage());
$buf .= "]]></{$this->_namespacePrefix}:message>" . PHP_EOL;
$ndc = $event->getNDC();
if ($ndc != null) {
$buf .= "<{$this->_namespacePrefix}:NDC><![CDATA[";
$this->appendEscapingCDATA($buf, $ndc);
$buf .= "]]></{$this->_namespacePrefix}:NDC>" . PHP_EOL;
}
if ($this->getLocationInfo()) {
$locationInfo = $event->getLocationInformation();
$buf .= "<{$this->_namespacePrefix}:locationInfo " . "class=\"" . $locationInfo->getClassName() . "\" " . "file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " . "line=\"" . $locationInfo->getLineNumber() . "\" " . "method=\"" . $locationInfo->getMethodName() . "\" ";
$buf .= "/>" . PHP_EOL;
}
$buf .= "</{$this->_namespacePrefix}:event>" . PHP_EOL . PHP_EOL;
return $buf;
}
示例10: format
/**
* In addition to the level of the statement and message, the
* returned string includes time, thread, category.
* <p>Time, thread, category are printed depending on options.
*
* @param LoggerLoggingEvent $event
* @return string
*/
public function format(LoggerLoggingEvent $event)
{
$timeStamp = (double) $event->getTimeStamp();
$format = strftime($this->dateFormat, (int) $timeStamp);
if ($this->microSecondsPrinting) {
$usecs = floor(($timeStamp - (int) $timeStamp) * 1000);
$format .= sprintf(',%03d', $usecs);
}
$format .= ' ';
if ($this->threadPrinting) {
$format .= '[' . getmypid() . '] ';
}
$level = $event->getLevel();
$format .= $level . ' ';
if ($this->categoryPrefixing) {
$format .= $event->getLoggerName() . ' ';
}
if ($this->contextPrinting) {
$ndc = $event->getNDC();
if ($ndc != null) {
$format .= $ndc . ' ';
}
}
$format .= '- ' . $event->getRenderedMessage();
$format .= PHP_EOL;
return $format;
}
示例11: format
/**
* @param LoggerLoggingEvent $event
* @return string
*/
function format($event)
{
$sbuf = LOG4PHP_LINE_SEP . "<tr>" . LOG4PHP_LINE_SEP;
$sbuf .= "<td>";
$eventTime = (double) $event->getTimeStamp();
$eventStartTime = (double) LoggerLoggingEvent::getStartTime();
$sbuf .= number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
$sbuf .= "</td>" . LOG4PHP_LINE_SEP;
$sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
$sbuf .= $event->getThreadName();
$sbuf .= "</td>" . LOG4PHP_LINE_SEP;
$sbuf .= "<td title=\"Level\">";
$level = $event->getLevel();
if ($level->equals(LoggerLevel::getLevelDebug())) {
$sbuf .= "<font color=\"#339933\">";
$sbuf .= $level->toString();
$sbuf .= "</font>";
} elseif ($level->equals(LoggerLevel::getLevelWarn())) {
$sbuf .= "<font color=\"#993300\"><strong>";
$sbuf .= $level->toString();
$sbuf .= "</strong></font>";
} else {
$sbuf .= $level->toString();
}
$sbuf .= "</td>" . LOG4PHP_LINE_SEP;
$sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
$sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
$sbuf .= "</td>" . LOG4PHP_LINE_SEP;
if ($this->locationInfo) {
$locInfo = $event->getLocationInformation();
$sbuf .= "<td>";
$sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES) . ':' . $locInfo->getLineNumber();
$sbuf .= "</td>" . LOG4PHP_LINE_SEP;
}
$sbuf .= "<td title=\"Message\">";
$sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
$sbuf .= "</td>" . LOG4PHP_LINE_SEP;
$sbuf .= "</tr>" . LOG4PHP_LINE_SEP;
if ($event->getNDC() != null) {
$sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
$sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
$sbuf .= "</td></tr>" . LOG4PHP_LINE_SEP;
}
return $sbuf;
}