本文整理汇总了PHP中LoggerLoggingEvent::getLoggerName方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerLoggingEvent::getLoggerName方法的具体用法?PHP LoggerLoggingEvent::getLoggerName怎么用?PHP LoggerLoggingEvent::getLoggerName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerLoggingEvent
的用法示例。
在下文中一共展示了LoggerLoggingEvent::getLoggerName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: convert
public function convert(LoggerLoggingEvent $event)
{
$name = $event->getLoggerName();
if (!isset($this->cache[$name])) {
// If length is set return shortened logger name
if (isset($this->length)) {
$this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length);
} else {
$this->cache[$name] = $name;
}
}
return $this->cache[$name];
}
示例3: 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);
}
}
示例4: format
/**
* Converts the logging event into an array which can be logged to mongodb.
*
* @param LoggerLoggingEvent $event
* @return array The array representation of the logging event.
*/
protected function format(LoggerLoggingEvent $event)
{
$timestampSec = (int) $event->getTimestamp();
$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
$document = array('timestamp' => new MongoDate($timestampSec, $timestampUsec), 'level' => $event->getLevel()->toString(), 'thread' => (int) $event->getThreadName(), 'message' => $event->getMessage(), 'loggerName' => $event->getLoggerName());
$locationInfo = $event->getLocationInformation();
if ($locationInfo != null) {
$document['fileName'] = $locationInfo->getFileName();
$document['method'] = $locationInfo->getMethodName();
$document['lineNumber'] = $locationInfo->getLineNumber() == 'NA' ? 'NA' : (int) $locationInfo->getLineNumber();
$document['className'] = $locationInfo->getClassName();
}
$throwableInfo = $event->getThrowableInformation();
if ($throwableInfo != null) {
$document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
}
return $document;
}
示例5: format
/**
* @param LoggerLoggingEvent $event
* @return string
*/
public function format(LoggerLoggingEvent $event)
{
$sbuf = PHP_EOL . "<tr>" . PHP_EOL;
$sbuf .= "<td>";
$sbuf .= $event->getTime();
$sbuf .= "</td>" . PHP_EOL;
$sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
$sbuf .= $event->getThreadName();
$sbuf .= "</td>" . PHP_EOL;
$sbuf .= "<td title=\"Level\">";
$level = $event->getLevel();
if ($level->equals(LoggerLevel::getLevelDebug())) {
$sbuf .= "<font color=\"#339933\">{$level}</font>";
} else {
if ($level->equals(LoggerLevel::getLevelWarn())) {
$sbuf .= "<font color=\"#993300\"><strong>{$level}</strong></font>";
} else {
$sbuf .= $level;
}
}
$sbuf .= "</td>" . PHP_EOL;
$sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
$sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
$sbuf .= "</td>" . PHP_EOL;
if ($this->locationInfo) {
$locInfo = $event->getLocationInformation();
$sbuf .= "<td>";
$sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES) . ':' . $locInfo->getLineNumber();
$sbuf .= "</td>" . PHP_EOL;
}
$sbuf .= "<td title=\"Message\">";
$sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
$sbuf .= "</td>" . PHP_EOL;
$sbuf .= "</tr>" . PHP_EOL;
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>" . PHP_EOL;
}
return $sbuf;
}
示例6: 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;
}
示例7: getFullyQualifiedName
/**
* @param LoggerLoggingEvent $event
* @return string
*/
function getFullyQualifiedName($event)
{
return $event->getLoggerName();
}
示例8: testConstructWithLoggerName
public function testConstructWithLoggerName()
{
$l = LoggerLevel::getLevelDebug();
$e = new LoggerLoggingEvent('fqcn', 'TestLogger', $l, 'test');
self::assertEquals($e->getLoggerName(), 'TestLogger');
}
示例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: append
function append(LoggerLoggingEvent $event)
{
if ($this->canAppend) {
try {
// Reopen new mysql connection (need for php threads)
$this->activateOptions();
if ($event->message instanceof FarmLogMessage) {
$severity = $this->SeverityToInt($event->getLevel()->toString());
$message = $this->db->qstr($event->message->Message);
$query = "INSERT DELAYED INTO logentries SET \r\n\t \t\t\tserverid\t= '', \r\n\t \t\t\tmessage\t\t= {$message},\r\n\t \t\t\tseverity\t= '{$severity}',\r\n\t \t\t\ttime\t\t= '" . time() . "',\r\n\t \t\t\tsource \t\t= '" . $event->getLoggerName() . "',\r\n\t \t\t\tfarmid \t\t= '{$event->message->FarmID}' \r\n\t \t\t";
$this->db->Execute($query);
$event->message = "[FarmID: {$event->message->FarmID}] {$event->message->Message}";
return;
} elseif ($event->message instanceof ScriptingLogMessage) {
$message = $this->db->qstr($event->message->Message);
$query = "INSERT DELAYED INTO scripting_log SET \r\n\t \t\t\tfarmid \t\t= '{$event->message->FarmID}',\r\n\t \t\t\tevent\t\t= '{$event->message->EventName}',\r\n\t \t\t\tserver_id\t= '{$event->message->ServerID}',\r\n\t \t\t\tdtadded\t\t= NOW(),\r\n\t \t\t\tmessage\t\t= {$message}\r\n\t \t\t";
$this->db->Execute($query);
$event->message = "[Farm: {$event->message->FarmID}] {$event->message->Message}";
return;
} else {
if (stristr($event->message, "AWS was not able to validate the provided access credentials") || stristr($event->message, "The X509 Certificate you provided does not exist in our records")) {
return;
}
}
$level = $event->getLevel()->toString();
// Redeclare threadName
$event->threadName = TRANSACTION_ID;
$event->subThreadName = defined("SUB_TRANSACTIONID") ? SUB_TRANSACTIONID : $GLOBALS["SUB_TRANSACTIONID"] ? $GLOBALS["SUB_TRANSACTIONID"] : TRANSACTION_ID;
$event->farmID = defined("LOGGER_FARMID") ? LOGGER_FARMID : $GLOBALS["LOGGER_FARMID"] ? $GLOBALS["LOGGER_FARMID"] : null;
if (defined('TRANSACTION_ID')) {
if ($level == "FATAL" || $level == "ERROR") {
// Set meta information
$this->db->Execute("INSERT DELAYED INTO syslog_metadata SET transactionid='" . TRANSACTION_ID . "', errors='1', warnings='0'\r\n\t\t \t\t\tON DUPLICATE KEY UPDATE errors=errors+1\r\n\t\t \t\t");
} else {
if ($level == "WARN") {
// Set meta information
$this->db->Execute("INSERT DELAYED INTO syslog_metadata SET transactionid='" . TRANSACTION_ID . "', errors='0', warnings='1'\r\n\t\t\t \t\t\tON DUPLICATE KEY UPDATE warnings=warnings+1\r\n\t\t\t \t\t");
}
}
}
$msg = $event->message;
$event->message = $this->db->qstr($event->message);
$query = $this->layout->format($event);
$this->db->Execute($query);
$event->message = $msg;
} catch (Exception $e) {
}
}
}
示例12: 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;
}
示例13: append
function append(LoggerLoggingEvent $event)
{
if ($this->canAppend) {
try {
// Reopen new mysql connection (need for php threads)
$this->activateOptions();
if ($event->message instanceof FarmLogMessage) {
$severity = $this->SeverityToInt($event->getLevel()->toString());
$message = $event->message->Message;
$tm = date('YmdH');
$hash = md5(":{$message}:{$event->message->FarmID}:{$event->getLoggerName()}:{$tm}", true);
$query = "INSERT DELAYED INTO logentries SET\n `id` = ?,\n `serverid`\t= '',\n `message`\t= ?,\n `severity`\t= ?,\n `time`\t\t= ?,\n `source` \t= ?,\n `farmid` \t= ?\n ON DUPLICATE KEY UPDATE cnt = cnt + 1, `time` = ?\n ";
$this->db->Execute($query, array($hash, $message, $severity, time(), $event->getLoggerName(), $event->message->FarmID, time()));
$event->message = "[FarmID: {$event->message->FarmID}] {$event->message->Message}";
return;
} elseif ($event->message instanceof ScriptingLogMessage) {
$message = $this->db->qstr($event->message->Message);
$query = "INSERT DELAYED INTO scripting_log SET\n `farmid` \t\t= ?,\n `event`\t\t = ?,\n `server_id` \t= ?,\n `dtadded`\t\t= NOW(),\n `message`\t\t= ?\n ";
$this->db->Execute($query, array($event->message->FarmID, $event->message->EventName, $event->message->ServerID, $message));
$event->message = "[Farm: {$event->message->FarmID}] {$event->message->Message}";
return;
} else {
if (stristr($event->message, "AWS was not able to validate the provided access credentials") || stristr($event->message, "The X509 Certificate you provided does not exist in our records")) {
return;
}
}
$level = $event->getLevel()->toString();
// Redeclare threadName
$event->threadName = TRANSACTION_ID;
$event->subThreadName = defined("SUB_TRANSACTIONID") ? SUB_TRANSACTIONID : (isset($GLOBALS["SUB_TRANSACTIONID"]) ? $GLOBALS["SUB_TRANSACTIONID"] : TRANSACTION_ID);
$event->farmID = defined("LOGGER_FARMID") ? LOGGER_FARMID : (isset($GLOBALS["LOGGER_FARMID"]) ? $GLOBALS["LOGGER_FARMID"] : null);
if (defined('TRANSACTION_ID')) {
if ($level == "FATAL" || $level == "ERROR") {
// Set meta information
$this->db->Execute("\n INSERT DELAYED INTO syslog_metadata\n SET transactionid='" . TRANSACTION_ID . "', errors='1', warnings='0'\n ON DUPLICATE KEY UPDATE errors=errors+1\n ");
} else {
if ($level == "WARN") {
// Set meta information
$this->db->Execute("\n INSERT DELAYED INTO syslog_metadata\n SET transactionid='" . TRANSACTION_ID . "', errors='0', warnings='1'\n ON DUPLICATE KEY UPDATE warnings=warnings+1\n ");
}
}
}
$msg = $event->message;
$event->message = $this->db->qstr($event->message);
$query = $this->layout->format($event);
$this->db->Execute($query);
$event->message = $msg;
} catch (Exception $e) {
}
}
}
示例14: append
function append(LoggerLoggingEvent $event)
{
if ($this->canAppend) {
try {
// Reopen new mysql connection (need for php threads)
$this->activateOptions();
if ($event->message instanceof FarmLogMessage) {
$severity = $this->SeverityToInt($event->getLevel()->toString());
$message = $event->message->Message;
$tm = date('YmdH');
$hash = md5(":{$message}:{$event->message->FarmID}:{$event->getLoggerName()}:{$tm}", true);
$serverId = $event->message->ServerID;
$query = "INSERT DELAYED INTO logentries SET\n `id` = ?,\n `serverid`\t= ?,\n `message`\t= ?,\n `severity`\t= ?,\n `time`\t\t= ?,\n `source` \t= ?,\n `farmid` \t= ?\n ON DUPLICATE KEY UPDATE cnt = cnt + 1, `time` = ?\n ";
$this->db->Execute($query, array($hash, $serverId, $message, $severity, time(), $event->getLoggerName(), $event->message->FarmID, time()));
$event->message = "[FarmID: {$event->message->FarmID}] {$event->message->Message}";
return;
} else {
// No longer log stuff in syslog table
return;
}
} catch (Exception $e) {
}
}
}