本文整理汇总了PHP中LoggerLoggingEvent类的典型用法代码示例。如果您正苦于以下问题:PHP LoggerLoggingEvent类的具体用法?PHP LoggerLoggingEvent怎么用?PHP LoggerLoggingEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LoggerLoggingEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
public function convert(LoggerLoggingEvent $event)
{
if ($this->useLocalDate) {
return $this->date($this->format, $event->getTimeStamp());
}
return date($this->format, $event->getTimeStamp());
}
示例2: 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());
}
示例3: append
/**
* Appends a logging event.
*
* If the target file changes because of passage of time (e.g. at midnight)
* the current file is closed. A new file, with the new date, will be
* opened by the write() method.
*/
public function append(LoggerLoggingEvent $event)
{
$eventDate = $this->getDate($event->getTimestamp());
// Initial setting of current date
if (!isset($this->currentDate)) {
$this->currentDate = $eventDate;
} else {
if ($this->currentDate !== $eventDate) {
$this->currentDate = $eventDate;
// Close the file if it's open.
// Note: $this->close() is not called here because it would set
// $this->closed to true and the appender would not recieve
// any more logging requests
if (is_resource($this->fp)) {
$this->write($this->layout->getFooter());
fclose($this->fp);
}
$this->fp = null;
}
}
//$this->rollOver();
//var_dump($this);
//parent::append($event);
$this->write($this->layout->getFooter());
}
示例4: format
public function format(LoggerLoggingEvent $event)
{
// If required, initialize the location data
if ($this->locationInfo) {
$event->getLocationInformation();
}
return serialize($event) . PHP_EOL;
}
示例5: convert
public function convert(LoggerLoggingEvent $event)
{
$info = $event->getThrowableInformation();
if (isset($info)) {
$ex = $info->getThrowable();
return (string) $ex . PHP_EOL;
}
return '';
}
示例6: convert
public function convert(LoggerLoggingEvent $event)
{
$info = $event->getThrowableInformation();
if (isset($info)) {
$ex = $info->getThrowable();
return $this->getExceptionTraceAsString($ex) . PHP_EOL;
}
return '';
}
示例7: decide
/**
* @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
*/
public function decide(LoggerLoggingEvent $event)
{
$msg = $event->getRenderedMessage();
if ($msg === null or $this->stringToMatch === null) {
return LoggerFilter::NEUTRAL;
}
if (strpos($msg, $this->stringToMatch) !== false) {
return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
}
return LoggerFilter::NEUTRAL;
}
示例8: decide
/**
* Return the decision of this filter.
*
* Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
* option is not set or if there is not match. Otherwise, if there is a
* match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
* <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
* returned decision is {@link LoggerFilter::DENY} if the
* <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
*
* @param LoggerLoggingEvent $event
* @return integer
*/
public function decide(LoggerLoggingEvent $event)
{
if ($this->levelToMatch === null) {
return LoggerFilter::NEUTRAL;
}
if ($this->levelToMatch->equals($event->getLevel())) {
return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
} else {
return LoggerFilter::NEUTRAL;
}
}
示例9: decide
/**
* @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
*/
function decide(LoggerLoggingEvent $event)
{
$category = $event->getLoggerName();
if ($category === null or $this->stringToMatch === null) {
return LoggerFilter::NEUTRAL;
}
if (preg_match($this->stringToMatch, $category)) {
return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::NEUTRAL;
} else {
return LoggerFilter::DENY;
}
}
示例10: convert
public function convert(LoggerLoggingEvent $event)
{
$name = $event->getLocationInformation()->getClassName();
if (!isset($this->cache[$name])) {
// If length is set return shortened class name
if (isset($this->length)) {
$this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length);
} else {
$this->cache[$name] = $name;
}
}
return $this->cache[$name];
}
示例11: append
public function append(LoggerLoggingEvent $event)
{
$level = $event->getLevel();
if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
trigger_error($this->layout->format($event), E_USER_ERROR);
} else {
if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
trigger_error($this->layout->format($event), E_USER_WARNING);
} else {
trigger_error($this->layout->format($event), E_USER_NOTICE);
}
}
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: testGetStartTime
public function testGetStartTime()
{
$time = LoggerLoggingEvent::getStartTime();
self::assertInternalType('float', $time);
$time2 = LoggerLoggingEvent::getStartTime();
self::assertEquals($time, $time2);
}
示例15: convert
/**
* @param LoggerLoggingEvent $event
* @return string
*/
public function convert($event)
{
$locationInfo = $event->getLocationInformation();
switch ($this->type) {
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER:
return $locationInfo->getFullInfo();
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER:
return $locationInfo->getMethodName();
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER:
return $locationInfo->getLineNumber();
case LoggerPatternParser::LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER:
return $locationInfo->getFileName();
default:
return '';
}
}