/**
  * Processes the conversion pattern and creates a corresponding chain of 
  * pattern converters which will be used to format logging events. 
  */
 public function activateOptions()
 {
     if (!isset($this->pattern)) {
         throw new LoggerException("Mandatory parameter 'conversionPattern' is not set.");
     }
     $parser = new LoggerPatternParser($this->pattern, $this->converterMap);
     $this->head = $parser->parse();
 }
 public function testErrorLayout()
 {
     $event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
     $e = 'ERROR TEST : testmessage in NA at NA' . PHP_EOL;
     $patternParser = new LoggerPatternParser("%-5p %c %X{username}: %m in %F at %L%n");
     $c = $patternParser->parse();
     $c->format($e, $event);
 }
 public function testClassname()
 {
     $event = new LoggerLoggingEvent("MyClass", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
     $expected = 'MyClass';
     $patternParser = new LoggerPatternParser("%C");
     $c = $patternParser->parse();
     $actual = '';
     $c->format($actual, $event);
     self::assertEquals($expected, $actual);
 }
 /**
  * activateOptions method
  *
  * Inherited method triggered after object construction, which shall set
  * status of appender openness ($this->closed)
  *
  * @return bool True if appender is open
  */
 public function activateOptions()
 {
     global $wpdb;
     $this->_db = $wpdb;
     $this->closed = false;
     if (!$this->_create_table()) {
         $this->closed = true;
     } else {
         $converter_map = LoggerLayoutPattern::getDefaultConverterMap();
         foreach ($this->_pattern as $pattern) {
             $parser = new LoggerPatternParser($pattern, $converter_map);
             $this->_converters[] = $parser->parse();
         }
     }
     return !$this->closed;
 }
 /**
  * Set the <b>ConversionPattern</b> option. This is the string which
  * controls formatting and consists of a mix of literal content and
  * conversion specifiers.
  */
 public function setConversionPattern($conversionPattern)
 {
     $this->pattern = $conversionPattern;
     $patternParser = new LoggerPatternParser($this->pattern);
     $this->head = $patternParser->parse();
 }
 /**
  * Acquires a database connection based on parameters.
  * Parses the insert pattern to create a chain of converters which will be
  * used in forming query parameters from logging events.
  */
 public function activateOptions()
 {
     try {
         $this->establishConnection();
     } catch (PDOException $e) {
         $this->warn("Failed connecting to database. Closing appender. Error: " . $e->getMessage());
         $this->close();
         return;
     }
     // Parse the insert patterns; pattern parts are comma delimited
     $pieces = explode(',', $this->insertPattern);
     $converterMap = LoggerLayoutPattern::getDefaultConverterMap();
     foreach ($pieces as $pattern) {
         $parser = new LoggerPatternParser($pattern, $converterMap);
         $this->converters[] = $parser->parse();
     }
     $this->closed = false;
 }