Exemplo n.º 1
0
 public static function internalDebugging($value = null)
 {
     if (is_bool($value)) {
         self::$debug = $value;
     }
     return self::$debug;
 }
Exemplo n.º 2
0
 function append($event)
 {
     LoggerLog::debug("LoggerAppenderEcho::append()");
     if ($this->layout !== null) {
         if ($this->firstAppend) {
             echo $this->layout->getHeader();
             $this->firstAppend = false;
         }
         echo $this->layout->format($event);
     }
 }
Exemplo n.º 3
0
 public function close()
 {
     $from = $this->from;
     $to = $this->to;
     if (!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
         $subject = $this->subject;
         LoggerLog::debug("LoggerAppenderMail::close() sending mail from=[{$from}] to=[{$to}] subject=[{$subject}]");
         mail($to, $subject, $this->layout->getHeader() . $this->body . $this->layout->getFooter(), "From: {$from}\r\n");
     }
     $this->closed = true;
 }
 /**
  * Set console target.
  * @param mixed $value a constant or a string
  */
 public function setTarget($value)
 {
     $v = trim($value);
     if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') {
         $this->target = self::STDOUT;
     } elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') {
         $target = self::STDERR;
     } else {
         LoggerLog::debug("Invalid target. Using '" . self::STDOUT . "' by default.");
     }
 }
Exemplo n.º 5
0
 function close()
 {
     $from = $this->getFrom();
     $to = $this->getTo();
     if (!empty($this->body) && $from !== null && $to !== null && $this->layout !== null) {
         $subject = $this->getSubject();
         LoggerLog::debug("LoggerAppenderMail::close() sending mail from=[{$from}] to=[{$to}] subject=[{$subject}]");
         @mail($to, $subject, $this->layout->getHeader() . $this->body . $this->layout->getFooter(), "From: {$from}\r\n");
     }
     $this->closed = true;
 }
Exemplo n.º 6
0
 /**
  * Add a renderer to a hierarchy passed as parameter.
  * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
  *
  * @param LoggerHierarchy $repository a logger repository.
  * @param string $renderedClassName
  * @param string $renderingClassName
  * @static
  */
 public static function addRenderer($repository, $renderedClassName, $renderingClassName)
 {
     LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}].");
     $renderer = LoggerObjectRenderer::factory($renderingClassName);
     if ($renderer == null) {
         LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}].");
         return;
     } else {
         $repository->setRenderer($renderedClassName, $renderer);
     }
 }
Exemplo n.º 7
0
 function append($event)
 {
     LoggerLog::debug("LoggerAppenderFirePHP::append()");
     $message = array("message" => $event->getMessage());
     if (function_exists('debug_backtrace')) {
         $prevHop = null;
         $trace = debug_backtrace();
         // make a downsearch to identify the caller
         $hop = array_pop($trace);
         $step = array();
         while ($hop !== null) {
             $className = @$hop['class'];
             if (!empty($className) and ($className == 'loggercategory' or in_array("LoggerCategory", $this->get_ancestors($className)))) {
                 $step["file"] = str_replace("\\", "/", str_replace(getcwd(), "", $hop["file"]));
                 $step["line"] = $hop['line'];
                 break;
             }
             $prevHop = $hop;
             $hop = array_pop($trace);
         }
         $step['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
         if (isset($prevHop['function']) and $prevHop['function'] !== 'include' and $prevHop['function'] !== 'include_once' and $prevHop['function'] !== 'require' and $prevHop['function'] !== 'require_once') {
             $step['function'] = $prevHop['function'];
         } else {
             $step['function'] = 'main';
         }
         $message["caller"] = join(":", array($step["file"], $step["class"], $step["function"], $step["line"]));
     }
     $label = "";
     if (isset($message["caller"])) {
         $label = " " . $message["caller"];
     }
     $level =& $event->getLevel();
     switch ($level->level) {
         case LOG4PHP_LEVEL_INFO_INT:
             $code = FirePHP::INFO;
             break;
         case LOG4PHP_LEVEL_WARN_INT:
             $code = FirePHP::WARN;
             break;
         case LOG4PHP_LEVEL_ERROR_INT:
             $code = FirePHP::ERROR;
             break;
         case LOG4PHP_LEVEL_FATAL_INT:
             $code = FirePHP::ERROR;
             break;
         default:
             $code = FirePHP::LOG;
             break;
     }
     $this->firephp->fb($message, $level->levelStr . $label, $code);
 }
Exemplo n.º 8
0
 public function append($event)
 {
     if ($this->layout !== null) {
         LoggerLog::debug("LoggerAppenderPhp::append()");
         $level = $event->getLevel();
         if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
             trigger_error($this->layout->format($event), E_USER_ERROR);
         } elseif ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
             trigger_error($this->layout->format($event), E_USER_WARNING);
         } else {
             trigger_error($this->layout->format($event), E_USER_NOTICE);
         }
     }
 }
 /**
  * Perform variable substitution in string <var>$val</var> from the
  * values of keys found with the {@link getSystemProperty()} method.
  * 
  * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
  * 
  * <p>For example, if the "MY_CONSTANT" contains "value", then
  * the call
  * <code>
  * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
  * </code>
  * will set the variable <i>$s</i> to "Value of key is value.".</p>
  * 
  * <p>If no value could be found for the specified key, then the
  * <var>$props</var> parameter is searched, if the value could not
  * be found there, then substitution defaults to the empty string.</p>
  * 
  * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
  * "inexistentKey", then the call
  * <code>
  * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
  * </code>
  * will set <var>$s</var> to "Value of inexistentKey is []".</p>
  * 
  * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
  * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
  * 
  * @log4j-author Avy Sharell
  * 
  * @param string $val The string on which variable substitution is performed.
  * @param array $props
  * @return string
  *
  * @static
  */
 function substVars($val, $props = null)
 {
     LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]");
     $sbuf = '';
     $i = 0;
     while (true) {
         $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
         if ($j === false) {
             LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
             // no more variables
             if ($i == 0) {
                 // this is a simple string
                 LoggerLog::debug("LoggerOptionConverter::substVars() simple string");
                 return $val;
             } else {
                 // add the tail string which contails no variables and return the result.
                 $sbuf .= substr($val, $i);
                 LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf");
                 return $sbuf;
             }
         } else {
             $sbuf .= substr($val, $i, $j - $i);
             LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
             $k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
             if ($k === false) {
                 LoggerLog::warn("LoggerOptionConverter::substVars() " . "'{$val}' has no closing brace. Opening brace at position {$j}.");
                 return '';
             } else {
                 $j += LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN;
                 $key = substr($val, $j, $k - $j);
                 // first try in System properties
                 $replacement = LoggerOptionConverter::getSystemProperty($key, null);
                 // then try props parameter
                 if ($replacement == null and $props !== null) {
                     $replacement = @$props[$key];
                 }
                 if (!empty($replacement)) {
                     // Do variable substitution on the replacement string
                     // such that we can solve "Hello ${x2}" as "Hello p1"
                     // the where the properties are
                     // x1=p1
                     // x2=${x1}
                     $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
                     $sbuf .= $recursiveReplacement;
                 }
                 $i = $k + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN;
             }
         }
     }
 }
Exemplo n.º 10
0
 function append($event)
 {
     if ($this->canAppend) {
         $query = $this->layout->format($event);
         LoggerLog::debug("LoggerAppenderDb::append() query='{$query}'");
         $this->db->query($query);
     }
 }
Exemplo n.º 11
0
 /**
  * Do nothing. 
  * How I Love it !! :)
  * 
  * @param LoggerLoggingEvent $event
  */
 protected function append($event)
 {
     LoggerLog::debug("LoggerAppenderNull::append()");
 }
Exemplo n.º 12
0
 function finalizeConverter($c)
 {
     LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '{$c}'");
     $pc = null;
     switch ($c) {
         case 'c':
             $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter.");
             // $this->formattingInfo->dump();
             $this->currentLiteral = '';
             break;
         case 'C':
             $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() CLASSNAME converter.");
             //$this->formattingInfo->dump();
             $this->currentLiteral = '';
             break;
         case 'd':
             $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
             // ISO8601_DATE_FORMAT;
             $dOpt = $this->extractOption();
             if ($dOpt !== null) {
                 $dateFormatStr = $dOpt;
             }
             if ($dateFormatStr == 'ISO8601') {
                 $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
             } elseif ($dateFormatStr == 'ABSOLUTE') {
                 $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE;
             } elseif ($dateFormatStr == 'DATE') {
                 $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE;
             } else {
                 $df = $dateFormatStr;
                 if ($df == null) {
                     $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
                 }
             }
             $pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
             $this->currentLiteral = '';
             break;
         case 'F':
             $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() File name converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'l':
             $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() Location converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'L':
             $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() LINE NUMBER converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'm':
             $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() MESSAGE converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'M':
             $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER);
             //LogLog.debug("METHOD converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'p':
             $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER);
             //LogLog.debug("LEVEL converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'r':
             $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() RELATIVE TIME converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 't':
             $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() THREAD converter.");
             //formattingInfo.dump();
             $this->currentLiteral = '';
             break;
         case 'u':
             if ($this->i < $this->patternLength) {
                 $cNext = $this->pattern[$this->i];
                 if (ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) {
                     $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string) (ord($cNext) - ord('0')));
                     LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}].");
                     // formattingInfo.dump();
                     $this->currentLiteral = '';
                     $this->i++;
                 } else {
                     LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char '{$cNext}' at position {$this->i}.");
                 }
             }
             break;
         case 'x':
             $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() NDC converter.");
             $this->currentLiteral = '';
             break;
         case 'X':
             $xOpt = $this->extractOption();
             $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
             LoggerLog::debug("LoggerPatternParser::finalizeConverter() MDC converter.");
             $this->currentLiteral = '';
             break;
         default:
             LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char [{$c}] at position {$this->i} in conversion pattern.");
             $pc = new LoggerLiteralPatternConverter($this->currentLiteral);
             $this->currentLiteral = '';
     }
     $this->addConverter($pc);
 }
Exemplo n.º 13
0
 /**
  * Set maximum depth of this diagnostic context. If the current
  * depth is smaller or equal to <var>maxDepth</var>, then no
  * action is taken.
  *
  * <p>This method is a convenient alternative to multiple 
  * {@link pop()} calls. Moreover, it is often the case that at 
  * the end of complex call sequences, the depth of the NDC is
  * unpredictable. The {@link setMaxDepth()} method circumvents
  * this problem.
  *
  * @param integer $maxDepth
  * @see getDepth()
  * @static
  */
 function setMaxDepth($maxDepth)
 {
     LoggerLog::debug("LoggerNDC::setMaxDepth() maxDepth='{$maxDepth}'");
     $maxDepth = (int) $maxDepth;
     if ($maxDepth <= LOGGER_NDC_HT_SIZE) {
         if (LoggerNDC::getDepth() > $maxDepth) {
             $GLOBALS['log4php.LoggerNDC.ht'] = array_slice($GLOBALS['log4php.LoggerNDC.ht'], $maxDepth);
         }
         $GLOBALS['log4php.LoggerNDC.maxDepth'] = $maxDepth;
     }
 }
Exemplo n.º 14
0
 function append($event)
 {
     if ($this->fp && $this->layout !== null) {
         LoggerLog::debug("LoggerAppenderFile::append()");
         @fwrite($this->fp, $this->layout->format($event));
     }
 }
Exemplo n.º 15
0
 /**
  * @see LoggerAppender::doAppend()
  * @param LoggerLoggingEvent $event
  */
 public function doAppend($event)
 {
     LoggerLog::debug("LoggerAppenderSkeleton::doAppend()");
     if ($this->closed) {
         LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}].");
         return;
     }
     if (!$this->isAsSevereAsThreshold($event->getLevel())) {
         LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold.");
         return;
     }
     $f = $this->getFirstFilter();
     while ($f !== null) {
         switch ($f->decide($event)) {
             case LOG4PHP_LOGGER_FILTER_DENY:
                 return;
             case LOG4PHP_LOGGER_FILTER_ACCEPT:
                 return $this->append($event);
             case LOG4PHP_LOGGER_FILTER_NEUTRAL:
                 $f = $f->getNext();
         }
     }
     $this->append($event);
 }
Exemplo n.º 16
0
 function append($event)
 {
     $from = $this->getFrom();
     $to = $this->getTo();
     if (empty($from) or empty($to)) {
         return;
     }
     $smtpHost = $this->getSmtpHost();
     $prevSmtpHost = ini_get('SMTP');
     if (!empty($smtpHost)) {
         ini_set('SMTP', $smtpHost);
     } else {
         $smtpHost = $prevSmtpHost;
     }
     $smtpPort = $this->getPort();
     $prevSmtpPort = ini_get('smtp_port');
     if ($smtpPort > 0 and $smtpPort < 65535) {
         ini_set('smtp_port', $smtpPort);
     } else {
         $smtpPort = $prevSmtpPort;
     }
     LoggerLog::debug("LoggerAppenderMailEvent::append()" . ":from=[{$from}]:to=[{$to}]:smtpHost=[{$smtpHost}]:smtpPort=[{$smtpPort}]");
     if (!@mail($to, $this->getSubject(), $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), "From: {$from}\r\n")) {
         LoggerLog::debug("LoggerAppenderMailEvent::append() mail error");
     }
     ini_set('SMTP', $prevSmtpHost);
     ini_set('smtp_port', $prevSmtpPort);
 }
Exemplo n.º 17
0
 /**
  * Get the context identified by the key parameter.
  *
  * <p>You can use special key identifiers to map values in 
  * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.'
  * followed by the var name you want to refer.</p>
  *
  * <p>This method has no side effects.</p>
  *
  * @param string $key
  * @return string
  * @static
  */
 function get($key)
 {
     LoggerLog::debug("LoggerMDC::get() key='{$key}'");
     if (!empty($key)) {
         if (strpos($key, 'server.') === 0) {
             $varName = substr($key, 7);
             LoggerLog::debug("LoggerMDC::get() a _SERVER[{$varName}] is requested.");
             return $_SERVER[$varName];
         } elseif (strpos($key, 'env.') === 0) {
             $varName = substr($key, 4);
             LoggerLog::debug("LoggerMDC::get() a _ENV[{$varName}] is requested.");
             return $_ENV[$varName];
         } elseif (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) {
             LoggerLog::debug("LoggerMDC::get() a user key is requested.");
             return $GLOBALS['log4php.LoggerMDC.ht'][$key];
         }
     }
     return '';
 }
Exemplo n.º 18
0
 function activate()
 {
     LoggerLog::debug("LoggerOptionConverter::activate()");
     if (method_exists($this->obj, 'activateoptions')) {
         return call_user_func(array(&$this->obj, 'activateoptions'));
     } else {
         LoggerLog::debug("LoggerOptionConverter::activate() Nothing to activate.");
     }
 }
Exemplo n.º 19
0
 /**
  * Produces a formatted string as specified by the conversion pattern.
  *
  * @param LoggerLoggingEvent $event
  * @return string
  */
 function format($event)
 {
     LoggerLog::debug("LoggerPatternLayout::format()");
     // Reset working stringbuffer
     $this->sbuf = '';
     $c = $this->head;
     while ($c !== null) {
         $c->format($this->sbuf, $event);
         $c = $c->next;
     }
     return $this->sbuf;
 }
 /**
  * Constructor
  *
  * @param string $formattingInfo
  * @param integer $precision
  */
 function LoggerCategoryPatternConverter($formattingInfo, $precision)
 {
     LoggerLog::debug("LoggerCategoryPatternConverter::LoggerCategoryPatternConverter() precision='{$precision}'");
     $this->LoggerNamedPatternConverter($formattingInfo, $precision);
 }
 /**
  * @param array $props array of properties
  * @param string $appenderName
  * @return LoggerAppender
  */
 function &parseAppender($props, $appenderName)
 {
     $appender =& LoggerAppender::singleton($appenderName);
     if ($appender !== null) {
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Appender [{$appenderName}] was already parsed.");
         return $appender;
     }
     // Appender was not previously initialized.
     $prefix = LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_APPENDER_PREFIX . $appenderName;
     $layoutPrefix = $prefix . ".layout";
     $appenderClass = @$props[$prefix];
     if (!empty($appenderClass)) {
         $appender =& LoggerAppender::singleton($appenderName, $appenderClass);
         if ($appender === null) {
             LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "Could not instantiate appender named [{$appenderName}].");
             return null;
         }
     } else {
         LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "Could not instantiate appender named [{$appenderName}] with null className.");
         return null;
     }
     $appender->setName($appenderName);
     if ($appender->requiresLayout()) {
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Parsing layout section for [{$appenderName}].");
         $layoutClass = @$props[$layoutPrefix];
         $layoutClass = LoggerOptionConverter::substVars($layoutClass, $props);
         if (empty($layoutClass)) {
             LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "layout class is empty in '{$layoutPrefix}'. Using Simple layout");
             $layout = LoggerLayout::factory('LoggerLayoutSimple');
         } else {
             $layout = LoggerLayout::factory($layoutClass);
             if ($layout === null) {
                 LoggerLog::warn("LoggerPropertyConfigurator::parseAppender() " . "cannot create layout '{$layoutClass}'. Using Simple layout");
                 $layout = LoggerLayout::factory('LoggerLayoutSimple');
             }
         }
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Parsing layout options for [{$appenderName}].");
         LoggerPropertySetter::setPropertiesByObject($layout, $props, $layoutPrefix . ".");
         LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "End Parsing layout options for [{$appenderName}].");
         $appender->setLayout($layout);
     }
     LoggerPropertySetter::setPropertiesByObject($appender, $props, $prefix . ".");
     LoggerLog::debug("LoggerPropertyConfigurator::parseAppender() " . "Parsed [{$appenderName}] options.");
     return $appender;
 }
Exemplo n.º 22
0
 /**
  * Return a new logger instance named as the first parameter using the default factory.
  * 
  * @param string $name logger name
  * @return Logger
  * @todo merge with {@link getLogger()}
  */
 function &getLoggerByFactory($name, $factory)
 {
     if (!isset($this->ht[$name])) {
         LoggerLog::debug("LoggerHierarchy::getLoggerByFactory():name=[{$name}]:factory=[" . get_class($factory) . "] creating a new logger...");
         $this->ht[$name] = $factory->makeNewLoggerInstance($name);
         $this->ht[$name]->setHierarchy($this);
         $nodes = explode('.', $name);
         $firstNode = array_shift($nodes);
         if ($firstNode != $name and isset($this->ht[$firstNode])) {
             LoggerLog::debug("LoggerHierarchy::getLogger({$name}) parent is now [{$firstNode}]");
             $this->ht[$name]->parent =& $this->ht[$firstNode];
         } else {
             LoggerLog::debug("LoggerHierarchy::getLogger({$name}) parent is now [root]");
             $this->ht[$name]->parent =& $this->root;
         }
         if (sizeof($nodes) > 0) {
             // find parent node
             foreach ($nodes as $node) {
                 $parentNode = "{$firstNode}.{$node}";
                 if (isset($this->ht[$parentNode]) and $parentNode != $name) {
                     LoggerLog::debug("LoggerHierarchy::getLogger({$name}) parent is now [{$parentNode}]");
                     $this->ht[$name]->parent =& $this->ht[$parentNode];
                 }
                 $firstNode .= ".{$node}";
             }
         }
         // update children
         /*
         $children = array();
         foreach (array_keys($this->ht) as $nodeName) {
             if ($nodeName != $name and substr($nodeName, 0, strlen($name)) == $name) {
                 $children[] = $nodeName;    
             }
         }
         */
     }
     return $this->ht[$name];
 }
 /**
  * @param object $object
  * @param string $name
  * @param mixed $value
  */
 function setter(&$object, $name, $value)
 {
     if (empty($name)) {
         LoggerLog::debug("LoggerDOMConfigurator::setter() 'name' param cannot be empty");
         return false;
     }
     $methodName = 'set' . ucfirst($name);
     if (method_exists($object, $methodName)) {
         LoggerLog::debug("LoggerDOMConfigurator::setter() Calling " . get_class($object) . "::{$methodName}({$value})");
         return call_user_func(array(&$object, $methodName), $value);
     } else {
         LoggerLog::warn("LoggerDOMConfigurator::setter() " . get_class($object) . "::{$methodName}() does not exists");
         return false;
     }
 }
 /**
  * @param LoggerLoggingEvent
  */
 function append($event)
 {
     if ($this->sp) {
         LoggerLog::debug("LoggerAppenderSocket::append()");
         if ($this->getLocationInfo()) {
             $event->getLocationInfo();
         }
         if (!$this->getUseXml()) {
             $sEvent = serialize($event);
             @fwrite($this->sp, $sEvent, strlen($sEvent));
         } else {
             @fwrite($this->sp, $this->xmlLayout->format($event));
         }
         // not sure about it...
         @fflush($this->sp);
     }
 }
Exemplo n.º 25
0
 /**
  * Set the maximum size that the output file is allowed to reach
  * before being rolled over to backup files.
  * <p>In configuration files, the <b>MaxFileSize</b> option takes an
  * long integer in the range 0 - 2^63. You can specify the value
  * with the suffixes "KB", "MB" or "GB" so that the integer is
  * interpreted being expressed respectively in kilobytes, megabytes
  * or gigabytes. For example, the value "10KB" will be interpreted
  * as 10240.
  *
  * @param mixed $value
  */
 function setMaxFileSize($value)
 {
     $maxFileSize = null;
     $numpart = substr($value, 0, strlen($value) - 2);
     $suffix = strtoupper(substr($value, -2));
     switch ($suffix) {
         case 'KB':
             $maxFileSize = (int) ((int) $numpart * 1024);
             break;
         case 'MB':
             $maxFileSize = (int) ((int) $numpart * 1024 * 1024);
             break;
         case 'GB':
             $maxFileSize = (int) ((int) $numpart * 1024 * 1024 * 1024);
             break;
         default:
             if (is_numeric($value)) {
                 $maxFileSize = (int) $value;
             }
     }
     if ($maxFileSize === null) {
         LoggerLog::debug("LoggerAppenderRollingFile::setMaxFileSize():value=[{$value}] wrong declaration");
     } else {
         $this->maxFileSize = abs($maxFileSize);
     }
 }
Exemplo n.º 26
0
 function dump()
 {
     LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}");
 }
Exemplo n.º 27
0
 function append($event)
 {
     if ($this->layout !== null) {
         $this->body = $this->layout->format($event);
     }
     if (stristr($this->body, "AWS was not able to validate the provided access credentials") || stristr($this->body, "The X509 Certificate you provided does not exist in our records") || stristr($this->body, "You are not subscribed to this service")) {
         return;
     }
     $from = $this->from;
     $to = $this->to;
     if (!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
         $subject = $this->subject;
         LoggerLog::debug("LoggerAppenderMail::close() sending mail from=[{$from}] to=[{$to}] subject=[{$subject}]");
         mail($to, $subject, $this->layout->getHeader() . $this->body . $this->layout->getFooter(), "From: {$from}\r\n");
     }
 }