You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ih...@apache.org on 2013/11/28 17:03:31 UTC
[01/43] LOG4PHP-121: Reorganized classes into namespaces
Updated Branches:
refs/heads/v3 [created] 75ec90ff5
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/LoggerTest.php
----------------------------------------------------------------------
diff --git a/tests/src/LoggerTest.php b/tests/src/LoggerTest.php
new file mode 100644
index 0000000..a511aa4
--- /dev/null
+++ b/tests/src/LoggerTest.php
@@ -0,0 +1,225 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Logger;
+
+/**
+ * @group main
+ */
+class LoggerTest extends \PHPUnit_Framework_TestCase {
+
+ private $testConfig1 = array (
+ 'rootLogger' => array (
+ 'level' => 'ERROR',
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'appenders' => array (
+ 'default' => array (
+ 'class' => 'EchoAppender',
+ ),
+ ),
+ 'loggers' => array (
+ 'mylogger' => array (
+ 'additivity' => 'false',
+ 'level' => 'DEBUG',
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ ),
+ );
+
+ // For testing additivity
+ private $testConfig2 = array (
+ 'appenders' => array (
+ 'default' => array (
+ 'class' => 'EchoAppender',
+ ),
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'loggers' => array (
+ 'foo' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar.baz' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ ),
+ );
+
+ // For testing additivity
+ private $testConfig3 = array (
+ 'appenders' => array (
+ 'default' => array (
+ 'class' => 'EchoAppender',
+ ),
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'loggers' => array (
+ 'foo' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar.baz' => array (
+ 'level' => 'ERROR',
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ ),
+ );
+
+ protected function setUp() {
+ Logger::clear();
+ Logger::resetConfiguration();
+ }
+
+ protected function tearDown() {
+ Logger::clear();
+ Logger::resetConfiguration();
+ }
+
+ public function testLoggerExist() {
+ $l = Logger::getLogger('test');
+ self::assertEquals($l->getName(), 'test');
+ self::assertTrue(Logger::exists('test'));
+ }
+
+ public function testCanGetRootLogger() {
+ $l = Logger::getRootLogger();
+ self::assertEquals($l->getName(), 'root');
+ }
+
+ public function testCanGetASpecificLogger() {
+ $l = Logger::getLogger('test');
+ self::assertEquals($l->getName(), 'test');
+ }
+
+ public function testCanLogToAllLevels() {
+ Logger::configure($this->testConfig1);
+
+ $logger = Logger::getLogger('mylogger');
+ ob_start();
+ $logger->info('this is an info');
+ $logger->warn('this is a warning');
+ $logger->error('this is an error');
+ $logger->debug('this is a debug message');
+ $logger->fatal('this is a fatal message');
+ $v = ob_get_contents();
+ ob_end_clean();
+
+ $e = 'INFO - this is an info'.PHP_EOL;
+ $e .= 'WARN - this is a warning'.PHP_EOL;
+ $e .= 'ERROR - this is an error'.PHP_EOL;
+ $e .= 'DEBUG - this is a debug message'.PHP_EOL;
+ $e .= 'FATAL - this is a fatal message'.PHP_EOL;
+
+ self::assertEquals($v, $e);
+ }
+
+ public function testIsEnabledFor() {
+ Logger::configure($this->testConfig1);
+
+ $logger = Logger::getLogger('mylogger');
+
+ self::assertFalse($logger->isTraceEnabled());
+ self::assertTrue($logger->isDebugEnabled());
+ self::assertTrue($logger->isInfoEnabled());
+ self::assertTrue($logger->isWarnEnabled());
+ self::assertTrue($logger->isErrorEnabled());
+ self::assertTrue($logger->isFatalEnabled());
+
+ $logger = Logger::getRootLogger();
+
+ self::assertFalse($logger->isTraceEnabled());
+ self::assertFalse($logger->isDebugEnabled());
+ self::assertFalse($logger->isInfoEnabled());
+ self::assertFalse($logger->isWarnEnabled());
+ self::assertTrue($logger->isErrorEnabled());
+ self::assertTrue($logger->isFatalEnabled());
+ }
+
+ public function testGetCurrentLoggers() {
+ Logger::clear();
+ Logger::resetConfiguration();
+
+ self::assertEquals(0, count(Logger::getCurrentLoggers()));
+
+ Logger::configure($this->testConfig1);
+ self::assertEquals(1, count(Logger::getCurrentLoggers()));
+ $list = Logger::getCurrentLoggers();
+ self::assertEquals('mylogger', $list[0]->getName());
+ }
+
+ public function testAdditivity() {
+ Logger::configure($this->testConfig2);
+
+ $logger = Logger::getLogger('foo.bar.baz');
+ ob_start();
+ $logger->info('test');
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ // The message should get logged 4 times: once by every logger in the
+ // hierarchy (including root)
+ $expected = str_repeat('INFO - test' . PHP_EOL, 4);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testAdditivity2() {
+ Logger::configure($this->testConfig3);
+
+ $logger = Logger::getLogger('foo.bar.baz');
+ ob_start();
+ $logger->info('test');
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ // The message should get logged 3 times: once by every logger in the
+ // hierarchy, except foo.bar.baz which is set to level ERROR
+ $expected = str_repeat('INFO - test' . PHP_EOL, 3);
+ self::assertSame($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/LoggingEventTest.php
----------------------------------------------------------------------
diff --git a/tests/src/LoggingEventTest.php b/tests/src/LoggingEventTest.php
new file mode 100644
index 0000000..f07e7c3
--- /dev/null
+++ b/tests/src/LoggingEventTest.php
@@ -0,0 +1,139 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Appenders\NullAppender;
+use Apache\Log4php\Layouts\AbstractLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+class LoggingEventTestCaseAppender extends NullAppender {
+
+ protected $requiresLayout = true;
+
+ public function append(LoggingEvent $event) {
+ $this->layout->format($event);
+ }
+}
+
+class LoggingEventTestCaseLayout extends AbstractLayout {
+
+ public function activateOptions() {
+ return;
+ }
+
+ public function format(LoggingEvent $event) {
+ LoggingEventTest::$locationInfo = $event->getLocationInformation();
+ LoggingEventTest::$throwableInfo = $event->getThrowableInformation();
+ }
+}
+
+/**
+ * @group main
+ */
+class LoggingEventTest extends \PHPUnit_Framework_TestCase {
+
+ public static $locationInfo;
+ public static $throwableInfo;
+
+ public function testConstructWithLoggerName() {
+ $l = Level::getLevelDebug();
+ $e = new LoggingEvent('fqcn', 'TestLogger', $l, 'test');
+ self::assertEquals($e->getLoggerName(), 'TestLogger');
+ }
+
+ public function testConstructWithTimestamp() {
+ $l = Level::getLevelDebug();
+ $timestamp = microtime(true);
+ $e = new LoggingEvent('fqcn', 'TestLogger', $l, 'test', $timestamp);
+ self::assertEquals($e->getTimeStamp(), $timestamp);
+ }
+
+ public function testGetStartTime() {
+ $time = LoggingEvent::getStartTime();
+ self::assertInternalType('float', $time);
+ $time2 = LoggingEvent::getStartTime();
+ self::assertEquals($time, $time2);
+ }
+
+ public function testGetLocationInformation() {
+ $hierarchy = Logger::getHierarchy();
+ $root = $hierarchy->getRootLogger();
+
+ $a = new LoggingEventTestCaseAppender('A1');
+ $a->setLayout(new LoggingEventTestCaseLayout());
+ $root->addAppender($a);
+
+ $logger = $hierarchy->getLogger('test');
+
+ $line = __LINE__; $logger->debug('test');
+ $hierarchy->shutdown();
+
+ $li = self::$locationInfo;
+
+ self::assertEquals(get_class($this), $li->getClassName());
+ self::assertEquals(__FILE__, $li->getFileName());
+ self::assertEquals($line, $li->getLineNumber());
+ self::assertEquals(__FUNCTION__, $li->getMethodName());
+ }
+
+ public function testGetThrowableInformation1() {
+ $hierarchy = Logger::getHierarchy();
+ $root = $hierarchy->getRootLogger();
+
+ $a = new LoggingEventTestCaseAppender('A1');
+ $a->setLayout( new LoggingEventTestCaseLayout() );
+ $root->addAppender($a);
+
+ $logger = $hierarchy->getLogger('test');
+ $logger->debug('test');
+ $hierarchy->shutdown();
+
+ $ti = self::$throwableInfo;
+
+ self::assertEquals($ti, null);
+ }
+
+ public function testGetThrowableInformation2() {
+ $hierarchy = Logger::getHierarchy();
+ $root = $hierarchy->getRootLogger();
+
+ $a = new LoggingEventTestCaseAppender('A1');
+ $a->setLayout( new LoggingEventTestCaseLayout() );
+ $root->addAppender($a);
+
+ $ex = new \Exception('Message1');
+ $logger = $hierarchy->getLogger('test');
+ $logger->debug('test', $ex);
+ $hierarchy->shutdown();
+
+ $ti = self::$throwableInfo;
+
+ self::assertInstanceOf("Apache\\Log4php\\ThrowableInformation", $ti);
+
+ $result = $ti->getStringRepresentation();
+ self::assertInternalType('array', $result);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/MDCTest.php
----------------------------------------------------------------------
diff --git a/tests/src/MDCTest.php b/tests/src/MDCTest.php
new file mode 100644
index 0000000..0d33383
--- /dev/null
+++ b/tests/src/MDCTest.php
@@ -0,0 +1,119 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\MDC;
+use Apache\Log4php\Layouts\PatternLayout;
+
+/**
+ * @group main
+ */
+class MDCTest extends \PHPUnit_Framework_TestCase {
+
+ /** A pattern with 1 key. */
+ private $pattern1 = "%-5p %c: %X{key1} %m";
+
+ /** A pattern with 2 keys. */
+ private $pattern2 = "%-5p %c: %X{key1} %X{key2} %m";
+
+ /** A pattern with 3 keys (one is numeric). */
+ private $pattern3 = "%-5p %c: %X{key1} %X{key2} %X{3} %m";
+
+ /** A pattern with a non-existant key. */
+ private $pattern4 = "%-5p %c: %X{key_does_not_exist} %m";
+
+ /** A pattern without a key. */
+ private $pattern5 = "%-5p %c: %X %m";
+
+ protected function setUp() {
+ MDC::clear();
+ }
+
+ protected function tearDown() {
+ MDC::clear();
+ }
+
+ public function testPatterns() {
+
+ // Create some data to test with
+ MDC::put('key1', 'valueofkey1');
+ MDC::put('key2', 'valueofkey2');
+ MDC::put(3, 'valueofkey3');
+
+ $expected = array(
+ 'key1' => 'valueofkey1',
+ 'key2' => 'valueofkey2',
+ 3 => 'valueofkey3',
+ );
+ $actual = MDC::getMap();
+
+ self::assertSame($expected, $actual);
+
+ $event = TestHelper::getInfoEvent("Test message");
+
+ // Pattern with 1 key
+ $actual = $this->formatEvent($event, $this->pattern1);
+ $expected = "INFO test: valueofkey1 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with 2 keys
+ $actual = $this->formatEvent($event, $this->pattern2);
+ $expected = "INFO test: valueofkey1 valueofkey2 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with 3 keys (one numeric)
+ $actual = $this->formatEvent($event, $this->pattern3);
+ $expected = "INFO test: valueofkey1 valueofkey2 valueofkey3 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with non-existant key
+ $actual = $this->formatEvent($event, $this->pattern4);
+ $expected = "INFO test: Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with an empty key
+ $actual = $this->formatEvent($event, $this->pattern5);
+ $expected = "INFO test: key1=valueofkey1, key2=valueofkey2, 3=valueofkey3 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Test key removal
+ MDC::remove('key1');
+ $value = MDC::get('key1');
+ self::assertEquals('', $value);
+
+ // Pattern with 1 key, now removed
+ $actual = $this->formatEvent($event, $this->pattern1);
+ $expected = "INFO test: Test message";
+ self::assertEquals($expected, $actual);
+ }
+
+ private function formatEvent($event, $pattern) {
+ $layout = new PatternLayout();
+ $layout->setConversionPattern($pattern);
+ $layout->activateOptions();
+ return $layout->format($event);
+ }
+}
+
+?>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/NDCTest.php
----------------------------------------------------------------------
diff --git a/tests/src/NDCTest.php b/tests/src/NDCTest.php
new file mode 100644
index 0000000..b65b822
--- /dev/null
+++ b/tests/src/NDCTest.php
@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\NDC;
+
+/**
+ * @group main
+ */
+class NDCTest extends \PHPUnit_Framework_TestCase {
+
+ public function testItemHandling()
+ {
+ // Test the empty stack
+ self::assertSame('', NDC::get());
+ self::assertSame('', NDC::peek());
+ self::assertSame(0, NDC::getDepth());
+ self::assertSame('', NDC::pop());
+
+ // Add some data to the stack
+ NDC::push('1');
+ NDC::push('2');
+ NDC::push('3');
+
+ self::assertSame('1 2 3', NDC::get());
+ self::assertSame('3', NDC::peek());
+ self::assertSame(3, NDC::getDepth());
+
+ // Remove last item
+ self::assertSame('3', NDC::pop());
+ self::assertSame('1 2', NDC::get());
+ self::assertSame('2', NDC::peek());
+ self::assertSame(2, NDC::getDepth());
+
+ // Remove all items
+ NDC::remove();
+
+ // Test the empty stack
+ self::assertSame('', NDC::get());
+ self::assertSame('', NDC::peek());
+ self::assertSame(0, NDC::getDepth());
+ self::assertSame('', NDC::pop());
+ }
+
+ public function testMaxDepth()
+ {
+ // Clear stack; add some testing data
+ NDC::clear();
+ NDC::push('1');
+ NDC::push('2');
+ NDC::push('3');
+ NDC::push('4');
+ NDC::push('5');
+ NDC::push('6');
+
+ self::assertSame('1 2 3 4 5 6', NDC::get());
+
+ // Edge case, should not change stack
+ NDC::setMaxDepth(6);
+ self::assertSame('1 2 3 4 5 6', NDC::get());
+ self::assertSame(6, NDC::getDepth());
+
+ NDC::setMaxDepth(3);
+ self::assertSame('1 2 3', NDC::get());
+ self::assertSame(3, NDC::getDepth());
+
+ NDC::setMaxDepth(0);
+ self::assertSame('', NDC::get());
+ self::assertSame(0, NDC::getDepth());
+ }
+}
+
+?>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Pattern/PatternConverterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Pattern/PatternConverterTest.php b/tests/src/Pattern/PatternConverterTest.php
new file mode 100644
index 0000000..e491dba
--- /dev/null
+++ b/tests/src/Pattern/PatternConverterTest.php
@@ -0,0 +1,415 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Pattern;
+
+use Apache\Log4php\Helpers\FormattingInfo;
+use Apache\Log4php\Logger;
+use Apache\Log4php\MDC;
+use Apache\Log4php\NDC;
+
+use Apache\Log4php\Pattern\ClassConverter;
+use Apache\Log4php\Pattern\CookieConverter;
+use Apache\Log4php\Pattern\DateConverter;
+use Apache\Log4php\Pattern\EnvironmentConverter;
+use Apache\Log4php\Pattern\FileConverter;
+use Apache\Log4php\Pattern\LevelConverter;
+use Apache\Log4php\Pattern\LineConverter;
+use Apache\Log4php\Pattern\LiteralConverter;
+use Apache\Log4php\Pattern\LocationConverter;
+use Apache\Log4php\Pattern\LoggerConverter;
+use Apache\Log4php\Pattern\MdcConverter;
+use Apache\Log4php\Pattern\MessageConverter;
+use Apache\Log4php\Pattern\MethodConverter;
+use Apache\Log4php\Pattern\NdcConverter;
+use Apache\Log4php\Pattern\NewLineConverter;
+use Apache\Log4php\Pattern\ProcessConverter;
+use Apache\Log4php\Pattern\RelativeConverter;
+use Apache\Log4php\Pattern\RequestConverter;
+use Apache\Log4php\Pattern\ServerConverter;
+use Apache\Log4php\Pattern\SessionConverter;
+use Apache\Log4php\Pattern\SessionIdConverter;
+use Apache\Log4php\Pattern\SuperglobalConverter;
+use Apache\Log4php\Pattern\ThrowableConverter;
+
+
+use Apache\Log4php\Tests\TestHelper;
+
+/** Converter referencing non-existant superglobal variable. */
+class InvalidSuperglobalConverter extends SuperglobalConverter {
+ protected $name = '_FOO';
+}
+
+/**
+ * @group pattern
+ */
+class PatternConverterTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * A logging event for testing.
+ * @var LoggingEvent
+ */
+ private $event;
+
+ /**
+ * Fromatting info used with the logging event.
+ * @var LoggerFormattingInfos
+ */
+ private $info;
+
+ public function __construct() {
+ $this->event = TestHelper::getInfoEvent('foobar');
+ $this->info = new FormattingInfo();
+ }
+
+ public function testCookie() {
+ // Fake a couple of cookies
+ $_COOKIE['test1'] = 'value1';
+ $_COOKIE['test2'] = 'value2';
+
+ $converter = new CookieConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+
+ $converter = new CookieConverter($this->info, 'test2');
+ $actual = $converter->convert($this->event);
+ $expected = 'value2';
+ self::assertSame($expected, $actual);
+
+ $converter = new CookieConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = "test1=value1, test2=value2";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testDate() {
+ $converter = new DateConverter($this->info, 'c');
+ $actual = $converter->convert($this->event);
+ $expected = date('c', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ // Format defaults to 'c'
+ $converter = new DateConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = date('c', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ $converter = new DateConverter($this->info, '');
+ $actual = $converter->convert($this->event);
+ $expected = date('c', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ // Test ABSOLUTE
+ $converter = new DateConverter($this->info, 'ABSOLUTE');
+ $actual = $converter->convert($this->event);
+ $expected = date('H:i:s', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ // Test DATE
+ $converter = new DateConverter($this->info, 'DATE');
+ $actual = $converter->convert($this->event);
+ $expected = date('d M Y H:i:s.', $this->event->getTimeStamp());
+
+ $timestamp = $this->event->getTimeStamp();
+ $ms = floor(($timestamp - floor($timestamp)) * 1000);
+ $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
+
+ $expected .= $ms;
+
+ self::assertSame($expected, $actual);
+ }
+
+ public function testEnvironment() {
+ // Fake a couple of environment values
+ $_ENV['test1'] = 'value1';
+ $_ENV['test2'] = 'value2';
+
+ $converter = new EnvironmentConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+
+ $converter = new EnvironmentConverter($this->info, 'test2');
+ $actual = $converter->convert($this->event);
+ $expected = 'value2';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testLevel() {
+ $converter = new LevelConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = $this->event->getLevel()->toString();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLiteral() {
+ $converter = new LiteralConverter('foo bar baz');
+ $actual = $converter->convert($this->event);
+ $expected = 'foo bar baz';
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLoggerWithoutOption() {
+ $event = TestHelper::getInfoEvent('foo', 'TestLoggerName');
+ $converter = new LoggerConverter($this->info);
+
+ $actual = $converter->convert($event);
+ $expected = 'TestLoggerName';
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLoggerWithOption0() {
+ $event = TestHelper::getInfoEvent('foo', 'TestLoggerName');
+ $converter = new LoggerConverter($this->info, '0');
+
+ $actual = $converter->convert($event);
+ $expected = 'TestLoggerName';
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLocation() {
+ $config = TestHelper::getEchoPatternConfig("%file:%line:%class:%method");
+ Logger::configure($config);
+
+ // Test by capturing output. Logging methods of a Logger object must
+ // be used for the location info to be formed correctly.
+ ob_start();
+ $log = Logger::getLogger('foo');
+ $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $expected = implode(':', array(__FILE__, $line, __CLASS__, __FUNCTION__));
+ self::assertSame($expected, $actual);
+
+ Logger::resetConfiguration();
+ }
+
+ public function testLocation2() {
+ $config = TestHelper::getEchoPatternConfig("%location");
+ Logger::configure($config);
+
+ // Test by capturing output. Logging methods of a Logger object must
+ // be used for the location info to be formed correctly.
+ ob_start();
+ $log = Logger::getLogger('foo');
+ $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $class = __CLASS__;
+ $func = __FUNCTION__;
+ $file = __FILE__;
+
+ $expected = "$class.$func($file:$line)";
+ self::assertSame($expected, $actual);
+
+ Logger::resetConfiguration();
+ }
+
+ public function testMessage() {
+ $expected = "This is a message.";
+ $event = TestHelper::getInfoEvent($expected);
+ $converter = new MessageConverter($this->info);
+ $actual = $converter->convert($event);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testMDC() {
+ MDC::put('foo', 'bar');
+ MDC::put('bla', 'tra');
+
+ // Entire context
+ $converter = new MdcConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = 'foo=bar, bla=tra';
+ self::assertSame($expected, $actual);
+
+ // Just foo
+ $converter = new MdcConverter($this->info, 'foo');
+ $actual = $converter->convert($this->event);
+ $expected = 'bar';
+ self::assertSame($expected, $actual);
+
+ // Non existant key
+ $converter = new MdcConverter($this->info, 'doesnotexist');
+ $actual = $converter->convert($this->event);
+ $expected = '';
+ self::assertSame($expected, $actual);
+
+ MDC::clear();
+ }
+
+ public function testNDC() {
+ NDC::push('foo');
+ NDC::push('bar');
+ NDC::push('baz');
+
+ $converter = new NdcConverter($this->info);
+ $expected = 'foo bar baz';
+ $actual = $converter->convert($this->event);
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testNewline() {
+ $converter = new NewLineConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = PHP_EOL;
+ self::assertSame($expected, $actual);
+ }
+
+ public function testProcess() {
+ $converter = new ProcessConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = getmypid();
+ self::assertSame($expected, $actual);
+ }
+
+ public function testRelative() {
+ $converter = new RelativeConverter($this->info);
+ $expected = number_format($this->event->getTimeStamp() - $this->event->getStartTime(), 4);
+ $actual = $converter->convert($this->event);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testRequest() {
+ // Fake a couple of request values
+ $_REQUEST['test1'] = 'value1';
+ $_REQUEST['test2'] = 'value2';
+
+ // Entire request
+ $converter = new RequestConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = 'test1=value1, test2=value2';
+ self::assertSame($expected, $actual);
+
+ // Just test2
+ $converter = new RequestConverter($this->info, 'test2');
+ $actual = $converter->convert($this->event);
+ $expected = 'value2';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testServer() {
+ // Fake a server value
+ $_SERVER['test1'] = 'value1';
+
+ $converter = new ServerConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testSession() {
+ // Fake a session value
+ $_SESSION['test1'] = 'value1';
+
+ $converter = new SessionConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testSessionID() {
+ $converter = new SessionIdConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = session_id();
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: InvalidSuperglobalConverter: Cannot find superglobal variable $_FOO
+ */
+ public function testNonexistantSuperglobal() {
+ $converter = new InvalidSuperglobalConverter($this->info);
+ $actual = $converter->convert($this->event);
+ }
+
+ public function testFormattingTrimRight() {
+ $event = TestHelper::getInfoEvent('0123456789');
+
+ $info = new FormattingInfo();
+ $info->max = 5;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = "01234";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingTrimLeft() {
+ $event = TestHelper::getInfoEvent('0123456789');
+
+ $info = new FormattingInfo();
+ $info->max = 5;
+ $info->trimLeft = true;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = "56789";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingPadEmpty() {
+ $event = TestHelper::getInfoEvent('');
+
+ $info = new FormattingInfo();
+ $info->min = 5;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = " ";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingPadLeft() {
+ $event = TestHelper::getInfoEvent('0');
+
+ $info = new FormattingInfo();
+ $info->min = 5;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = " 0";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingPadRight() {
+ $event = TestHelper::getInfoEvent('0');
+
+ $info = new FormattingInfo();
+ $info->min = 5;
+ $info->padLeft = false;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = "0 ";
+ self::assertSame($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/README
----------------------------------------------------------------------
diff --git a/tests/src/README b/tests/src/README
new file mode 100644
index 0000000..693e23e
--- /dev/null
+++ b/tests/src/README
@@ -0,0 +1,19 @@
+All tests can be run from the root of the package by running:
+$ phpunit
+
+Tests classes are divided into groups which can be run individually:
+$ phpunit --group main
+$ phpunit --group appenders
+$ phpunit --group configurators
+$ phpunit --group filters
+$ phpunit --group helpers
+$ phpunit --group layouts
+$ phpunit --group renderers
+
+Individual test classes can be run using e.g.:
+$ phpunit src/test/php/appenders/LoggerAppenderSocketTest.php
+
+Do not use relative file paths in the tests. Absoulte paths may be constructed
+using snippets like:
+* dirname(__FILE__) . '/../path/to/file'
+* PHPUNIT_TEMP_DIR . '/../path/to/file'
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/ReflectionUtilsTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ReflectionUtilsTest.php b/tests/src/ReflectionUtilsTest.php
new file mode 100644
index 0000000..2357657
--- /dev/null
+++ b/tests/src/ReflectionUtilsTest.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\ReflectionUtils;
+
+class Simple {
+ private $name;
+ private $male;
+
+ public function getName() {
+ return $this->name;
+ }
+
+ public function isMale() {
+ return $this->male;
+ }
+
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ public function setMale($male) {
+ $this->male = $male;
+ }
+}
+
+/**
+ * @group main
+ */
+class ReflectionUtilsTest extends \PHPUnit_Framework_TestCase {
+
+ public function testSimpleSet() {
+ $s = new Simple();
+ $ps = new ReflectionUtils($s);
+ $ps->setProperty("name", "Joe");
+ $ps->setProperty("male", true);
+
+ $this->assertEquals($s->isMale(), true);
+ $this->assertEquals($s->getName(), 'Joe');
+ }
+
+ public function testSimpleArraySet() {
+ $arr['xxxname'] = 'Joe';
+ $arr['xxxmale'] = true;
+
+ $s = new Simple();
+ $ps = new ReflectionUtils($s);
+ $ps->setProperties($arr, "xxx");
+
+ $this->assertEquals($s->getName(), 'Joe');
+ $this->assertEquals($s->isMale(), true);
+ }
+
+ public function testStaticArraySet() {
+ $arr['xxxname'] = 'Joe';
+ $arr['xxxmale'] = true;
+
+ $s = new Simple();
+ ReflectionUtils::setPropertiesByObject($s,$arr,"xxx");
+
+ $this->assertEquals($s->getName(), 'Joe');
+ $this->assertEquals($s->isMale(), true);
+ }
+ public function testCreateObject() {
+ $class = 'Apache\\Log4php\\Layouts\\SimpleLayout';
+ $object = ReflectionUtils::createObject($class);
+ $name = get_class($object);
+ self::assertEquals($name, $class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Renderers/RendererMapTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Renderers/RendererMapTest.php b/tests/src/Renderers/RendererMapTest.php
new file mode 100644
index 0000000..3960660
--- /dev/null
+++ b/tests/src/Renderers/RendererMapTest.php
@@ -0,0 +1,249 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+use Apache\Log4php\Renderers\RendererInterface;
+use Apache\Log4php\Renderers\RendererMap;
+use Apache\Log4php\Renderers\DefaultRenderer;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggerException;
+
+/** Renders everything as 'foo'. */
+class FooRenderer implements RendererInterface {
+ public function render($input) {
+ return 'foo';
+ }
+}
+
+class InvalidCostumObjectRenderer { }
+
+class Fruit3 {
+ public $test1 = 'test1';
+ public $test2 = 'test2';
+ public $test3 = 'test3';
+}
+
+class Fruit3Descendant extends Fruit3 {
+}
+
+class FruitRenderer3 implements RendererInterface {
+ public function render($fruit) {
+ return $fruit->test1 . ',' . $fruit->test2 . ',' . $fruit->test3;
+ }
+}
+
+class SampleObject {
+}
+
+/**
+ * @group renderers
+ */
+class RendererMapTest extends \PHPUnit_Framework_TestCase {
+
+ public function testDefaults() {
+
+ $map = new RendererMap();
+ $actual = $map->getByClassName('Exception');
+ $expected = 'Apache\\Log4php\\Renderers\\ExceptionRenderer';
+ self::assertInstanceOf($expected, $actual);
+
+ // Check non-configured objects return null
+ self::assertNull($map->getByObject(new stdClass()));
+ self::assertNull($map->getByClassName('stdClass'));
+ }
+
+ public function testClear()
+ {
+ $map = new RendererMap();
+ $map->clear(); // This should clear the map and remove default renderers
+ self::assertNull($map->getByClassName('Exception'));
+ }
+
+ public function testFindAndRender()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'FruitRenderer3');
+
+ $fruit = new Fruit3();
+ $descendant = new Fruit3Descendant();
+
+ // Check rendering of fruit
+ $actual = $map->findAndRender($fruit);
+ $expected = 'test1,test2,test3';
+ self::assertSame($expected, $actual);
+
+ $actual = $map->getByObject($fruit);
+ self::assertInstanceOf('FruitRenderer3', $actual);
+
+ // Check rendering of fruit's descendant
+ $actual = $map->findAndRender($descendant);
+ $expected = 'test1,test2,test3';
+ self::assertSame($expected, $actual);
+
+ $actual = $map->getByObject($descendant);
+ self::assertInstanceOf('FruitRenderer3', $actual);
+
+ // Test rendering null returns null
+ self::assertNull($map->findAndRender(null));
+ }
+
+ /**
+ * Try adding a non-existant class as renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExist] not found.
+ */
+ public function testAddRendererError1()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'DoesNotExist');
+ }
+
+ /**
+ * Try adding a class which does not implement RendererInterface as renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ */
+ public function testAddRendererError2()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'stdClass');
+ }
+
+ public function testAddRendererError3()
+ {
+ $map = new RendererMap();
+ @$map->addRenderer('Fruit3', 'stdClass');
+ self::assertNull($map->getByClassName('Fruit3'));
+
+ @$map->addRenderer('Fruit3', 'DoesNotExist');
+ self::assertNull($map->getByClassName('Fruit3'));
+ }
+
+ /**
+ * Try setting a non-existant class as default renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed setting default renderer. Rendering class [DoesNotExist] not found.
+ */
+ public function testSetDefaultRendererError1()
+ {
+ $map = new RendererMap();
+ $map->setDefaultRenderer('DoesNotExist');
+ }
+
+ /**
+ * Try setting a class which does not implement RendererInterface as default renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed setting default renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ */
+ public function testSetDefaultRendererError2()
+ {
+ $map = new RendererMap();
+ $map->setDefaultRenderer('stdClass');
+ }
+
+ public function testSetDefaultRendererError3()
+ {
+ $map = new RendererMap();
+ $expected = $map->getDefaultRenderer();
+
+ @$map->setDefaultRenderer('stdClass');
+ $actual = $map->getDefaultRenderer();
+ self::assertSame($expected, $actual);
+
+ @$map->setDefaultRenderer('DoesNotExist');
+ $actual = $map->getDefaultRenderer();
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFetchingRenderer()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'FruitRenderer3');
+ }
+
+ public function testDefaultRenderer()
+ {
+ $fruit = new Fruit3();
+
+ $map = new RendererMap();
+ $actual = $map->findAndRender($fruit);
+
+ $defaultRenderer = new DefaultRenderer();
+ $expected = $defaultRenderer->render($fruit);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testOverrideDefaultRenderer()
+ {
+ $map = new RendererMap();
+ $default = $map->getDefaultRenderer();
+
+ $array = array(1, 2, 3);
+
+ $actual = $map->findAndRender($array);
+ $expected = print_r($array, true);
+ self::assertSame($actual, $expected);
+
+ // Now switch the default renderer
+ $map->setDefaultRenderer('FooRenderer');
+ $actual = $map->findAndRender($array);
+ $expected = 'foo';
+ self::assertSame($actual, $expected);
+ }
+
+ public function testGetByObjectCrap()
+ {
+ $map = new RendererMap();
+
+ // Non object input should always return null
+ self::assertNull($map->getByObject(null));
+ self::assertNull($map->getByObject(array()));
+ self::assertNull($map->getByObject('sdasda'));
+ }
+
+ public function testXMLConfig()
+ {
+ $map = Logger::getHierarchy()->getRendererMap();
+ Logger::resetConfiguration();
+
+ $expected = 'Apache\\Log4php\\Renderers\\DefaultRenderer';
+ self::assertInstanceOf($expected, $map->getDefaultRenderer());
+
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_default_renderer.xml');
+ self::assertInstanceOf('FruitRenderer3', $map->getDefaultRenderer());
+
+ Logger::resetConfiguration();
+ self::assertInstanceOf($expected, $map->getDefaultRenderer());
+ }
+
+ public function testExceptionRenderer()
+ {
+ $ex = new LoggerException("This is a test");
+
+ $map = new RendererMap();
+ $actual = $map->findAndRender($ex);
+ $expected = (string) $ex;
+
+ self::assertSame($expected, $actual);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/RootLoggerTest.php
----------------------------------------------------------------------
diff --git a/tests/src/RootLoggerTest.php b/tests/src/RootLoggerTest.php
new file mode 100644
index 0000000..aa6429e
--- /dev/null
+++ b/tests/src/RootLoggerTest.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\RootLogger;
+
+/**
+ * @group main
+ */
+class RootLoggerTest extends \PHPUnit_Framework_TestCase {
+
+ public function testInitialSetup() {
+ $root = new RootLogger();
+ self::assertSame(Level::getLevelAll(), $root->getLevel());
+ self::assertSame(Level::getLevelAll(), $root->getEffectiveLevel());
+ self::assertSame('root', $root->getName());
+ self::assertNull($root->getParent());
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: RootLogger cannot have a parent.
+ */
+ public function testSetParentWarning() {
+ $root = new RootLogger();
+ $logger = new Logger('test');
+ $root->setParent($logger);
+ }
+
+ public function testSetParentResult() {
+ $root = new RootLogger();
+ $logger = new Logger('test');
+ @$root->setParent($logger);
+ self::assertNull($root->getParent());
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Cannot set RootLogger level to null.
+ */
+ public function testNullLevelWarning() {
+ $root = new RootLogger();
+ $root->setLevel(null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/TestHelper.php
----------------------------------------------------------------------
diff --git a/tests/src/TestHelper.php b/tests/src/TestHelper.php
new file mode 100644
index 0000000..c653eca
--- /dev/null
+++ b/tests/src/TestHelper.php
@@ -0,0 +1,160 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/** A set of helper functions for running tests. */
+class TestHelper {
+
+ /**
+ * Returns a test logging event with level set to TRACE.
+ * @return LoggingEvent
+ */
+ public static function getTraceEvent($message = 'test', $logger = "test") {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelTrace(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to DEBUG.
+ * @return LoggingEvent
+ */
+ public static function getDebugEvent($message = 'test', $logger = "test") {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelDebug(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to INFO.
+ * @return LoggingEvent
+ */
+ public static function getInfoEvent($message = 'test', $logger = "test") {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelInfo(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to WARN.
+ * @return LoggingEvent
+ */
+ public static function getWarnEvent($message = 'test', $logger = "test") {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelWarn(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to ERROR.
+ * @return LoggingEvent
+ */
+ public static function getErrorEvent($message = 'test', $logger = "test") {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelError(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to FATAL.
+ * @return LoggingEvent
+ */
+ public static function getFatalEvent($message = 'test', $logger = "test") {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelFatal(), $message);
+ }
+
+ /**
+ * Returns an array of logging events, one for each level, sorted ascending
+ * by severitiy.
+ */
+ public static function getAllEvents($message = 'test') {
+ return array(
+ self::getTraceEvent($message),
+ self::getDebugEvent($message),
+ self::getInfoEvent($message),
+ self::getWarnEvent($message),
+ self::getErrorEvent($message),
+ self::getFatalEvent($message),
+ );
+ }
+
+ /** Returns an array of all existing levels, sorted ascending by severity. */
+ public static function getAllLevels() {
+ return array(
+ Level::getLevelTrace(),
+ Level::getLevelDebug(),
+ Level::getLevelInfo(),
+ Level::getLevelWarn(),
+ Level::getLevelError(),
+ Level::getLevelFatal(),
+ );
+ }
+
+ /** Returns a string representation of a filter decision. */
+ public static function decisionToString($decision) {
+ switch($decision) {
+ case AbstractFilter::ACCEPT: return 'ACCEPT';
+ case AbstractFilter::NEUTRAL: return 'NEUTRAL';
+ case AbstractFilter::DENY: return 'DENY';
+ }
+ }
+
+ /** Returns a simple configuration with one echo appender tied to root logger. */
+ public static function getEchoConfig() {
+ return array(
+ 'threshold' => 'ALL',
+ 'rootLogger' => array(
+ 'level' => 'trace',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout',
+ ),
+ ),
+ ),
+ );
+ }
+
+ /** Returns a simple configuration with one echo appender using the pattern layout. */
+ public static function getEchoPatternConfig($pattern) {
+ return array(
+ 'threshold' => 'ALL',
+ 'rootLogger' => array(
+ 'level' => 'trace',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => $pattern
+ )
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/ThrowableInformationTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ThrowableInformationTest.php b/tests/src/ThrowableInformationTest.php
new file mode 100644
index 0000000..9d230da
--- /dev/null
+++ b/tests/src/ThrowableInformationTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\ThrowableInformation;
+
+class ThrowableInformationTestException extends \Exception { }
+
+/**
+ * @group main
+ */
+class ThrowableInformationTest extends \PHPUnit_Framework_TestCase {
+
+ public function testConstructor() {
+ $ex = new \Exception();
+ $tInfo = new ThrowableInformation($ex);
+
+ $result = $tInfo->getStringRepresentation();
+ $this->assertInternalType('array', $result);
+ }
+
+ public function testExceptionChain() {
+ $ex1 = new ThrowableInformationTestException('Message1');
+ $ex2 = new ThrowableInformationTestException('Message2', 0, $ex1);
+ $ex3 = new ThrowableInformationTestException('Message3', 0, $ex2);
+
+ $tInfo = new ThrowableInformation($ex3);
+ $result = $tInfo->getStringRepresentation();
+ $this->assertInternalType('array', $result);
+ }
+
+ public function testGetThrowable() {
+ $ex = new ThrowableInformationTestException('Message1');
+ $tInfo = new ThrowableInformation($ex);
+ $result = $tInfo->getThrowable();
+ $this->assertEquals($ex, $result);
+ }
+}
[40/43] git commit: Added @license tag to all source files
Posted by ih...@apache.org.
Added @license tag to all source files
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/dfa21323
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/dfa21323
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/dfa21323
Branch: refs/heads/v3
Commit: dfa21323fc82ff903c0bafbb315d472d2a9a9401
Parents: 759cd15
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 14:45:57 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 14:45:57 2013 +0100
----------------------------------------------------------------------
src/AppenderPool.php | 3 +++
src/Appenders/AbstractAppender.php | 3 +++
src/Autoloader.php | 3 +++
src/Configurable.php | 1 +
src/Filters/AbstractFilter.php | 2 ++
src/Filters/DenyAllFilter.php | 1 +
src/Filters/LevelMatchFilter.php | 2 ++
src/Filters/LevelRangeFilter.php | 1 +
src/Filters/StringMatchFilter.php | 2 ++
src/Helpers/FormattingInfo.php | 2 ++
src/Helpers/OptionConverter.php | 2 ++
src/Helpers/PatternParser.php | 1 +
src/Helpers/Utils.php | 2 ++
src/Hierarchy.php | 3 +++
src/Layouts/AbstractLayout.php | 2 ++
src/Layouts/HtmlLayout.php | 2 ++
src/Layouts/PatternLayout.php | 2 ++
src/Layouts/SerializedLayout.php | 2 ++
src/Layouts/SimpleLayout.php | 2 ++
src/Layouts/XmlLayout.php | 1 +
src/Level.php | 3 +++
src/LocationInfo.php | 3 +++
src/Logger.php | 2 +-
src/LoggerException.php | 3 +++
src/LoggingEvent.php | 3 +++
src/MDC.php | 3 ++-
src/NDC.php | 2 ++
src/Pattern/AbstractConverter.php | 2 ++
src/Pattern/ClassConverter.php | 2 ++
src/Pattern/CookieConverter.php | 1 +
src/Pattern/DateConverter.php | 2 ++
src/Pattern/EnvironmentConverter.php | 2 +-
src/Pattern/FileConverter.php | 2 ++
src/Pattern/LevelConverter.php | 2 ++
src/Pattern/LineConverter.php | 2 ++
src/Pattern/LiteralConverter.php | 2 ++
src/Pattern/LocationConverter.php | 2 ++
src/Pattern/LoggerConverter.php | 2 ++
src/Pattern/MdcConverter.php | 2 ++
src/Pattern/MessageConverter.php | 2 ++
src/Pattern/MethodConverter.php | 2 ++
src/Pattern/NdcConverter.php | 2 ++
src/Pattern/NewLineConverter.php | 2 ++
src/Pattern/ProcessConverter.php | 2 ++
src/Pattern/RelativeConverter.php | 2 ++
src/Pattern/RequestConverter.php | 2 +-
src/Pattern/ServerConverter.php | 2 +-
src/Pattern/SessionConverter.php | 2 +-
src/Pattern/SessionIdConverter.php | 2 ++
src/Pattern/SuperglobalConverter.php | 1 +
src/Pattern/ThrowableConverter.php | 2 ++
src/ReflectionUtils.php | 3 +++
src/Renderers/DefaultRenderer.php | 2 ++
src/Renderers/ExceptionRenderer.php | 2 ++
src/Renderers/RendererInterface.php | 2 ++
src/Renderers/RendererMap.php | 2 ++
src/RootLogger.php | 4 +++-
src/ThrowableInformation.php | 2 ++
58 files changed, 114 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/AppenderPool.php
----------------------------------------------------------------------
diff --git a/src/AppenderPool.php b/src/AppenderPool.php
index 92f9455..abcb698 100644
--- a/src/AppenderPool.php
+++ b/src/AppenderPool.php
@@ -27,6 +27,9 @@ use Apache\Log4php\Appenders\AbstractAppender;
* are created in the pool. Afterward, they are linked to loggers, each
* appender can be linked to multiple loggers. This makes sure duplicate
* appenders are not created.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class AppenderPool
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Appenders/AbstractAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/AbstractAppender.php b/src/Appenders/AbstractAppender.php
index 52ffe07..e772b21 100644
--- a/src/Appenders/AbstractAppender.php
+++ b/src/Appenders/AbstractAppender.php
@@ -25,6 +25,9 @@ use Apache\Log4php\LoggingEvent;
/**
* Abstract class that defines output logs strategies.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
abstract class AbstractAppender extends Configurable
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Autoloader.php
----------------------------------------------------------------------
diff --git a/src/Autoloader.php b/src/Autoloader.php
index d4fc666..b193c71 100644
--- a/src/Autoloader.php
+++ b/src/Autoloader.php
@@ -20,6 +20,9 @@ namespace Apache\Log4php;
/**
* PSR-4 compliant autoloader implementation.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class Autoloader
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Configurable.php
----------------------------------------------------------------------
diff --git a/src/Configurable.php b/src/Configurable.php
index 258e6ec..6964408 100644
--- a/src/Configurable.php
+++ b/src/Configurable.php
@@ -27,6 +27,7 @@ use Exception;
* extended. Provides a generic setter with integrated validation.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
* @since 2.2
*/
abstract class Configurable
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Filters/AbstractFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/AbstractFilter.php b/src/Filters/AbstractFilter.php
index 9b884a7..bdc167a 100644
--- a/src/Filters/AbstractFilter.php
+++ b/src/Filters/AbstractFilter.php
@@ -52,6 +52,8 @@ use Apache\Log4php\LoggingEvent;
*
* <p>The philosophy of log4php filters is largely inspired from the
* Linux ipchains.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
abstract class AbstractFilter extends Configurable
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Filters/DenyAllFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/DenyAllFilter.php b/src/Filters/DenyAllFilter.php
index 6781b55..4822988 100644
--- a/src/Filters/DenyAllFilter.php
+++ b/src/Filters/DenyAllFilter.php
@@ -28,6 +28,7 @@ use Apache\Log4php\LoggingEvent;
* filtering behaviour to a "deny all unless instructed otherwise"
* behaviour.
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
class DenyAllFilter extends AbstractFilter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Filters/LevelMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/LevelMatchFilter.php b/src/Filters/LevelMatchFilter.php
index 2ace612..69aa6e5 100644
--- a/src/Filters/LevelMatchFilter.php
+++ b/src/Filters/LevelMatchFilter.php
@@ -41,6 +41,8 @@ use Apache\Log4php\LoggingEvent;
* The corresponding XML file:
*
* {@example ../../examples/resources/filter_levelmatch.xml 18}
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.6
*/
class LevelMatchFilter extends AbstractFilter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Filters/LevelRangeFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/LevelRangeFilter.php b/src/Filters/LevelRangeFilter.php
index 6eb62f5..c457db5 100644
--- a/src/Filters/LevelRangeFilter.php
+++ b/src/Filters/LevelRangeFilter.php
@@ -58,6 +58,7 @@ use Apache\Log4php\LoggingEvent;
*
* @author Simon Kitching
* @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.6
*/
class LevelRangeFilter extends AbstractFilter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Filters/StringMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/StringMatchFilter.php b/src/Filters/StringMatchFilter.php
index c6e6359..5582317 100644
--- a/src/Filters/StringMatchFilter.php
+++ b/src/Filters/StringMatchFilter.php
@@ -41,6 +41,8 @@ use Apache\Log4php\LoggingEvent;
* The corresponding XML file:
*
* {@example ../../examples/resources/filter_stringmatch.xml 18}
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
class StringMatchFilter extends AbstractFilter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Helpers/FormattingInfo.php
----------------------------------------------------------------------
diff --git a/src/Helpers/FormattingInfo.php b/src/Helpers/FormattingInfo.php
index fb824b4..923d0b6 100644
--- a/src/Helpers/FormattingInfo.php
+++ b/src/Helpers/FormattingInfo.php
@@ -21,6 +21,8 @@ namespace Apache\Log4php\Helpers;
/**
* This class encapsulates the information obtained when parsing
* formatting modifiers in conversion modifiers.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
class FormattingInfo
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Helpers/OptionConverter.php
----------------------------------------------------------------------
diff --git a/src/Helpers/OptionConverter.php b/src/Helpers/OptionConverter.php
index d67b4a8..868bed6 100644
--- a/src/Helpers/OptionConverter.php
+++ b/src/Helpers/OptionConverter.php
@@ -23,6 +23,8 @@ use Apache\Log4php\LoggerException;
/**
* A convenience class to convert property values to specific types.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.5
*/
class OptionConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Helpers/PatternParser.php
----------------------------------------------------------------------
diff --git a/src/Helpers/PatternParser.php b/src/Helpers/PatternParser.php
index 5d22b39..1d9b014 100644
--- a/src/Helpers/PatternParser.php
+++ b/src/Helpers/PatternParser.php
@@ -29,6 +29,7 @@ use Apache\Log4php\Pattern\LiteralConverter;
* <p>It is this class that parses conversion patterns and creates
* a chained list of {@link AbstractConverter} converters.</p>
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
class PatternParser
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Helpers/Utils.php
----------------------------------------------------------------------
diff --git a/src/Helpers/Utils.php b/src/Helpers/Utils.php
index 01d5a40..e55c7ab 100644
--- a/src/Helpers/Utils.php
+++ b/src/Helpers/Utils.php
@@ -20,6 +20,8 @@ namespace Apache\Log4php\Helpers;
/**
* Contains various helper methods.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class Utils
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Hierarchy.php
----------------------------------------------------------------------
diff --git a/src/Hierarchy.php b/src/Hierarchy.php
index 384b8ee..0d85889 100644
--- a/src/Hierarchy.php
+++ b/src/Hierarchy.php
@@ -45,6 +45,9 @@ use Apache\Log4php\Renderers\RendererMap;
* then it creates a provision node for the ancestor and adds itself
* to the provision node. Other descendants of the same ancestor add
* themselves to the previously created provision node.</p>
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class Hierarchy
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Layouts/AbstractLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/AbstractLayout.php b/src/Layouts/AbstractLayout.php
index 3a8e486..bd4dd71 100644
--- a/src/Layouts/AbstractLayout.php
+++ b/src/Layouts/AbstractLayout.php
@@ -23,6 +23,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Extend this abstract class to create your own log layout format.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
abstract class AbstractLayout extends Configurable
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Layouts/HtmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/HtmlLayout.php b/src/Layouts/HtmlLayout.php
index 6a5bd50..be414d8 100644
--- a/src/Layouts/HtmlLayout.php
+++ b/src/Layouts/HtmlLayout.php
@@ -28,6 +28,8 @@ use Apache\Log4php\Level;
*
* - title
* - locationInfo
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class HtmlLayout extends AbstractLayout
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Layouts/PatternLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/PatternLayout.php b/src/Layouts/PatternLayout.php
index 58f1b50..96fda23 100644
--- a/src/Layouts/PatternLayout.php
+++ b/src/Layouts/PatternLayout.php
@@ -29,6 +29,8 @@ use Apache\Log4php\LoggingEvent;
*
* * converionPattern - A string which controls the formatting of logging
* events. See docs for full specification.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class PatternLayout extends AbstractLayout
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Layouts/SerializedLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SerializedLayout.php b/src/Layouts/SerializedLayout.php
index 12fb53f..77af51e 100644
--- a/src/Layouts/SerializedLayout.php
+++ b/src/Layouts/SerializedLayout.php
@@ -26,6 +26,8 @@ use Apache\Log4php\LoggingEvent;
* Available options:
* - locationInfo - If set to true, the event's location information will also
* be serialized (slow, defaults to false).
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.2
*/
class SerializedLayout extends AbstractLayout
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Layouts/SimpleLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SimpleLayout.php b/src/Layouts/SimpleLayout.php
index 5f57e0a..3c02e5e 100644
--- a/src/Layouts/SimpleLayout.php
+++ b/src/Layouts/SimpleLayout.php
@@ -25,6 +25,8 @@ use Apache\Log4php\LoggingEvent;
*
* Returns the log statement in a format consisting of the
* <b>level</b>, followed by " - " and then the <b>message</b>.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class SimpleLayout extends AbstractLayout
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Layouts/XmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/XmlLayout.php b/src/Layouts/XmlLayout.php
index f3b94b0..9a503f8 100644
--- a/src/Layouts/XmlLayout.php
+++ b/src/Layouts/XmlLayout.php
@@ -34,6 +34,7 @@ use Apache\Log4php\LoggingEvent;
* The output is designed to be included as an external entity in a separate file to form
* a correct XML file.</p>
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class XmlLayout extends AbstractLayout
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Level.php
----------------------------------------------------------------------
diff --git a/src/Level.php b/src/Level.php
index 78f8642..0f7ce46 100644
--- a/src/Level.php
+++ b/src/Level.php
@@ -26,6 +26,9 @@ namespace Apache\Log4php;
*
* <p>The <i>Level</i> class may be subclassed to define a larger
* level set.</p>
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
* @since 0.5
*/
class Level
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/LocationInfo.php
----------------------------------------------------------------------
diff --git a/src/LocationInfo.php b/src/LocationInfo.php
index bbb9fd9..712091b 100644
--- a/src/LocationInfo.php
+++ b/src/LocationInfo.php
@@ -20,6 +20,9 @@ namespace Apache\Log4php;
/**
* The internal representation of caller location information.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
* @since 0.3
*/
class LocationInfo
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Logger.php
----------------------------------------------------------------------
diff --git a/src/Logger.php b/src/Logger.php
index 055cd34..fa504b1 100644
--- a/src/Logger.php
+++ b/src/Logger.php
@@ -32,7 +32,7 @@ namespace Apache\Log4php;
* <li>{@link fatal()}</li>
* </ul>
*
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php
*/
class Logger
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/LoggerException.php
----------------------------------------------------------------------
diff --git a/src/LoggerException.php b/src/LoggerException.php
index 3641e90..3b9b411 100644
--- a/src/LoggerException.php
+++ b/src/LoggerException.php
@@ -20,6 +20,9 @@ namespace Apache\Log4php;
/**
* LoggerException class
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class LoggerException extends \Exception
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/LoggingEvent.php
----------------------------------------------------------------------
diff --git a/src/LoggingEvent.php b/src/LoggingEvent.php
index 0167c6a..4187224 100644
--- a/src/LoggingEvent.php
+++ b/src/LoggingEvent.php
@@ -20,6 +20,9 @@ namespace Apache\Log4php;
/**
* The internal representation of logging event.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class LoggingEvent
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/MDC.php
----------------------------------------------------------------------
diff --git a/src/MDC.php b/src/MDC.php
index 6e7f008..096f5af 100644
--- a/src/MDC.php
+++ b/src/MDC.php
@@ -29,8 +29,9 @@ namespace Apache\Log4php;
* This class is similar to the {@link NDC} class except that
* it is based on a map instead of a stack.
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
* @since 0.3
- *
*/
class MDC
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/NDC.php
----------------------------------------------------------------------
diff --git a/src/NDC.php b/src/NDC.php
index c81c233..f70d9b7 100644
--- a/src/NDC.php
+++ b/src/NDC.php
@@ -72,6 +72,8 @@ namespace Apache\Log4php;
* the same category) can still be distinguished because each client
* request will have a different NDC tag.
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
* @since 0.3
*/
class NDC
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/AbstractConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/AbstractConverter.php b/src/Pattern/AbstractConverter.php
index 57c6dfc..c3760ab 100644
--- a/src/Pattern/AbstractConverter.php
+++ b/src/Pattern/AbstractConverter.php
@@ -28,6 +28,8 @@ use Apache\Log4php\LoggingEvent;
* <p>Conversion specifiers in a conversion patterns are parsed to
* individual PatternConverters. Each of which is responsible for
* converting a logging event in a converter specific manner.</p>
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
abstract class AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/ClassConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ClassConverter.php b/src/Pattern/ClassConverter.php
index 09b87da..5adc46d 100644
--- a/src/Pattern/ClassConverter.php
+++ b/src/Pattern/ClassConverter.php
@@ -24,6 +24,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the fully qualified class name of the class from which the logging
* request was issued.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class ClassConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/CookieConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/CookieConverter.php b/src/Pattern/CookieConverter.php
index 245c11d..5d7b61a 100644
--- a/src/Pattern/CookieConverter.php
+++ b/src/Pattern/CookieConverter.php
@@ -25,6 +25,7 @@ namespace Apache\Log4php\Pattern;
* Options:
* [0] $_COOKIE key value
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class CookieConverter extends SuperglobalConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/DateConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/DateConverter.php b/src/Pattern/DateConverter.php
index d6ddc7e..553067e 100644
--- a/src/Pattern/DateConverter.php
+++ b/src/Pattern/DateConverter.php
@@ -28,6 +28,8 @@ use Apache\Log4php\LoggingEvent;
*
* There are several "special" values which can be given for this option:
* 'ISO8601', 'ABSOLUTE' and 'DATE'.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class DateConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/EnvironmentConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/EnvironmentConverter.php b/src/Pattern/EnvironmentConverter.php
index 6d1afa7..2af9b0e 100644
--- a/src/Pattern/EnvironmentConverter.php
+++ b/src/Pattern/EnvironmentConverter.php
@@ -25,7 +25,7 @@ namespace Apache\Log4php\Pattern;
* Options:
* [0] $_ENV key value
*
- *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class EnvironmentConverter extends SuperglobalConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/FileConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/FileConverter.php b/src/Pattern/FileConverter.php
index 15ce1ba..3b189d7 100644
--- a/src/Pattern/FileConverter.php
+++ b/src/Pattern/FileConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the name of the file from which the logging request was issued.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class FileConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/LevelConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LevelConverter.php b/src/Pattern/LevelConverter.php
index dabd5c3..27edfb6 100644
--- a/src/Pattern/LevelConverter.php
+++ b/src/Pattern/LevelConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the event's level.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class LevelConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/LineConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LineConverter.php b/src/Pattern/LineConverter.php
index 6a47e2e..ff12d8a 100644
--- a/src/Pattern/LineConverter.php
+++ b/src/Pattern/LineConverter.php
@@ -23,6 +23,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the line number within the file from which the logging request was
* issued.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class LineConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/LiteralConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LiteralConverter.php b/src/Pattern/LiteralConverter.php
index 061aed5..5c6934b 100644
--- a/src/Pattern/LiteralConverter.php
+++ b/src/Pattern/LiteralConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the literal value passed in the constructor, without modifications.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class LiteralConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/LocationConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LocationConverter.php b/src/Pattern/LocationConverter.php
index c100807..8c72303 100644
--- a/src/Pattern/LocationConverter.php
+++ b/src/Pattern/LocationConverter.php
@@ -23,6 +23,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the line number within the file from which the logging request was
* issued.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class LocationConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/LoggerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LoggerConverter.php b/src/Pattern/LoggerConverter.php
index 7c419ac..b436fee 100644
--- a/src/Pattern/LoggerConverter.php
+++ b/src/Pattern/LoggerConverter.php
@@ -26,6 +26,8 @@ use Apache\Log4php\LoggingEvent;
*
* Takes one option, which is an integer. If the option is given, the logger
* name will be shortened to the given length, if possible.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class LoggerConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/MdcConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MdcConverter.php b/src/Pattern/MdcConverter.php
index 6739694..32c8154 100644
--- a/src/Pattern/MdcConverter.php
+++ b/src/Pattern/MdcConverter.php
@@ -25,6 +25,8 @@ use Apache\Log4php\LoggingEvent;
*
* Options:
* [0] the MDC key
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class MdcConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/MessageConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MessageConverter.php b/src/Pattern/MessageConverter.php
index de9004d..e49b9b6 100644
--- a/src/Pattern/MessageConverter.php
+++ b/src/Pattern/MessageConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the logged message.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class MessageConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/MethodConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MethodConverter.php b/src/Pattern/MethodConverter.php
index 523693b..6b03ea6 100644
--- a/src/Pattern/MethodConverter.php
+++ b/src/Pattern/MethodConverter.php
@@ -23,6 +23,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the name of the function or method from which the logging request
* was issued.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class MethodConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/NdcConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/NdcConverter.php b/src/Pattern/NdcConverter.php
index 12255a4..f1c5c08 100644
--- a/src/Pattern/NdcConverter.php
+++ b/src/Pattern/NdcConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the full Nested Diagnostic Context.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class NdcConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/NewLineConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/NewLineConverter.php b/src/Pattern/NewLineConverter.php
index 8754952..40672f1 100644
--- a/src/Pattern/NewLineConverter.php
+++ b/src/Pattern/NewLineConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns platform-specific newline character(s).
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class NewLineConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/ProcessConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ProcessConverter.php b/src/Pattern/ProcessConverter.php
index e0d87f3..d4e5189 100644
--- a/src/Pattern/ProcessConverter.php
+++ b/src/Pattern/ProcessConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the PID of the current process.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class ProcessConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/RelativeConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/RelativeConverter.php b/src/Pattern/RelativeConverter.php
index 02fe940..3b2b9d7 100644
--- a/src/Pattern/RelativeConverter.php
+++ b/src/Pattern/RelativeConverter.php
@@ -23,6 +23,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the number of milliseconds elapsed since the start of the
* application until the creation of the logging event.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class RelativeConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/RequestConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/RequestConverter.php b/src/Pattern/RequestConverter.php
index 9c72c33..e447e39 100644
--- a/src/Pattern/RequestConverter.php
+++ b/src/Pattern/RequestConverter.php
@@ -25,7 +25,7 @@ namespace Apache\Log4php\Pattern;
* Options:
* [0] $_REQUEST key value
*
- *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class RequestConverter extends SuperglobalConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/ServerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ServerConverter.php b/src/Pattern/ServerConverter.php
index 0ed7d5a..264fc9a 100644
--- a/src/Pattern/ServerConverter.php
+++ b/src/Pattern/ServerConverter.php
@@ -25,7 +25,7 @@ namespace Apache\Log4php\Pattern;
* Options:
* [0] $_SERVER key value
*
- *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class ServerConverter extends SuperglobalConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/SessionConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SessionConverter.php b/src/Pattern/SessionConverter.php
index 52343de..bdb749a 100644
--- a/src/Pattern/SessionConverter.php
+++ b/src/Pattern/SessionConverter.php
@@ -25,7 +25,7 @@ namespace Apache\Log4php\Pattern;
* Options:
* [0] $_SESSION key value
*
- *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class SessionConverter extends SuperglobalConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/SessionIdConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SessionIdConverter.php b/src/Pattern/SessionIdConverter.php
index 23324c4..ade9e82 100644
--- a/src/Pattern/SessionIdConverter.php
+++ b/src/Pattern/SessionIdConverter.php
@@ -22,6 +22,8 @@ use Apache\Log4php\LoggingEvent;
/**
* Returns the active session ID, or an empty string if out of session.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class SessionIdConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/SuperglobalConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SuperglobalConverter.php b/src/Pattern/SuperglobalConverter.php
index 7befa67..11431fb 100644
--- a/src/Pattern/SuperglobalConverter.php
+++ b/src/Pattern/SuperglobalConverter.php
@@ -32,6 +32,7 @@ use Apache\Log4php\LoggingEvent;
*
* @see http://php.net/manual/en/language.variables.superglobals.php
* @see http://www.php.net/manual/en/ini.core.php#ini.variables-order
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
abstract class SuperglobalConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Pattern/ThrowableConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ThrowableConverter.php b/src/Pattern/ThrowableConverter.php
index 8f12a84..7527bf8 100644
--- a/src/Pattern/ThrowableConverter.php
+++ b/src/Pattern/ThrowableConverter.php
@@ -20,6 +20,8 @@ namespace Apache\Log4php\Pattern;
/**
* Returns the throwable information linked to the logging event, if any.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.3
*/
class ThrowableConverter extends AbstractConverter
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/ReflectionUtils.php
----------------------------------------------------------------------
diff --git a/src/ReflectionUtils.php b/src/ReflectionUtils.php
index 38793fd..dd9a4da 100644
--- a/src/ReflectionUtils.php
+++ b/src/ReflectionUtils.php
@@ -20,6 +20,9 @@ namespace Apache\Log4php;
/**
* Provides methods for reflective use on php objects
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class ReflectionUtils
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Renderers/DefaultRenderer.php
----------------------------------------------------------------------
diff --git a/src/Renderers/DefaultRenderer.php b/src/Renderers/DefaultRenderer.php
index 6d1a2be..3ec0aa5 100644
--- a/src/Renderers/DefaultRenderer.php
+++ b/src/Renderers/DefaultRenderer.php
@@ -22,6 +22,8 @@ namespace Apache\Log4php\Renderers;
* The default renderer, which is used when no other renderer is found.
*
* Renders the input using <var>print_r</var>.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
class DefaultRenderer implements RendererInterface
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Renderers/ExceptionRenderer.php
----------------------------------------------------------------------
diff --git a/src/Renderers/ExceptionRenderer.php b/src/Renderers/ExceptionRenderer.php
index ad9b09f..a1f58d6 100644
--- a/src/Renderers/ExceptionRenderer.php
+++ b/src/Renderers/ExceptionRenderer.php
@@ -20,6 +20,8 @@ namespace Apache\Log4php\Renderers;
/**
* Renderer used for Exceptions.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.1
*/
class ExceptionRenderer implements RendererInterface
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Renderers/RendererInterface.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererInterface.php b/src/Renderers/RendererInterface.php
index ad96b85..bae172d 100644
--- a/src/Renderers/RendererInterface.php
+++ b/src/Renderers/RendererInterface.php
@@ -20,6 +20,8 @@ namespace Apache\Log4php\Renderers;
/**
* Implement this interface in order to render objects to strings.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
interface RendererInterface
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/Renderers/RendererMap.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererMap.php b/src/Renderers/RendererMap.php
index 1165720..74e5977 100644
--- a/src/Renderers/RendererMap.php
+++ b/src/Renderers/RendererMap.php
@@ -21,6 +21,8 @@ namespace Apache\Log4php\Renderers;
/**
* Manages defined renderers and determines which renderer to use for a given
* input.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 0.3
*/
class RendererMap
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/RootLogger.php
----------------------------------------------------------------------
diff --git a/src/RootLogger.php b/src/RootLogger.php
index bd9b089..8a79733 100644
--- a/src/RootLogger.php
+++ b/src/RootLogger.php
@@ -20,7 +20,9 @@ namespace Apache\Log4php;
/**
* The root logger.
- * @see Logger
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
*/
class RootLogger extends Logger
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/dfa21323/src/ThrowableInformation.php
----------------------------------------------------------------------
diff --git a/src/ThrowableInformation.php b/src/ThrowableInformation.php
index 255c0b8..cbc77f1 100644
--- a/src/ThrowableInformation.php
+++ b/src/ThrowableInformation.php
@@ -21,6 +21,8 @@ namespace Apache\Log4php;
/**
* The internal representation of throwables.
*
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
* @since 2.1
*/
class ThrowableInformation
[18/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterMDC.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterMDC.php b/src/main/php/pattern/LoggerPatternConverterMDC.php
deleted file mode 100644
index 10f824b..0000000
--- a/src/main/php/pattern/LoggerPatternConverterMDC.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the Mapped Diagnostic Context value corresponding to the given key.
- *
- * Options:
- * [0] the MDC key
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterMDC extends LoggerPatternConverter {
-
- private $key;
-
- public function activateOptions() {
- if (isset($this->option) && $this->option !== '') {
- $this->key = $this->option;
- }
- }
-
- 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);
- }
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterMessage.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterMessage.php b/src/main/php/pattern/LoggerPatternConverterMessage.php
deleted file mode 100644
index c3569b9..0000000
--- a/src/main/php/pattern/LoggerPatternConverterMessage.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the logged message.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterMessage extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return $event->getRenderedMessage();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterMethod.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterMethod.php b/src/main/php/pattern/LoggerPatternConverterMethod.php
deleted file mode 100644
index 9d36325..0000000
--- a/src/main/php/pattern/LoggerPatternConverterMethod.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the name of the function or method from which the logging request
- * was issued.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterMethod extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return $event->getLocationInformation()->getMethodName();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterNDC.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterNDC.php b/src/main/php/pattern/LoggerPatternConverterNDC.php
deleted file mode 100644
index 2808862..0000000
--- a/src/main/php/pattern/LoggerPatternConverterNDC.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the full Nested Diagnostic Context.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterNDC extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return $event->getNDC();
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterNewLine.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterNewLine.php b/src/main/php/pattern/LoggerPatternConverterNewLine.php
deleted file mode 100644
index defc040..0000000
--- a/src/main/php/pattern/LoggerPatternConverterNewLine.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns platform-specific newline character(s).
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterNewLine extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return PHP_EOL;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterProcess.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterProcess.php b/src/main/php/pattern/LoggerPatternConverterProcess.php
deleted file mode 100644
index 1439fbc..0000000
--- a/src/main/php/pattern/LoggerPatternConverterProcess.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the PID of the current process.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterProcess extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return getmypid();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterRelative.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterRelative.php b/src/main/php/pattern/LoggerPatternConverterRelative.php
deleted file mode 100644
index 175e694..0000000
--- a/src/main/php/pattern/LoggerPatternConverterRelative.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the number of milliseconds elapsed since the start of the
- * application until the creation of the logging event.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterRelative extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- $ts = $event->getRelativeTime();
- return number_format($ts, 4);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterRequest.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterRequest.php b/src/main/php/pattern/LoggerPatternConverterRequest.php
deleted file mode 100644
index 27bf998..0000000
--- a/src/main/php/pattern/LoggerPatternConverterRequest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns a value from the $_REQUEST superglobal array corresponding to the
- * given key.
- *
- * Options:
- * [0] $_REQUEST key value
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterRequest extends LoggerPatternConverterSuperglobal {
- protected $name = '_REQUEST';
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterServer.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterServer.php b/src/main/php/pattern/LoggerPatternConverterServer.php
deleted file mode 100644
index 37b26e3..0000000
--- a/src/main/php/pattern/LoggerPatternConverterServer.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns a value from the $_SERVER superglobal array corresponding to the
- * given key.
- *
- * Options:
- * [0] $_SERVER key value
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterServer extends LoggerPatternConverterSuperglobal {
- protected $name = '_SERVER';
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterSession.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterSession.php b/src/main/php/pattern/LoggerPatternConverterSession.php
deleted file mode 100644
index 0105490..0000000
--- a/src/main/php/pattern/LoggerPatternConverterSession.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns a value from the $_SESSION superglobal array corresponding to the
- * given key.
- *
- * Options:
- * [0] $_SESSION key value
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterSession extends LoggerPatternConverterSuperglobal {
- protected $name = '_SESSION';
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterSessionID.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterSessionID.php b/src/main/php/pattern/LoggerPatternConverterSessionID.php
deleted file mode 100644
index f45df60..0000000
--- a/src/main/php/pattern/LoggerPatternConverterSessionID.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the active session ID, or an empty string if out of session.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterSessionID extends LoggerPatternConverter {
- public function convert(LoggerLoggingEvent $event) {
- return session_id();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterSuperglobal.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterSuperglobal.php b/src/main/php/pattern/LoggerPatternConverterSuperglobal.php
deleted file mode 100644
index 649e169..0000000
--- a/src/main/php/pattern/LoggerPatternConverterSuperglobal.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns a value from a superglobal array corresponding to the
- * given key.
- *
- * Option: the key to look up within the superglobal array
- *
- * Also, it is possible that a superglobal variable is not populated by PHP
- * because of the settings in the variables-order ini directive. In this case
- * the converter will return an empty value.
- *
- * @see http://php.net/manual/en/language.variables.superglobals.php
- * @see http://www.php.net/manual/en/ini.core.php#ini.variables-order
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-abstract class LoggerPatternConverterSuperglobal extends LoggerPatternConverter {
-
- /**
- * Name of the superglobal variable, to be defined by subclasses.
- * For example: "_SERVER" or "_ENV".
- */
- protected $name;
-
- protected $value = '';
-
- public function activateOptions() {
- // Read the key from options array
- if (isset($this->option) && $this->option !== '') {
- $key = $this->option;
- }
-
- /*
- * There is a bug in PHP which doesn't allow superglobals to be
- * accessed when their name is stored in a variable, e.g.:
- *
- * $name = '_SERVER';
- * $array = $$name;
- *
- * This code does not work when run from within a method (only when run
- * in global scope). But the following code does work:
- *
- * $name = '_SERVER';
- * global $$name;
- * $array = $$name;
- *
- * That's why global is used here.
- */
- global ${$this->name};
-
- // Check the given superglobal exists. It is possible that it is not initialized.
- if (!isset(${$this->name})) {
- $class = get_class($this);
- trigger_error("log4php: $class: Cannot find superglobal variable \${$this->name}.", E_USER_WARNING);
- return;
- }
-
- $source = ${$this->name};
-
- // When the key is set, display the matching value
- if (isset($key)) {
- if (isset($source[$key])) {
- $this->value = $source[$key];
- }
- }
-
- // When the key is not set, display all values
- else {
- $values = array();
- foreach($source as $key => $value) {
- $values[] = "$key=$value";
- }
- $this->value = implode(', ', $values);
- }
- }
-
- public function convert(LoggerLoggingEvent $event) {
- return $this->value;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterThrowable.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterThrowable.php b/src/main/php/pattern/LoggerPatternConverterThrowable.php
deleted file mode 100644
index 609836a..0000000
--- a/src/main/php/pattern/LoggerPatternConverterThrowable.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the throwable information linked to the logging event, if any.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterThrowable extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- $info = $event->getThrowableInformation();
- if (isset($info)) {
- $ex = $info->getThrowable();
- return (string) $ex . PHP_EOL;
- }
- return '';
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/renderers/LoggerRenderer.php
----------------------------------------------------------------------
diff --git a/src/main/php/renderers/LoggerRenderer.php b/src/main/php/renderers/LoggerRenderer.php
deleted file mode 100644
index dd913fe..0000000
--- a/src/main/php/renderers/LoggerRenderer.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Implement this interface in order to render objects to strings.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage renderers
- * @since 0.3
- */
-interface LoggerRenderer {
- /**
- * Renders the entity passed as <var>input</var> to a string.
- * @param mixed $input The entity to render.
- * @return string The rendered string.
- */
- public function render($input);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/renderers/LoggerRendererDefault.php
----------------------------------------------------------------------
diff --git a/src/main/php/renderers/LoggerRendererDefault.php b/src/main/php/renderers/LoggerRendererDefault.php
deleted file mode 100644
index 2f35f97..0000000
--- a/src/main/php/renderers/LoggerRendererDefault.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The default renderer, which is used when no other renderer is found.
- *
- * Renders the input using <var>print_r</var>.
- *
- * @package log4php
- * @subpackage renderers
- * @since 0.3
- */
-class LoggerRendererDefault implements LoggerRenderer {
-
- /** @inheritdoc */
- public function render($input) {
- return print_r($input, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/renderers/LoggerRendererException.php
----------------------------------------------------------------------
diff --git a/src/main/php/renderers/LoggerRendererException.php b/src/main/php/renderers/LoggerRendererException.php
deleted file mode 100644
index d78bcb8..0000000
--- a/src/main/php/renderers/LoggerRendererException.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Renderer used for Exceptions.
- *
- * @package log4php
- * @subpackage renderers
- * @since 2.1
- */
-class LoggerRendererException implements LoggerRenderer {
-
- public function render($input) {
-
- // Exception class has a very decent __toString method
- // so let's just use that instead of writing lots of code.
- return (string) $input;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/renderers/LoggerRendererMap.php
----------------------------------------------------------------------
diff --git a/src/main/php/renderers/LoggerRendererMap.php b/src/main/php/renderers/LoggerRendererMap.php
deleted file mode 100644
index 8e7631b..0000000
--- a/src/main/php/renderers/LoggerRendererMap.php
+++ /dev/null
@@ -1,186 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Manages defined renderers and determines which renderer to use for a given
- * input.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage renderers
- * @since 0.3
- */
-class LoggerRendererMap {
-
- /**
- * Maps class names to appropriate renderers.
- * @var array
- */
- private $map = array();
-
- /**
- * The default renderer to use if no specific renderer is found.
- * @var LoggerRenderer
- */
- private $defaultRenderer;
-
- public function __construct() {
-
- // Set default config
- $this->reset();
- }
-
- /**
- * Adds a renderer to the map.
- *
- * If a renderer already exists for the given <var>$renderedClass</var> it
- * will be overwritten without warning.
- *
- * @param string $renderedClass The name of the class which will be
- * rendered by the renderer.
- * @param string $renderingClass The name of the class which will
- * perform the rendering.
- */
- public function addRenderer($renderedClass, $renderingClass) {
- // Check the rendering class exists
- if (!class_exists($renderingClass)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
- return;
- }
-
- // Create the instance
- $renderer = new $renderingClass();
-
- // Check the class implements the right interface
- if (!($renderer instanceof LoggerRenderer)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface.");
- return;
- }
-
- // Convert to lowercase since class names in PHP are not case sensitive
- $renderedClass = strtolower($renderedClass);
-
- $this->map[$renderedClass] = $renderer;
- }
-
- /**
- * Sets a custom default renderer class.
- *
- * TODO: there's code duplication here. This method is almost identical to
- * addRenderer(). However, it has custom error messages so let it sit for
- * now.
- *
- * @param string $renderingClass The name of the class which will
- * perform the rendering.
- */
- public function setDefaultRenderer($renderingClass) {
- // Check the class exists
- if (!class_exists($renderingClass)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
- return;
- }
-
- // Create the instance
- $renderer = new $renderingClass();
-
- // Check the class implements the right interface
- if (!($renderer instanceof LoggerRenderer)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface.");
- return;
- }
-
- $this->defaultRenderer = $renderer;
- }
-
- /**
- * Returns the default renderer.
- * @var LoggerRenderer
- */
- public function getDefaultRenderer() {
- return $this->defaultRenderer;
- }
-
- /**
- * Finds the appropriate renderer for the given <var>input</var>, and
- * renders it (i.e. converts it to a string).
- *
- * @param mixed $input Input to render.
- * @return string The rendered contents.
- */
- public function findAndRender($input) {
- if ($input === null) {
- return null;
- }
-
- // For objects, try to find a renderer in the map
- if(is_object($input)) {
- $renderer = $this->getByClassName(get_class($input));
- if (isset($renderer)) {
- return $renderer->render($input);
- }
- }
-
- // Fall back to the default renderer
- return $this->defaultRenderer->render($input);
- }
-
- /**
- * Returns the appropriate renderer for a given object.
- *
- * @param mixed $object
- * @return LoggerRenderer Or null if none found.
- */
- public function getByObject($object) {
- if (!is_object($object)) {
- return null;
- }
- return $this->getByClassName(get_class($object));
- }
-
- /**
- * Returns the appropriate renderer for a given class name.
- *
- * If no renderer could be found, returns NULL.
- *
- * @param string $class
- * @return LoggerRendererObject Or null if not found.
- */
- public function getByClassName($class) {
- for(; !empty($class); $class = get_parent_class($class)) {
- $class = strtolower($class);
- if(isset($this->map[$class])) {
- return $this->map[$class];
- }
- }
- return null;
- }
-
- /** Empties the renderer map. */
- public function clear() {
- $this->map = array();
- }
-
- /** Resets the renderer map to it's default configuration. */
- public function reset() {
- $this->defaultRenderer = new LoggerRendererDefault();
- $this->clear();
- $this->addRenderer('Exception', 'LoggerRendererException');
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/xml/log4php.dtd
----------------------------------------------------------------------
diff --git a/src/main/php/xml/log4php.dtd b/src/main/php/xml/log4php.dtd
deleted file mode 100644
index 54c6c7f..0000000
--- a/src/main/php/xml/log4php.dtd
+++ /dev/null
@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<!-- Authors: Chris Taylor, Ceki Gülcü. -->
-<!-- Version: 1.2 -->
-
-<!-- PHP Port Modifications Author: Marco Vassura -->
-<!-- PHP dtd Version: $Revision$ -->
-
-<!-- A configuration element consists of optional renderer
-elements,appender elements, categories and an optional root
-element. -->
-<!-- [log4php] -->
-<!--
- category instead of logger cannot be used. categoryFactory is not implemented in log4php.
--->
-<!-- [/log4php] -->
-<!ELEMENT log4php:configuration (renderer*, appender*,(logger)*,root?)>
-
-<!-- The "threshold" attribute takes a level value such that all -->
-<!-- logging statements with a level equal or below this value are -->
-<!-- disabled. -->
-
-<!-- Setting the "debug" enable the printing of internal log4j logging -->
-<!-- statements. -->
-
-<!-- By default, debug attribute is "null", meaning that we not do touch -->
-<!-- internal log4j logging settings. The "null" value for the threshold -->
-<!-- attribute can be misleading. The threshold field of a repository -->
-<!-- cannot be set to null. The "null" value for the threshold attribute -->
-<!-- simply means don't touch the threshold field, the threshold field -->
-<!-- keeps its old value. -->
-
-<!ATTLIST log4php:configuration
- xmlns:log4php CDATA #FIXED "http://logging.apache.org/log4php"
- threshold (all|debug|info|warn|error|fatal|off|null) "null"
->
-
-<!-- renderer elements allow the user to customize the conversion of -->
-<!-- message objects to String. -->
-<!ELEMENT renderer EMPTY>
-<!ATTLIST renderer
- renderedClass CDATA #REQUIRED
- renderingClass CDATA #REQUIRED
->
-
-<!-- Appenders must have a name and a class. -->
-<!-- Appenders may contain an error handler, a layout, optional parameters -->
-<!-- and filters. They may also reference (or include) other appenders. -->
-<!-- [log4php] -->
-<!-- error handler tag has no effects since log4php does not handle errors. Defintion deleted. -->
-<!-- [/log4php] -->
-<!ELEMENT appender (param*, layout?, filter*, appender-ref*)>
-<!ATTLIST appender
- name ID #REQUIRED
- class CDATA #REQUIRED
->
-
-<!ELEMENT layout (param*)>
-<!ATTLIST layout
- class CDATA #REQUIRED
->
-
-<!ELEMENT filter (param*)>
-<!ATTLIST filter
- class CDATA #REQUIRED
->
-
-
-<!ELEMENT param EMPTY>
-<!ATTLIST param
- name CDATA #REQUIRED
- value CDATA #REQUIRED
->
-
-<!ELEMENT priority EMPTY>
-<!ATTLIST priority
- value CDATA #REQUIRED
->
-
-<!ELEMENT level EMPTY>
-<!ATTLIST level
- value CDATA #REQUIRED
->
-
-<!-- If no level element is specified, then the configurator MUST not -->
-<!-- touch the level of the named logger. -->
-<!ELEMENT logger (level?,appender-ref*)>
-<!ATTLIST logger
- name ID #REQUIRED
- additivity (true|false) "true"
->
-
-<!ELEMENT appender-ref EMPTY>
-<!ATTLIST appender-ref
- ref IDREF #REQUIRED
->
-
-<!-- If no priority element is specified, then the configurator MUST not -->
-<!-- touch the priority of root. -->
-<!-- The root category always exists and cannot be subclassed. -->
-<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
-
-
-<!-- ==================================================================== -->
-<!-- A logging event -->
-<!-- ==================================================================== -->
-<!ELEMENT log4php:eventSet (log4php:event*)>
-<!ATTLIST log4php:eventSet
- xmlns:log4php CDATA #FIXED "http://www.vxr.it/log4php/"
- version (0.2|0.3) "0.3"
- includesLocationInfo (true|false) "true"
->
-
-<!ELEMENT log4php:event (log4php:message, log4php:locationInfo?) >
-
-<!-- The timestamp format is application dependent. -->
-<!ATTLIST log4php:event
- logger CDATA #REQUIRED
- level CDATA #REQUIRED
- thread CDATA #REQUIRED
- timestamp CDATA #REQUIRED
->
-
-<!ELEMENT log4php:message (#PCDATA)>
-<!ELEMENT log4php:NDC (#PCDATA)>
-
-<!ELEMENT log4php:locationInfo EMPTY>
-<!ATTLIST log4php:locationInfo
- class CDATA #REQUIRED
- method CDATA #REQUIRED
- file CDATA #REQUIRED
- line CDATA #REQUIRED
->
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/apt/contributingpatches.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/contributingpatches.apt b/src/site/apt/contributingpatches.apt
deleted file mode 100644
index 93c9a5b..0000000
--- a/src/site/apt/contributingpatches.apt
+++ /dev/null
@@ -1,112 +0,0 @@
-~~ Licensed to the Apache Software Foundation (ASF) under one or more
-~~ contributor license agreements. See the NOTICE file distributed with
-~~ this work for additional information regarding copyright ownership.
-~~ The ASF licenses this file to You under the Apache License, Version 2.0
-~~ (the "License"); you may not use this file except in compliance with
-~~ the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing, software
-~~ distributed under the License is distributed on an "AS IS" BASIS,
-~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-~~ See the License for the specific language governing permissions and
-~~ limitations under the License.
- ------
- Contributing Patches
- ------
- ------
- ------
-
-Contributing patches
-
- Before you read this document, make sure you have read the general information on the
- {{{./volunteering.html}Volunteering}} page. Credits to the Apache Commons project on which documents
- this one is based on.
-
- For guidelines on how to set up a development environment for Apache log4php, there is a
- {{{http://wiki.apache.org/logging-log4php/SettingUpALinuxEnvironment} detailed guide}} on the
- wiki pages.
-
-* Respect the original style
-
- Please respect the style of the orginal file. Make sure that your additions fit in with that style.
- The framework has coding conventions and every contribution is supposed to adhere to them.
- You might find it a little difficult to discover the conventions used by a particular class
- but if you stick to the style of the original then that'll be fine. If in doubt, ask on the developers
- mailinglist.
-
- If a patch is submitted which doesn't satisfy the component's coding conventions,
- then either a committer will need to rewrite the submission or it will be rejected.
- Getting it right in this first place will save you having to rewrite it.
-
- Most important codestyles:
-
- * don't use vertical alignement
-
- * keep brackets on the same line as the method signature
-
- * keep brackets on the same line as control statements
-
- * always use brackets for control statements
-
- * use lowerCamelCase for naming methods and variables
-
- * don't use underscores (_)
-
- []
-
-* Tabs not spaces
-
- PLEASE NO SPACES!
-
- Some IDEs include automatic source (re)formatting. If you use an IDE, please check that
- this feature is either disabled or set to use tabs.
-
- If a patch is submitted which uses tabs rather than spaces, then either a committer
- will have to reformat it before it's applied or the patch will be rejected. Again,
- it's easier to get it right in the first place rather than have to reformat and resubmit your patch.
-
-* Test cases
-
- Classes needs to be tested with {{{https://github.com/sebastianbergmann/phpunit/}PHPUnit}}. If
- you are not familiar with the principles of regression testing, then the
- {{{http://www.phpunit.de/manual/3.6/en/}PHPUnit manual}} is a good place to start.
-
- Before you submit your patch, please do a clean build of the full distribution and
- run the unit tests (this can be done with <<<maven test>>>. This ensures that
- your patch doesn't break any existing functionality.
-
- We strongly recommend that you create and submit test cases together with the rest
- of your contribution. Test cases ensure that bugs stay fixed and features don't get broken.
- Test cases will probably be needed anyway so submitting them saves time.
-
-* Creating a patch
-
- The Apache log4php {{{./source-repository.html}source code repository}} holds the current source.
-
- Please create your patch against the latest revision of the files in the source code
- repository since this makes the job of applying the patch much easier.
- If you don't have a version checked out, then check one out. If you have, then please
- do a fresh update before you make your changes.
-
- The patch should be in unified format. You can create a patch in this format by using:
-
-+--
- svn diff File >> patchfile
-+--
-
- Eclipse has some diff features too. Please make sure you have your project as a patch root.
- Try to give your patch files meaningful names. This makes it easier for
- developers who need to apply a number of different patches.
-
-* Submitting a patch
-
- The preffered way of submitting a patch is by attaching it to a bug report in the project's
- {{{http://logging.apache.org/log4php/issue-tracking.html} issue tracker}}. Create a new bug
- report if necessary.
-
- Please make sure to mark "Grant license to ASF for inclusion in ASF works" when attaching
- the patch. This means you agree with providing us with the code contained in the patch
- under the {{{http://www.apache.org/licenses/LICENSE-2.0}Apache licence}}.
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/apt/download.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/download.apt b/src/site/apt/download.apt
deleted file mode 100644
index 628b6e5..0000000
--- a/src/site/apt/download.apt
+++ /dev/null
@@ -1,92 +0,0 @@
-~~ Licensed to the Apache Software Foundation (ASF) under one or more
-~~ contributor license agreements. See the NOTICE file distributed with
-~~ this work for additional information regarding copyright ownership.
-~~ The ASF licenses this file to You under the Apache License, Version 2.0
-~~ (the "License"); you may not use this file except in compliance with
-~~ the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing, software
-~~ distributed under the License is distributed on an "AS IS" BASIS,
-~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-~~ See the License for the specific language governing permissions and
-~~ limitations under the License.
- ------
-Download
- ------
- ------
- ------
-
-Download
-
- Apache log4php\u2122 is a versatile logging framework for PHP.
-
- Apache log4php is distributed under the {{{http://www.apache.org/licenses/LICENSE-2.0.html} Apache License, version 2.0}}.
-
- Version 2.2.1 is the latest stable version, available since 18.02.2012..
-
-* Source package
-
- The source package contains the complete source code and API docs. This is recommended for most users.
-
-*----------+-----------+------------+
-|| Mirrors || Checksum || Signature |
-*----------+-----------+------------+
-| {{{http://www.apache.org/dyn/closer.cgi/logging/log4php/2.2.1/apache-log4php-2.2.1-src.tar.gz}apache-log4php-2.2.1-src.tar.gz}} | {{{http://www.apache.org/dist/logging/log4php/2.2.1/apache-log4php-2.2.1-src.tar.gz.md5}MD5}} | {{{http://www.apache.org/dist/logging/log4php/2.2.1/apache-log4php-2.2.1-src.tar.gz.asc}ASC}} |
-*----------+-----------+------------+
-| {{{http://www.apache.org/dyn/closer.cgi/logging/log4php/2.2.1/apache-log4php-2.2.1-src.zip}apache-log4php-2.2.1-src.zip}} | {{{http://www.apache.org/dist/logging/log4php/2.2.1/apache-log4php-2.2.1-src.zip.md5}MD5}} | {{{http://www.apache.org/dist/logging/log4php/2.2.1/apache-log4php-2.2.1-src.zip.asc}ASC}} |
-*----------+-----------+------------+
-
-* Pear package
-
- To install from the Apache log4php PEAR channel:
-
-+--
-pear channel-discover pear.apache.org/log4php
-pear install log4php/Apache_log4php
-+--
-
- Alternatively, the PEAR package can be downloaded from:
-
-*----------+-----------+------------+
-|| Mirrors || Checksum || Signature |
-*----------+-----------+------------+
-| {{{http://www.apache.org/dyn/closer.cgi/logging/log4php/2.2.1/Apache_log4php-2.2.1.tgz}Apache_log4php-2.2.1.tgz}} | {{{http://www.apache.org/dist/logging/log4php/2.2.1/Apache_log4php-2.2.1.tgz.md5}MD5}} | {{{http://www.apache.org/dist/logging/log4php/2.2.1/Apache_log4php-2.2.1.tgz.asc}ASC}} |
-*----------+-----------+------------+
-
-* From repository
-
- The latest development version can be checked out from the {{{./source-repository.html}project repository}}. This will provide access to all the latest features, but may be unstable and should not be used in production systems.
-
-* Previous Releases
-
- All previous releases of Apache log4php can be found in the {{{http://archive.apache.org/dist/logging/log4php}archive repository}}.
-
-* Please mind the signatures
-
- It is important that you verify the integrity of the downloaded files using the PGP or MD5 signatures.
- Please read {{{http://httpd.apache.org/dev/verification.html}Verifying Apache HTTP Server Releases}} for more
- information on why you should verify our releases.
-
- The PGP signatures can be verified using PGP or GPG. First download the {{{http://www.apache.org/dist/logging/log4php/KEYS}KEYS}}
- as well as the asc signature file for the relevant distribution. Make sure you get these files from the
- {{{http://www.apache.org/dist/logging/log4php}main distribution directory}}, rather than from a mirror.
-
- Then verify the signatures using GPG perform the following:
-
----
-# gpg --import KEYS
-# gpg --verify apache-log4php-2.2.1-src.tar.gz.asc
----
-
- This should result in a confirmation message:
-
----
-gpg: Signature made Fri 27 Nov 2009 07:47:28 AM CET using DSA key ID 42196CA8
-gpg: Good signature from "Christian Grobmeier (Apache Codesigning) <gr...@apache.org>"
----
-
- Apache log4php 2.2.1 is signed by Ivan Habunek (key 0BD936F1).
-
- Alternatively, you can verify the MD5 signature on the files.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
deleted file mode 100644
index 2203536..0000000
--- a/src/site/apt/index.apt
+++ /dev/null
@@ -1,104 +0,0 @@
-~~ Licensed to the Apache Software Foundation (ASF) under one or more
-~~ contributor license agreements. See the NOTICE file distributed with
-~~ this work for additional information regarding copyright ownership.
-~~ The ASF licenses this file to You under the Apache License, Version 2.0
-~~ (the "License"); you may not use this file except in compliance with
-~~ the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing, software
-~~ distributed under the License is distributed on an "AS IS" BASIS,
-~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-~~ See the License for the specific language governing permissions and
-~~ limitations under the License.
- ------
-Welcome
- ------
- ------
- ------
-
-What is Apache log4php?
-
- Apache log4php\u2122 is a versatile logging framework for PHP.
-
- Feature highlights:
-
- * Configuration through XML, properties or PHP files
-
- * Various logging destinations, including:
-
- * Console (stdout, stderr)
-
- * Files (including daily and rolling files)
-
- * Email
-
- * Databases
-
- * Sockets
-
- * Syslog
-
- []
-
- * Several built-in log message formats, including:
-
- * HTML
-
- * XML
-
- * User defined pattern
-
- []
-
- * Nested (NDC) and Mapped (MDC) Diagnostic Contexts.
-
- []
-
-
-The Apache log4php project
-
- Apache log4php\u2122 is an open source project at the
- {{{http://www.apache.org}Apache Software Foundation}}, a part the
- {{{http://logging.apache.org}Apache Logging Services}} project.
-
- Apache log4php\u2122 graduated in March 2010.
-
-Who uses Apache log4php?
-
- This sections lists some of the projects which use Apache log4php.
-
- In alphabetic order:
-
- * {{{http://cmsmadesimple.org}CMS Made Simple}} - an open source (GPL) CMS
-
- * {{{http://marcelog.github.com/Ding/}Ding}} - a dependency injection, AOP, and MVC container, with features
- similar to the Spring Framework
-
- * {{{http://sourceforge.net/projects/helpzilla/}Helpzilla}} - interactive solutions for customer care
-
- * {{{http://www.imento.dk}Imento}} - a danish company which uses log4php in their commercial
- MVC framework
-
- * {{{http://www.paloose.org}Paloose}} - a simplified version of Cocoon using PHP
-
- * {{{http://marcelog.github.com/PAMI/}PAMI}} / {{{http://marcelog.github.com/PAGI/}PAGI}} - OOP clients for the
- Asterisk Manager Protocol and the Asterisk Gateway Protocol, implemented in PHP.
-
- * {{{http://piwi.googlecode.com/}PIWI Framework}} - a framework for quick website building and
- PHP Dependency Injection similar to Apache Cocoon and Apache Forrest.
-
- * {{{http://code.google.com/p/scalr/}Scalr}} - a fully redundant, self-curing and self-scaling hosting environment
- using Amazon's EC2
-
- * {{{http://www.sitesupra.com/}SiteSupra}} - an enterprise PHP platform
-
- * {{{http://www.sugarcrm.com}SugarCRM}} - low-cost customer relationship management solutions
-
- * {{{http://www.vtiger.com}vtiger}} - an open source CRM
-
- []
-
- If you think that you should be on this list, please let us know by sending a
- message to the {{{./mail-lists.html}log4php user lists}}.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/apt/privacy-policy.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/privacy-policy.apt b/src/site/apt/privacy-policy.apt
deleted file mode 100644
index ea16972..0000000
--- a/src/site/apt/privacy-policy.apt
+++ /dev/null
@@ -1,49 +0,0 @@
-~~ Licensed to the Apache Software Foundation (ASF) under one or more
-~~ contributor license agreements. See the NOTICE file distributed with
-~~ this work for additional information regarding copyright ownership.
-~~ The ASF licenses this file to You under the Apache License, Version 2.0
-~~ (the "License"); you may not use this file except in compliance with
-~~ the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing, software
-~~ distributed under the License is distributed on an "AS IS" BASIS,
-~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-~~ See the License for the specific language governing permissions and
-~~ limitations under the License.
- ------
- Privacy policy
- ------
- ------
- ------
-
-Privacy policy
-
- Information about your use of this website is collected using server access logs and a tracking cookie. The
- collected information consists of the following:
-
- * The IP address from which you access the website;
-
- * The type of browser and operating system you use to access our site;
-
- * The date and time you access our site;
-
- * The pages you visit; and
-
- * The addresses of pages from where you followed a link to our site.
-
- []
-
- Part of this information is gathered using a tracking cookie set by the
- {{{http://www.google.com/analytics/}Google Analytics}} service and handled by Google as described in their
- {{{http://www.google.com/privacy.html}privacy policy}}. See your browser documentation for instructions on how to
- disable the cookie if you prefer not to share this data with Google.
-
- We use the gathered information to help us make our site more useful to visitors and to better understand how
- and when our site is used. We do not track or collect personally identifiable information or associate gathered
- data with any personally identifying information from other sources.
-
- By using this website, you consent to the collection of this data in the manner and for the purpose described
- above.
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/apt/volunteering.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/volunteering.apt b/src/site/apt/volunteering.apt
deleted file mode 100644
index 9b660c2..0000000
--- a/src/site/apt/volunteering.apt
+++ /dev/null
@@ -1,44 +0,0 @@
-~~ Licensed to the Apache Software Foundation (ASF) under one or more
-~~ contributor license agreements. See the NOTICE file distributed with
-~~ this work for additional information regarding copyright ownership.
-~~ The ASF licenses this file to You under the Apache License, Version 2.0
-~~ (the "License"); you may not use this file except in compliance with
-~~ the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing, software
-~~ distributed under the License is distributed on an "AS IS" BASIS,
-~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-~~ See the License for the specific language governing permissions and
-~~ limitations under the License.
- ------
-Volunteering
- ------
- ------
- ------
-
-On Volunteering
-
- If you want to volunteer and help with developing Apache log4php, you are highly encouraged to
- read {{{http://www.apache.org/foundation/getinvolved.html}Apache getting involved}}. If you have
- questions on that document, we might be able to answer them on the developers mailinglist.
-
- The best way to contribute is to identify for yourself things that you think are broken, or could
- be improved, and then propose a patch. A couple of ways to identify possible candidates:
-
- * Have you used Apache log4php, and wished it would do something a little more? or a little
- different? In open source circles, people often get involved initially by "scratching your
- own itch" as the saying goes.
-
- * Have a look at the {{{https://issues.apache.org/jira/browse/LOG4PHP}bug reports}} for the
- log4php project, and seen any bugs that you can create a patch for.
-
- * Check out the project {{{http://wiki.apache.org/logging-log4php/TODO}todo list}} for things that
- have already been thought about, but just are not done yet.
-
- * If you are apt at graphic design, Apache log4php is
- {{{http://wiki.apache.org/logging-log4php/LogoProposals}looking for a logo}}. Consider donating
- one.
-
- []
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/cse.xml
----------------------------------------------------------------------
diff --git a/src/site/cse.xml b/src/site/cse.xml
deleted file mode 100644
index 10740a6..0000000
--- a/src/site/cse.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<GoogleCustomizations>
- <CustomSearchEngine id="2bsldg43-_4" creator="016746456102595360368" keywords="log4php PHP logging framework Apache logger appender" language="en" encoding="UTF-8">
- <Title>Apache log4php</Title>
- <Description>Engine for searching the Apache log4php web site.</Description>
- <Context>
- <BackgroundLabels>
- <Label name="_cse_2bsldg43-_4" mode="FILTER" />
- <Label name="_cse_exclude_2bsldg43-_4" mode="ELIMINATE" />
- </BackgroundLabels>
- </Context>
- <LookAndFeel nonprofit="true" />
- <AdSense />
- <EnterpriseAccount />
- <commerce_search_security_setting />
- <autocomplete_settings />
- </CustomSearchEngine>
- <Annotations>
- <!-- Include log4php web -->
- <Annotation about="logging.apache.org/log4php*">
- <Label name="_cse_2bsldg43-_4" />
- </Annotation>
- <!-- Exclude code coverage -->
- <Annotation about="logging.apache.org/log4php/coverage-report*">
- <Label name="_cse_exclude_2bsldg43-_4" />
- </Annotation>
- <!-- Exclude api docs -->
- <Annotation about="logging.apache.org/log4php/apidocs*">
- <Label name="_cse_exclude_2bsldg43-_4" />
- </Annotation>
- </Annotations>
-</GoogleCustomizations>
\ No newline at end of file
[41/43] git commit: Made sure trigger_error always throws a warning,
not error
Posted by ih...@apache.org.
Made sure trigger_error always throws a warning, not error
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/b178d461
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/b178d461
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/b178d461
Branch: refs/heads/v3
Commit: b178d4612df665d7488b8be4916d9801e7f64bdf
Parents: dfa2132
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 15:36:34 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 15:36:34 2013 +0100
----------------------------------------------------------------------
src/Configuration/adapters/IniAdapter.php | 2 +-
src/Renderers/RendererMap.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/b178d461/src/Configuration/adapters/IniAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/IniAdapter.php b/src/Configuration/adapters/IniAdapter.php
index fcc50e2..93a71d4 100644
--- a/src/Configuration/adapters/IniAdapter.php
+++ b/src/Configuration/adapters/IniAdapter.php
@@ -272,7 +272,7 @@ class IniAdapter implements AdapterInterface
}
}
- trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
+ trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.", E_USER_WARNING);
}
/**
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/b178d461/src/Renderers/RendererMap.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererMap.php b/src/Renderers/RendererMap.php
index 74e5977..c3cec35 100644
--- a/src/Renderers/RendererMap.php
+++ b/src/Renderers/RendererMap.php
@@ -69,14 +69,14 @@ class RendererMap
}
if (!isset($renderer)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
+ trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.", E_USER_WARNING);
return;
}
// Check the class implements the right interface
if (!($renderer instanceof RendererInterface)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
+ trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.", E_USER_WARNING);
return;
}
@@ -101,7 +101,7 @@ class RendererMap
{
// Check the class exists
if (!class_exists($renderingClass)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
+ trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.", E_USER_WARNING);
return;
}
@@ -111,7 +111,7 @@ class RendererMap
// Check the class implements the right interface
if (!($renderer instanceof RendererInterface)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
+ trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.", E_USER_WARNING);
return;
}
[24/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/LoggingEvent.php
----------------------------------------------------------------------
diff --git a/src/LoggingEvent.php b/src/LoggingEvent.php
new file mode 100644
index 0000000..f0fd7e3
--- /dev/null
+++ b/src/LoggingEvent.php
@@ -0,0 +1,366 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * The internal representation of logging event.
+ */
+class LoggingEvent {
+
+ private static $startTime;
+
+ /**
+ * @var string Fully Qualified Class Name of the calling category class.
+ */
+ private $fqcn;
+
+ /**
+ * @var Logger reference
+ */
+ private $logger;
+
+ /**
+ * The category (logger) name.
+ * This field will be marked as private in future
+ * releases. Please do not access it directly.
+ * Use the {@link getLoggerName()} method instead.
+ * @deprecated
+ */
+ private $categoryName;
+
+ /**
+ * Level of the logging event.
+ * @var Level
+ */
+ protected $level;
+
+ /**
+ * The nested diagnostic context (NDC) of logging event.
+ * @var string
+ */
+ private $ndc;
+
+ /**
+ * Have we tried to do an NDC lookup? If we did, there is no need
+ * to do it again. Note that its value is always false when
+ * serialized. Thus, a receiving SocketNode will never use it's own
+ * (incorrect) NDC. See also writeObject method.
+ * @var boolean
+ */
+ private $ndcLookupRequired = true;
+
+ /**
+ * @var mixed The application supplied message of logging event.
+ */
+ private $message;
+
+ /**
+ * The application supplied message rendered through the log4php
+ * objet rendering mechanism. At present renderedMessage == message.
+ * @var string
+ */
+ private $renderedMessage;
+
+ /**
+ * The name of thread in which this logging event was generated.
+ * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
+ * @var mixed
+ */
+ private $threadName;
+
+ /**
+ * The number of seconds elapsed from 1/1/1970 until logging event
+ * was created plus microseconds if available.
+ * @var float
+ */
+ public $timeStamp;
+
+ /**
+ * @var LocationInfo Location information for the caller.
+ */
+ private $locationInfo;
+
+ /**
+ * @var ThrowableInformation log4php internal representation of throwable
+ */
+ private $throwableInfo;
+
+ /**
+ * Instantiate a LoggingEvent from the supplied parameters.
+ *
+ * Except {@link $timeStamp} all the other fields of
+ * LoggingEvent are filled when actually needed.
+ *
+ * @param string $fqcn name of the caller class.
+ * @param mixed $logger The {@link Logger} category of this event or the logger name.
+ * @param Level $level The level of this event.
+ * @param mixed $message The message of this event.
+ * @param integer $timeStamp the timestamp of this logging event.
+ * @param Exception $throwable The throwable associated with logging event
+ */
+ public function __construct($fqcn, $logger, Level $level, $message, $timeStamp = null, $throwable = null) {
+ $this->fqcn = $fqcn;
+ if($logger instanceof Logger) {
+ $this->logger = $logger;
+ $this->categoryName = $logger->getName();
+ } else {
+ $this->categoryName = strval($logger);
+ }
+ $this->level = $level;
+ $this->message = $message;
+ if($timeStamp !== null && is_numeric($timeStamp)) {
+ $this->timeStamp = $timeStamp;
+ } else {
+ $this->timeStamp = microtime(true);
+ }
+
+ if (isset($throwable) && $throwable instanceof \Exception) {
+ $this->throwableInfo = new ThrowableInformation($throwable);
+ }
+ }
+
+ /**
+ * Returns the full qualified classname.
+ * TODO: PHP does contain namespaces in 5.3. Those should be returned too,
+ */
+ public function getFullQualifiedClassname() {
+ return $this->fqcn;
+ }
+
+ /**
+ * Set the location information for this logging event. The collected
+ * information is cached for future use.
+ *
+ * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
+ * to collect informations about caller.</p>
+ * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
+ * @return LocationInfo
+ */
+ public function getLocationInformation() {
+ if($this->locationInfo === null) {
+
+ $locationInfo = array();
+ $trace = debug_backtrace();
+ $prevHop = null;
+
+ // make a downsearch to identify the caller
+ $hop = array_pop($trace);
+ while($hop !== null) {
+ if(isset($hop['class'])) {
+ $className = $hop['class'];
+
+ if($className === "Apache\\Log4php\\Logger" ||
+ $className === "Apache\\Log4php\\RootLogger") {
+ $locationInfo['line'] = $hop['line'];
+ $locationInfo['file'] = $hop['file'];
+ break;
+ }
+ }
+ $prevHop = $hop;
+ $hop = array_pop($trace);
+ }
+ $locationInfo['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') {
+
+ $locationInfo['function'] = $prevHop['function'];
+ } else {
+ $locationInfo['function'] = 'main';
+ }
+
+ $this->locationInfo = new LocationInfo($locationInfo, $this->fqcn);
+ }
+ return $this->locationInfo;
+ }
+
+ /**
+ * Return the level of this event. Use this form instead of directly
+ * accessing the {@link $level} field.
+ * @return Level
+ */
+ public function getLevel() {
+ return $this->level;
+ }
+
+ /**
+ * Returns the logger which created the event.
+ * @return Logger
+ */
+ public function getLogger() {
+ return $this->logger;
+ }
+
+ /**
+ * Return the name of the logger. Use this form instead of directly
+ * accessing the {@link $categoryName} field.
+ * @return string
+ */
+ public function getLoggerName() {
+ return $this->categoryName;
+ }
+
+ /**
+ * Return the message for this logging event.
+ * @return mixed
+ */
+ public function getMessage() {
+ return $this->message;
+ }
+
+ /**
+ * This method returns the NDC for this event. It will return the
+ * correct content even if the event was generated in a different
+ * thread or even on a different machine. The {@link NDC::get()} method
+ * should <b>never</b> be called directly.
+ * @return string
+ */
+ public function getNDC() {
+ if($this->ndcLookupRequired) {
+ $this->ndcLookupRequired = false;
+ $this->ndc = NDC::get();
+ }
+ return $this->ndc;
+ }
+
+ /**
+ * Returns the the context corresponding to the <code>key</code>
+ * parameter.
+ * @return string
+ */
+ public function getMDC($key) {
+ return MDC::get($key);
+ }
+
+ /**
+ * Returns the entire MDC context.
+ * @return array
+ */
+ public function getMDCMap () {
+ return MDC::getMap();
+ }
+
+ /**
+ * Render message.
+ * @return string
+ */
+ public function getRenderedMessage() {
+ if($this->renderedMessage === null and $this->message !== null) {
+ if(is_string($this->message)) {
+ $this->renderedMessage = $this->message;
+ } else {
+ $rendererMap = Logger::getHierarchy()->getRendererMap();
+ $this->renderedMessage= $rendererMap->findAndRender($this->message);
+ }
+ }
+ return $this->renderedMessage;
+ }
+
+ /**
+ * Returns the time when the application started, as a UNIX timestamp
+ * with microseconds.
+ * @return float
+ */
+ public static function getStartTime() {
+ if(!isset(self::$startTime)) {
+ self::$startTime = microtime(true);
+ }
+ return self::$startTime;
+ }
+
+ /**
+ * @return float
+ */
+ public function getTimeStamp() {
+ return $this->timeStamp;
+ }
+
+ /**
+ * Returns the time in seconds passed from the beginning of execution to
+ * the time the event was constructed.
+ *
+ * @return float Seconds with microseconds in decimals.
+ */
+ public function getRelativeTime() {
+ return $this->timeStamp - self::$startTime;
+ }
+
+ /**
+ * Returns the time in milliseconds passed from the beginning of execution
+ * to the time the event was constructed.
+ *
+ * @deprecated This method has been replaced by getRelativeTime which
+ * does not perform unneccesary multiplication and formatting.
+ *
+ * @return integer
+ */
+ public function getTime() {
+ $eventTime = $this->getTimeStamp();
+ $eventStartTime = LoggingEvent::getStartTime();
+ return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getThreadName() {
+ if ($this->threadName === null) {
+ $this->threadName = (string)getmypid();
+ }
+ return $this->threadName;
+ }
+
+ /**
+ * @return mixed ThrowableInformation
+ */
+ public function getThrowableInformation() {
+ return $this->throwableInfo;
+ }
+
+ /**
+ * Serialize this object
+ * @return string
+ */
+ public function toString() {
+ serialize($this);
+ }
+
+ /**
+ * Avoid serialization of the {@link $logger} object
+ */
+ public function __sleep() {
+ return array(
+ 'fqcn',
+ 'categoryName',
+ 'level',
+ 'ndc',
+ 'ndcLookupRequired',
+ 'message',
+ 'renderedMessage',
+ 'threadName',
+ 'timeStamp',
+ 'locationInfo',
+ );
+ }
+
+}
+
+LoggingEvent::getStartTime();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/MDC.php
----------------------------------------------------------------------
diff --git a/src/MDC.php b/src/MDC.php
new file mode 100644
index 0000000..9f911c6
--- /dev/null
+++ b/src/MDC.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * The MDC class provides _mapped diagnostic contexts_.
+ *
+ * A Mapped Diagnostic Context, or MDC in short, is an instrument for
+ * distinguishing interleaved log output from different sources. Log output
+ * is typically interleaved when a server handles multiple clients
+ * near-simultaneously.
+ *
+ * This class is similar to the {@link NDC} class except that
+ * it is based on a map instead of a stack.
+ *
+ * @since 0.3
+ *
+ */
+class MDC {
+
+ /** Holds the context map. */
+ private static $map = array();
+
+ /**
+ * Stores a context value as identified with the key parameter into the
+ * context map.
+ *
+ * @param string $key the key
+ * @param string $value the value
+ */
+ public static function put($key, $value) {
+ self::$map[$key] = $value;
+ }
+
+ /**
+ * Returns the context value identified by the key parameter.
+ *
+ * @param string $key The key.
+ * @return string The context or an empty string if no context found
+ * for given key.
+ */
+ public static function get($key) {
+ return isset(self::$map[$key]) ? self::$map[$key] : '';
+ }
+
+ /**
+ * Returns the contex map as an array.
+ * @return array The MDC context map.
+ */
+ public static function getMap() {
+ return self::$map;
+ }
+
+ /**
+ * Removes the the context identified by the key parameter.
+ *
+ * Only affects user mappings, not $_ENV or $_SERVER.
+ *
+ * @param string $key The key to be removed.
+ */
+ public static function remove($key) {
+ unset(self::$map[$key]);
+ }
+
+ /**
+ * Clears the mapped diagnostic context.
+ */
+ public static function clear() {
+ self::$map = array();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/NDC.php
----------------------------------------------------------------------
diff --git a/src/NDC.php b/src/NDC.php
new file mode 100644
index 0000000..b3de74a
--- /dev/null
+++ b/src/NDC.php
@@ -0,0 +1,184 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * The NDC class implements <i>nested diagnostic contexts</i>.
+ *
+ * NDC was defined by Neil Harrison in the article "Patterns for Logging
+ * Diagnostic Messages" part of the book <i>"Pattern Languages of
+ * Program Design 3"</i> edited by Martin et al.
+ *
+ * A Nested Diagnostic Context, or NDC in short, is an instrument
+ * to distinguish interleaved log output from different sources. Log
+ * output is typically interleaved when a server handles multiple
+ * clients near-simultaneously.
+ *
+ * This class is similar to the {@link MDC} class except that it is
+ * based on a stack instead of a map.
+ *
+ * Interleaved log output can still be meaningful if each log entry
+ * from different contexts had a distinctive stamp. This is where NDCs
+ * come into play.
+ *
+ * <b>Note that NDCs are managed on a per thread basis</b>.
+ *
+ * NDC operations such as {@link push()}, {@link pop()},
+ * {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
+ * affect the NDC of the <i>current</i> thread only. NDCs of other
+ * threads remain unaffected.
+ *
+ * For example, a servlet can build a per client request NDC
+ * consisting the clients host name and other information contained in
+ * the the request. <i>Cookies</i> are another source of distinctive
+ * information. To build an NDC one uses the {@link push()}
+ * operation.
+ *
+ * Simply put,
+ *
+ * - Contexts can be nested.
+ * - When entering a context, call <kbd>NDC::push()</kbd>
+ * As a side effect, if there is no nested diagnostic context for the
+ * current thread, this method will create it.
+ * - When leaving a context, call <kbd>NDC::pop()</kbd>
+ * - <b>When exiting a thread make sure to call {@link remove()}</b>
+ *
+ * There is no penalty for forgetting to match each
+ * <kbd>push</kbd> operation with a corresponding <kbd>pop</kbd>,
+ * except the obvious mismatch between the real application context
+ * and the context set in the NDC.
+ *
+ * If configured to do so, {@link LoggerPatternLayout}
+ * instances automatically retrieve the nested diagnostic
+ * context for the current thread without any user intervention.
+ * Hence, even if a servlet is serving multiple clients
+ * simultaneously, the logs emanating from the same code (belonging to
+ * the same category) can still be distinguished because each client
+ * request will have a different NDC tag.
+ *
+ * @since 0.3
+ */
+class NDC {
+
+ /** This is the repository of NDC stack */
+ private static $stack = array();
+
+ /**
+ * Clear any nested diagnostic information if any. This method is
+ * useful in cases where the same thread can be potentially used
+ * over and over in different unrelated contexts.
+ *
+ * <p>This method is equivalent to calling the {@link setMaxDepth()}
+ * method with a zero <var>maxDepth</var> argument.
+ */
+ public static function clear() {
+ self::$stack = array();
+ }
+
+ /**
+ * Never use this method directly, use the {@link LoggingEvent::getNDC()} method instead.
+ * @return array
+ */
+ public static function get() {
+ return implode(' ', self::$stack);
+ }
+
+ /**
+ * Get the current nesting depth of this diagnostic context.
+ *
+ * @see setMaxDepth()
+ * @return integer
+ */
+ public static function getDepth() {
+ return count(self::$stack);
+ }
+
+ /**
+ * Clients should call this method before leaving a diagnostic
+ * context.
+ *
+ * <p>The returned value is the value that was pushed last. If no
+ * context is available, then the empty string "" is returned.</p>
+ *
+ * @return string The innermost diagnostic context.
+ */
+ public static function pop() {
+ if(count(self::$stack) > 0) {
+ return array_pop(self::$stack);
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Looks at the last diagnostic context at the top of this NDC
+ * without removing it.
+ *
+ * <p>The returned value is the value that was pushed last. If no
+ * context is available, then the empty string "" is returned.</p>
+ * @return string The innermost diagnostic context.
+ */
+ public static function peek() {
+ if(count(self::$stack) > 0) {
+ return end(self::$stack);
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Push new diagnostic context information for the current thread.
+ *
+ * <p>The contents of the <var>message</var> parameter is
+ * determined solely by the client.
+ *
+ * @param string $message The new diagnostic context information.
+ */
+ public static function push($message) {
+ array_push(self::$stack, (string)$message);
+ }
+
+ /**
+ * Remove the diagnostic context for this thread.
+ */
+ public static function remove() {
+ NDC::clear();
+ }
+
+ /**
+ * 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()
+ */
+ public static function setMaxDepth($maxDepth) {
+ $maxDepth = (int)$maxDepth;
+ if(NDC::getDepth() > $maxDepth) {
+ self::$stack = array_slice(self::$stack, 0, $maxDepth);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/AbstractConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/AbstractConverter.php b/src/Pattern/AbstractConverter.php
new file mode 100644
index 0000000..dc13f4b
--- /dev/null
+++ b/src/Pattern/AbstractConverter.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\Helpers\FormattingInfo;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * AbstractConverter is an abstract class that provides the formatting
+ * functionality that derived classes need.
+ *
+ * <p>Conversion specifiers in a conversion patterns are parsed to
+ * individual PatternConverters. Each of which is responsible for
+ * converting a logging event in a converter specific manner.</p>
+ * @since 0.3
+ */
+abstract class AbstractConverter {
+
+ /**
+ * Next converter in the converter chain.
+ * @var AbstractConverter
+ */
+ public $next = null;
+
+ /**
+ * Formatting information, parsed from pattern modifiers.
+ * @var FormattingInfo
+ */
+ protected $formattingInfo;
+
+ /**
+ * Converter-specific formatting options.
+ * @var array
+ */
+ protected $option;
+
+ /**
+ * Constructor
+ * @param FormattingInfo $formattingInfo
+ * @param array $option
+ */
+ public function __construct(FormattingInfo $formattingInfo = null, $option = null) {
+ $this->formattingInfo = $formattingInfo;
+ $this->option = $option;
+ $this->activateOptions();
+ }
+
+ /**
+ * Called in constructor. Converters which need to process the options
+ * can override this method.
+ */
+ public function activateOptions() { }
+
+ /**
+ * Converts the logging event to the desired format. Derived pattern
+ * converters must implement this method.
+ *
+ * @param LoggingEvent $event
+ */
+ abstract public function convert(LoggingEvent $event);
+
+ /**
+ * Converts the event and formats it according to setting in the
+ * Formatting information object.
+ *
+ * @param string &$sbuf string buffer to write to
+ * @param LoggingEvent $event Event to be formatted.
+ */
+ public function format(&$sbuf, $event) {
+ $string = $this->convert($event);
+
+ if (!isset($this->formattingInfo)) {
+ $sbuf .= $string;
+ return;
+ }
+
+ $fi = $this->formattingInfo;
+
+ // Empty string
+ if($string === '' || is_null($string)) {
+ if($fi->min > 0) {
+ $sbuf .= str_repeat(' ', $fi->min);
+ }
+ return;
+ }
+
+ $len = strlen($string);
+
+ // Trim the string if needed
+ if($len > $fi->max) {
+ if ($fi->trimLeft) {
+ $sbuf .= substr($string, $len - $fi->max, $fi->max);
+ } else {
+ $sbuf .= substr($string , 0, $fi->max);
+ }
+ }
+
+ // Add padding if needed
+ else if($len < $fi->min) {
+ if($fi->padLeft) {
+ $sbuf .= str_repeat(' ', $fi->min - $len);
+ $sbuf .= $string;
+ } else {
+ $sbuf .= $string;
+ $sbuf .= str_repeat(' ', $fi->min - $len);
+ }
+ }
+
+ // No action needed
+ else {
+ $sbuf .= $string;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/ClassConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ClassConverter.php b/src/Pattern/ClassConverter.php
new file mode 100644
index 0000000..b5e658c
--- /dev/null
+++ b/src/Pattern/ClassConverter.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\Helpers\Utils;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the fully qualified class name of the class from which the logging
+ * request was issued.
+ * @since 2.3
+ */
+class ClassConverter extends AbstractConverter {
+
+ /** Length to which to shorten the class name. */
+ private $length;
+
+ /** Holds processed class names. */
+ private $cache = array();
+
+ public function activateOptions() {
+ // Parse the option (desired output length)
+ if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
+ $this->length = (integer) $this->option;
+ }
+ }
+
+ public function convert(LoggingEvent $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] = Utils::shortenClassName($name, $this->length);
+ }
+
+ // If no length is specified return the full class name
+ else {
+ $this->cache[$name] = $name;
+ }
+ }
+
+ return $this->cache[$name];
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/CookieConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/CookieConverter.php b/src/Pattern/CookieConverter.php
new file mode 100644
index 0000000..69b5738
--- /dev/null
+++ b/src/Pattern/CookieConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+/**
+ * Returns a value from the $_COOKIE superglobal array corresponding to the
+ * given key. If no key is given, return all values.
+ *
+ * Options:
+ * [0] $_COOKIE key value
+ *
+ * @since 2.3
+ */
+class CookieConverter extends SuperglobalConverter {
+ protected $name = '_COOKIE';
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/DateConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/DateConverter.php b/src/Pattern/DateConverter.php
new file mode 100644
index 0000000..5a1ad4a
--- /dev/null
+++ b/src/Pattern/DateConverter.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the date/time of the logging request.
+ *
+ * Option: the datetime format, as used by the date() function. If
+ * the option is not given, the default format 'c' will be used.
+ *
+ * There are several "special" values which can be given for this option:
+ * 'ISO8601', 'ABSOLUTE' and 'DATE'.
+ * @since 2.3
+ */
+class DateConverter extends AbstractConverter {
+
+ const DATE_FORMAT_ISO8601 = 'c';
+
+ const DATE_FORMAT_ABSOLUTE = 'H:i:s';
+
+ const DATE_FORMAT_DATE = 'd M Y H:i:s.u';
+
+ private $format = self::DATE_FORMAT_ISO8601;
+
+ private $specials = array(
+ 'ISO8601' => self::DATE_FORMAT_ISO8601,
+ 'ABSOLUTE' => self::DATE_FORMAT_ABSOLUTE,
+ 'DATE' => self::DATE_FORMAT_DATE,
+ );
+
+ private $useLocalDate = false;
+
+ public function activateOptions() {
+
+ // Parse the option (date format)
+ if (!empty($this->option)) {
+ if(isset($this->specials[$this->option])) {
+ $this->format = $this->specials[$this->option];
+ } else {
+ $this->format = $this->option;
+ }
+ }
+
+ // Check whether the pattern contains milliseconds (u)
+ if (preg_match('/(?<!\\\\)u/', $this->format)) {
+ $this->useLocalDate = true;
+ }
+ }
+
+ public function convert(LoggingEvent $event) {
+ if ($this->useLocalDate) {
+ return $this->date($this->format, $event->getTimeStamp());
+ }
+ return date($this->format, $event->getTimeStamp());
+ }
+
+ /**
+ * Currently, PHP date() function always returns zeros for milliseconds (u)
+ * on Windows. This is a replacement function for date() which correctly
+ * displays milliseconds on all platforms.
+ *
+ * It is slower than PHP date() so it should only be used if necessary.
+ */
+ private function date($format, $utimestamp) {
+ $timestamp = floor($utimestamp);
+ $ms = floor(($utimestamp - $timestamp) * 1000);
+ $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
+
+ return date(preg_replace('`(?<!\\\\)u`', $ms, $format), $timestamp);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/EnvironmentConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/EnvironmentConverter.php b/src/Pattern/EnvironmentConverter.php
new file mode 100644
index 0000000..7be0272
--- /dev/null
+++ b/src/Pattern/EnvironmentConverter.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+/**
+ * Returns a value from the $_ENV superglobal array corresponding to the
+ * given key.
+ *
+ * Options:
+ * [0] $_ENV key value
+ *
+ *
+ * @since 2.3
+ */
+class EnvironmentConverter extends SuperglobalConverter {
+ protected $name = '_ENV';
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/FileConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/FileConverter.php b/src/Pattern/FileConverter.php
new file mode 100644
index 0000000..809192d
--- /dev/null
+++ b/src/Pattern/FileConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the name of the file from which the logging request was issued.
+ * @since 2.3
+ */
+class FileConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return $event->getLocationInformation()->getFileName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/LevelConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LevelConverter.php b/src/Pattern/LevelConverter.php
new file mode 100644
index 0000000..3b42fe0
--- /dev/null
+++ b/src/Pattern/LevelConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the event's level.
+ * @since 2.3
+ */
+class LevelConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return $event->getLevel()->toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/LineConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LineConverter.php b/src/Pattern/LineConverter.php
new file mode 100644
index 0000000..659fa11
--- /dev/null
+++ b/src/Pattern/LineConverter.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the line number within the file from which the logging request was
+ * issued.
+ * @since 2.3
+ */
+class LineConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return $event->getLocationInformation()->getLineNumber();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/LiteralConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LiteralConverter.php b/src/Pattern/LiteralConverter.php
new file mode 100644
index 0000000..089fa7f
--- /dev/null
+++ b/src/Pattern/LiteralConverter.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the literal value passed in the constructor, without modifications.
+ * @since 2.3
+ */
+class LiteralConverter extends AbstractConverter {
+
+ private $literalValue;
+
+ public function __construct($literalValue) {
+ $this->literalValue = $literalValue;
+ }
+
+ public function convert(LoggingEvent $event) {
+ return $this->literalValue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/LocationConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LocationConverter.php b/src/Pattern/LocationConverter.php
new file mode 100644
index 0000000..4334ec7
--- /dev/null
+++ b/src/Pattern/LocationConverter.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the line number within the file from which the logging request was
+ * issued.
+ * @since 2.3
+ */
+class LocationConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return
+ $event->getLocationInformation()->getClassName() . '.' .
+ $event->getLocationInformation()->getMethodName() . '(' .
+ $event->getLocationInformation()->getFileName() . ':' .
+ $event->getLocationInformation()->getLineNumber() . ')';
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/LoggerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LoggerConverter.php b/src/Pattern/LoggerConverter.php
new file mode 100644
index 0000000..0433659
--- /dev/null
+++ b/src/Pattern/LoggerConverter.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\Helpers\Utils;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the name of the logger which created the logging request.
+ *
+ * Takes one option, which is an integer. If the option is given, the logger
+ * name will be shortened to the given length, if possible.
+ * @since 2.3
+ */
+class LoggerConverter extends AbstractConverter {
+
+ /** Length to which to shorten the name. */
+ private $length;
+
+ /** Holds processed logger names. */
+ private $cache = array();
+
+ public function activateOptions() {
+ // Parse the option (desired output length)
+ if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
+ $this->length = (integer) $this->option;
+ }
+ }
+
+ public function convert(LoggingEvent $event) {
+ $name = $event->getLoggerName();
+
+ if (!isset($this->cache[$name])) {
+
+ // If length is set return shortened logger name
+ if (isset($this->length)) {
+ $this->cache[$name] = Utils::shortenClassName($name, $this->length);
+ }
+
+ // If no length is specified return full logger name
+ else {
+ $this->cache[$name] = $name;
+ }
+ }
+
+ return $this->cache[$name];
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/MdcConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MdcConverter.php b/src/Pattern/MdcConverter.php
new file mode 100644
index 0000000..cb50c8e
--- /dev/null
+++ b/src/Pattern/MdcConverter.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the Mapped Diagnostic Context value corresponding to the given key.
+ *
+ * Options:
+ * [0] the MDC key
+ * @since 2.3
+ */
+class MdcConverter extends AbstractConverter {
+
+ private $key;
+
+ public function activateOptions() {
+ if (isset($this->option) && $this->option !== '') {
+ $this->key = $this->option;
+ }
+ }
+
+ public function convert(LoggingEvent $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);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/MessageConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MessageConverter.php b/src/Pattern/MessageConverter.php
new file mode 100644
index 0000000..acd53d8
--- /dev/null
+++ b/src/Pattern/MessageConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the logged message.
+ * @since 2.3
+ */
+class MessageConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return $event->getRenderedMessage();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/MethodConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MethodConverter.php b/src/Pattern/MethodConverter.php
new file mode 100644
index 0000000..d0c29e8
--- /dev/null
+++ b/src/Pattern/MethodConverter.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the name of the function or method from which the logging request
+ * was issued.
+ * @since 2.3
+ */
+class MethodConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return $event->getLocationInformation()->getMethodName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/NdcConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/NdcConverter.php b/src/Pattern/NdcConverter.php
new file mode 100644
index 0000000..fb0027e
--- /dev/null
+++ b/src/Pattern/NdcConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the full Nested Diagnostic Context.
+ * @since 2.3
+ */
+class NdcConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return $event->getNDC();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/NewLineConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/NewLineConverter.php b/src/Pattern/NewLineConverter.php
new file mode 100644
index 0000000..2e3f7e6
--- /dev/null
+++ b/src/Pattern/NewLineConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns platform-specific newline character(s).
+ * @since 2.3
+ */
+class NewLineConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return PHP_EOL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/ProcessConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ProcessConverter.php b/src/Pattern/ProcessConverter.php
new file mode 100644
index 0000000..4ba2151
--- /dev/null
+++ b/src/Pattern/ProcessConverter.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the PID of the current process.
+ * @since 2.3
+ */
+class ProcessConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ return getmypid();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/RelativeConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/RelativeConverter.php b/src/Pattern/RelativeConverter.php
new file mode 100644
index 0000000..d6e3111
--- /dev/null
+++ b/src/Pattern/RelativeConverter.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the number of milliseconds elapsed since the start of the
+ * application until the creation of the logging event.
+ * @since 2.3
+ */
+class RelativeConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ $ts = $event->getRelativeTime();
+ return number_format($ts, 4);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/RequestConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/RequestConverter.php b/src/Pattern/RequestConverter.php
new file mode 100644
index 0000000..5440e75
--- /dev/null
+++ b/src/Pattern/RequestConverter.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns a value from the $_REQUEST superglobal array corresponding to the
+ * given key.
+ *
+ * Options:
+ * [0] $_REQUEST key value
+ *
+ *
+ * @since 2.3
+ */
+class RequestConverter extends SuperglobalConverter {
+ protected $name = '_REQUEST';
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/ServerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ServerConverter.php b/src/Pattern/ServerConverter.php
new file mode 100644
index 0000000..c6085ce
--- /dev/null
+++ b/src/Pattern/ServerConverter.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns a value from the $_SERVER superglobal array corresponding to the
+ * given key.
+ *
+ * Options:
+ * [0] $_SERVER key value
+ *
+ *
+ * @since 2.3
+ */
+class ServerConverter extends SuperglobalConverter {
+ protected $name = '_SERVER';
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/SessionConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SessionConverter.php b/src/Pattern/SessionConverter.php
new file mode 100644
index 0000000..c5d812b
--- /dev/null
+++ b/src/Pattern/SessionConverter.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns a value from the $_SESSION superglobal array corresponding to the
+ * given key.
+ *
+ * Options:
+ * [0] $_SESSION key value
+ *
+ *
+ * @since 2.3
+ */
+class SessionConverter extends SuperglobalConverter {
+ protected $name = '_SESSION';
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/SessionIdConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SessionIdConverter.php b/src/Pattern/SessionIdConverter.php
new file mode 100644
index 0000000..c5d622c
--- /dev/null
+++ b/src/Pattern/SessionIdConverter.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns the active session ID, or an empty string if out of session.
+ * @since 2.3
+ */
+class SessionIdConverter extends AbstractConverter {
+ public function convert(LoggingEvent $event) {
+ return session_id();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/SuperglobalConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SuperglobalConverter.php b/src/Pattern/SuperglobalConverter.php
new file mode 100644
index 0000000..c43d0c0
--- /dev/null
+++ b/src/Pattern/SuperglobalConverter.php
@@ -0,0 +1,100 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Returns a value from a superglobal array corresponding to the
+ * given key.
+ *
+ * Option: the key to look up within the superglobal array
+ *
+ * Also, it is possible that a superglobal variable is not populated by PHP
+ * because of the settings in the variables-order ini directive. In this case
+ * the converter will return an empty value.
+ *
+ * @see http://php.net/manual/en/language.variables.superglobals.php
+ * @see http://www.php.net/manual/en/ini.core.php#ini.variables-order
+ * @since 2.3
+ */
+abstract class SuperglobalConverter extends AbstractConverter {
+
+ /**
+ * Name of the superglobal variable, to be defined by subclasses.
+ * For example: "_SERVER" or "_ENV".
+ */
+ protected $name;
+
+ protected $value = '';
+
+ public function activateOptions() {
+ // Read the key from options array
+ if (isset($this->option) && $this->option !== '') {
+ $key = $this->option;
+ }
+
+ /*
+ * There is a bug in PHP which doesn't allow superglobals to be
+ * accessed when their name is stored in a variable, e.g.:
+ *
+ * $name = '_SERVER';
+ * $array = $$name;
+ *
+ * This code does not work when run from within a method (only when run
+ * in global scope). But the following code does work:
+ *
+ * $name = '_SERVER';
+ * global $$name;
+ * $array = $$name;
+ *
+ * That's why global is used here.
+ */
+ global ${$this->name};
+
+ // Check the given superglobal exists. It is possible that it is not initialized.
+ if (!isset(${$this->name})) {
+ $class = basename(get_class($this));
+ trigger_error("log4php: $class: Cannot find superglobal variable \${$this->name}.", E_USER_WARNING);
+ return;
+ }
+
+ $source = ${$this->name};
+
+ // When the key is set, display the matching value
+ if (isset($key)) {
+ if (isset($source[$key])) {
+ $this->value = $source[$key];
+ }
+ }
+
+ // When the key is not set, display all values
+ else {
+ $values = array();
+ foreach($source as $key => $value) {
+ $values[] = "$key=$value";
+ }
+ $this->value = implode(', ', $values);
+ }
+ }
+
+ public function convert(LoggingEvent $event) {
+ return $this->value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Pattern/ThrowableConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ThrowableConverter.php b/src/Pattern/ThrowableConverter.php
new file mode 100644
index 0000000..f18e322
--- /dev/null
+++ b/src/Pattern/ThrowableConverter.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Pattern;
+
+/**
+ * Returns the throwable information linked to the logging event, if any.
+ * @since 2.3
+ */
+class ThrowableConverter extends AbstractConverter {
+
+ public function convert(LoggingEvent $event) {
+ $info = $event->getThrowableInformation();
+ if (isset($info)) {
+ $ex = $info->getThrowable();
+ return (string) $ex . PHP_EOL;
+ }
+ return '';
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/ReflectionUtils.php
----------------------------------------------------------------------
diff --git a/src/ReflectionUtils.php b/src/ReflectionUtils.php
new file mode 100644
index 0000000..cc39ec3
--- /dev/null
+++ b/src/ReflectionUtils.php
@@ -0,0 +1,151 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * Provides methods for reflective use on php objects
+ */
+class ReflectionUtils {
+
+ /** the target object */
+ private $obj;
+
+ /**
+ * Create a new ReflectionUtils for the specified Object.
+ * This is done in prepartion for invoking {@link setProperty()}
+ * one or more times.
+ * @param object &$obj the object for which to set properties
+ */
+ public function __construct($obj) {
+ $this->obj = $obj;
+ }
+
+ /**
+ * Set the properties of an object passed as a parameter in one
+ * go. The <code>properties</code> are parsed relative to a
+ * <code>prefix</code>.
+ *
+ * @param object $obj The object to configure.
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ */
+ // TODO: check, if this is really useful
+ public static function setPropertiesByObject($obj, $properties, $prefix) {
+ $pSetter = new ReflectionUtils($obj);
+ return $pSetter->setProperties($properties, $prefix);
+ }
+
+ /**
+ * Set the properites for the object that match the
+ * <code>prefix</code> passed as parameter.
+ *
+ * Example:
+ *
+ * $arr['xxxname'] = 'Joe';
+ * $arr['xxxmale'] = true;
+ * and prefix xxx causes setName and setMale.
+ *
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ */
+ public function setProperties($properties, $prefix) {
+ $len = strlen($prefix);
+ reset($properties);
+ while(list($key,) = each($properties)) {
+ if(strpos($key, $prefix) === 0) {
+ if(strpos($key, '.', ($len + 1)) > 0) {
+ continue;
+ }
+ $value = $properties[$key];
+ $key = substr($key, $len);
+ if($key == 'layout' and ($this->obj instanceof Appender)) {
+ continue;
+ }
+ $this->setProperty($key, $value);
+ }
+ }
+ $this->activate();
+ }
+
+ /**
+ * Set a property on this PropertySetter's Object. If successful, this
+ * method will invoke a setter method on the underlying Object. The
+ * setter is the one for the specified property name and the value is
+ * determined partly from the setter argument type and partly from the
+ * value specified in the call to this method.
+ *
+ * <p>If the setter expects a String no conversion is necessary.
+ * If it expects an int, then an attempt is made to convert 'value'
+ * to an int using new Integer(value). If the setter expects a boolean,
+ * the conversion is by new Boolean(value).
+ *
+ * @param string $name name of the property
+ * @param string $value String value of the property
+ */
+ public function setProperty($name, $value) {
+ if($value === null) {
+ return;
+ }
+
+ $method = "set" . ucfirst($name);
+
+ if(!method_exists($this->obj, $method)) {
+ throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
+ } else {
+ return call_user_func(array($this->obj, $method), $value);
+ }
+ }
+
+ public function activate() {
+ if(method_exists($this->obj, 'activateoptions')) {
+ return call_user_func(array($this->obj, 'activateoptions'));
+ }
+ }
+
+ /**
+ * Creates an instances from the given class name.
+ *
+ * @param string $classname
+ * @return an object from the class with the given classname
+ */
+ public static function createObject($class) {
+ if(!empty($class)) {
+ return new $class();
+ }
+ return null;
+ }
+
+ /**
+ * @param object $object
+ * @param string $name
+ * @param mixed $value
+ */
+ public static function setter($object, $name, $value) {
+ if (empty($name)) {
+ return false;
+ }
+ $methodName = 'set'.ucfirst($name);
+ if (method_exists($object, $methodName)) {
+ return call_user_func(array($object, $methodName), $value);
+ } else {
+ return false;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Renderers/DefaultRenderer.php
----------------------------------------------------------------------
diff --git a/src/Renderers/DefaultRenderer.php b/src/Renderers/DefaultRenderer.php
new file mode 100644
index 0000000..78b844c
--- /dev/null
+++ b/src/Renderers/DefaultRenderer.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Renderers;
+
+/**
+ * The default renderer, which is used when no other renderer is found.
+ *
+ * Renders the input using <var>print_r</var>.
+ * @since 0.3
+ */
+class DefaultRenderer implements RendererInterface {
+
+ /** @inheritdoc */
+ public function render($input) {
+ return print_r($input, true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Renderers/ExceptionRenderer.php
----------------------------------------------------------------------
diff --git a/src/Renderers/ExceptionRenderer.php b/src/Renderers/ExceptionRenderer.php
new file mode 100644
index 0000000..d625ae8
--- /dev/null
+++ b/src/Renderers/ExceptionRenderer.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Renderers;
+
+/**
+ * Renderer used for Exceptions.
+ * @since 2.1
+ */
+class ExceptionRenderer implements RendererInterface {
+
+ public function render($input) {
+
+ // Exception class has a very decent __toString method
+ // so let's just use that instead of writing lots of code.
+ return (string) $input;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Renderers/RendererInterface.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererInterface.php b/src/Renderers/RendererInterface.php
new file mode 100644
index 0000000..8bfda22
--- /dev/null
+++ b/src/Renderers/RendererInterface.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Renderers;
+
+/**
+ * Implement this interface in order to render objects to strings.
+ * @since 0.3
+ */
+interface RendererInterface {
+ /**
+ * Renders the entity passed as <var>input</var> to a string.
+ * @param mixed $input The entity to render.
+ * @return string The rendered string.
+ */
+ public function render($input);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Renderers/RendererMap.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererMap.php b/src/Renderers/RendererMap.php
new file mode 100644
index 0000000..1444d25
--- /dev/null
+++ b/src/Renderers/RendererMap.php
@@ -0,0 +1,189 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Renderers;
+
+/**
+ * Manages defined renderers and determines which renderer to use for a given
+ * input.
+ * @since 0.3
+ */
+class RendererMap {
+
+ /**
+ * Maps class names to appropriate renderers.
+ * @var array
+ */
+ private $map = array();
+
+ /**
+ * The default renderer to use if no specific renderer is found.
+ * @var RendererInterface
+ */
+ private $defaultRenderer;
+
+ public function __construct() {
+
+ // Set default config
+ $this->reset();
+ }
+
+ /**
+ * Adds a renderer to the map.
+ *
+ * If a renderer already exists for the given <var>$renderedClass</var> it
+ * will be overwritten without warning.
+ *
+ * @param string $renderedClass The name of the class which will be
+ * rendered by the renderer.
+ * @param string $renderingClass The name of the class which will
+ * perform the rendering.
+ */
+ public function addRenderer($renderedClass, $renderingClass) {
+
+ if (class_exists($renderingClass)) {
+ $renderer = new $renderingClass();
+ } else {
+ // Try to find renderer in the default namespace
+ $namespaced = "Apache\\Log4php\\Renderers\\$renderingClass";
+ if (class_exists($namespaced)) {
+ $renderer = new $namespaced();
+ }
+ }
+
+ if (!isset($renderer)) {
+ trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
+ return;
+ }
+
+ // Check the class implements the right interface
+ if (!($renderer instanceof RendererInterface)) {
+ trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
+ return;
+ }
+
+ // Convert to lowercase since class names in PHP are not case sensitive
+ $renderedClass = strtolower($renderedClass);
+
+ $this->map[$renderedClass] = $renderer;
+ }
+
+ /**
+ * Sets a custom default renderer class.
+ *
+ * TODO: there's code duplication here. This method is almost identical to
+ * addRenderer(). However, it has custom error messages so let it sit for
+ * now.
+ *
+ * @param string $renderingClass The name of the class which will
+ * perform the rendering.
+ */
+ public function setDefaultRenderer($renderingClass) {
+ // Check the class exists
+ if (!class_exists($renderingClass)) {
+ trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
+ return;
+ }
+
+ // Create the instance
+ $renderer = new $renderingClass();
+
+ // Check the class implements the right interface
+ if (!($renderer instanceof RendererInterface)) {
+ trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
+ return;
+ }
+
+ $this->defaultRenderer = $renderer;
+ }
+
+ /**
+ * Returns the default renderer.
+ * @var RendererInterface
+ */
+ public function getDefaultRenderer() {
+ return $this->defaultRenderer;
+ }
+
+ /**
+ * Finds the appropriate renderer for the given <var>input</var>, and
+ * renders it (i.e. converts it to a string).
+ *
+ * @param mixed $input Input to render.
+ * @return string The rendered contents.
+ */
+ public function findAndRender($input) {
+ if ($input === null) {
+ return null;
+ }
+
+ // For objects, try to find a renderer in the map
+ if(is_object($input)) {
+ $renderer = $this->getByClassName(get_class($input));
+ if (isset($renderer)) {
+ return $renderer->render($input);
+ }
+ }
+
+ // Fall back to the default renderer
+ return $this->defaultRenderer->render($input);
+ }
+
+ /**
+ * Returns the appropriate renderer for a given object.
+ *
+ * @param mixed $object
+ * @return RendererInterface Or null if none found.
+ */
+ public function getByObject($object) {
+ if (!is_object($object)) {
+ return null;
+ }
+ return $this->getByClassName(get_class($object));
+ }
+
+ /**
+ * Returns the appropriate renderer for a given class name.
+ *
+ * If no renderer could be found, returns NULL.
+ *
+ * @param string $class
+ * @return LoggerRendererObject Or null if not found.
+ */
+ public function getByClassName($class) {
+ for(; !empty($class); $class = get_parent_class($class)) {
+ $class = strtolower($class);
+ if(isset($this->map[$class])) {
+ return $this->map[$class];
+ }
+ }
+ return null;
+ }
+
+ /** Empties the renderer map. */
+ public function clear() {
+ $this->map = array();
+ }
+
+ /** Resets the renderer map to it's default configuration. */
+ public function reset() {
+ $this->defaultRenderer = new DefaultRenderer();
+ $this->clear();
+ $this->addRenderer('Exception', 'ExceptionRenderer');
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/RootLogger.php
----------------------------------------------------------------------
diff --git a/src/RootLogger.php b/src/RootLogger.php
new file mode 100644
index 0000000..ba7f5c3
--- /dev/null
+++ b/src/RootLogger.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * The root logger.
+ * @see Logger
+ */
+class RootLogger extends Logger
+{
+ /**
+ * Constructor
+ *
+ * @param integer $level initial log level
+ */
+ public function __construct(Level $level = null) {
+ parent::__construct('root');
+
+ if($level == null) {
+ $level = Level::getLevelAll();
+ }
+ $this->setLevel($level);
+ }
+
+ /**
+ * @return Level the level
+ */
+ public function getEffectiveLevel() {
+ return $this->getLevel();
+ }
+
+ /**
+ * Override level setter to prevent setting the root logger's level to
+ * null. Root logger must always have a level.
+ *
+ * @param Level $level
+ */
+ public function setLevel(Level $level = null) {
+ if (isset($level)) {
+ parent::setLevel($level);
+ } else {
+ trigger_error("log4php: Cannot set RootLogger level to null.", E_USER_WARNING);
+ }
+ }
+
+ /**
+ * Override parent setter. Root logger cannot have a parent.
+ * @param Logger $parent
+ */
+ public function setParent(Logger $parent) {
+ trigger_error("log4php: RootLogger cannot have a parent.", E_USER_WARNING);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/ThrowableInformation.php
----------------------------------------------------------------------
diff --git a/src/ThrowableInformation.php b/src/ThrowableInformation.php
new file mode 100644
index 0000000..e2befeb
--- /dev/null
+++ b/src/ThrowableInformation.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * The internal representation of throwables.
+ *
+ * @since 2.1
+ */
+class ThrowableInformation
+{
+ /** @var Exception Throwable to log */
+ private $throwable;
+
+ /** @var array Array of throwable messages */
+ private $throwableArray;
+
+ /**
+ * Create a new instance
+ *
+ * @param $throwable - a throwable as a exception
+ * @param $logger - Logger reference
+ */
+ public function __construct(\Exception $throwable) {
+ $this->throwable = $throwable;
+ }
+
+ /**
+ * Return source exception
+ *
+ * @return Exception
+ */
+ public function getThrowable() {
+ return $this->throwable;
+ }
+
+ /**
+ * @desc Returns string representation of throwable
+ *
+ * @return array
+ */
+ public function getStringRepresentation() {
+ if (!is_array($this->throwableArray)) {
+ $renderer = new Renderers\ExceptionRenderer();
+
+ $this->throwableArray = explode("\n", $renderer->render($this->throwable));
+ }
+
+ return $this->throwableArray;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/assembly/src.xml
----------------------------------------------------------------------
diff --git a/src/assembly/src.xml b/src/assembly/src.xml
deleted file mode 100644
index d0dcd8d..0000000
--- a/src/assembly/src.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
- <id>src</id>
- <formats>
- <format>zip</format>
- <format>tar.gz</format>
- </formats>
- <baseDirectory>apache-log4php-${project.version}</baseDirectory>
- <includeSiteDirectory>false</includeSiteDirectory>
- <fileSets>
- <fileSet>
- <includes>
- <include>LICENSE</include>
- <include>NOTICE</include>
- <include>README</include>
- <include>INSTALL</include>
- <include>CHANGELOG</include>
- <include>pom.xml</include>
- <include>build.xml</include>
- <include>package-config.php</include>
- <include>package.php</include>
- <include>src/**</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/site/apidocs</directory>
- <outputDirectory>apidocs</outputDirectory>
- </fileSet>
- </fileSets>
-</assembly>
[13/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/jquery.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/jquery.js b/src/site/resources/js/jquery.js
deleted file mode 100644
index 8ccd0ea..0000000
--- a/src/site/resources/js/jquery.js
+++ /dev/null
@@ -1,9266 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.7.1
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Mon Nov 21 21:11:03 2011 -0500
- */
-(function( window, undefined ) {
-
-// Use the correct document accordingly with window argument (sandbox)
-var document = window.document,
- navigator = window.navigator,
- location = window.location;
-var jQuery = (function() {
-
-// Define a local copy of jQuery
-var jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.fn.init( selector, context, rootjQuery );
- },
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$,
-
- // A central reference to the root jQuery(document)
- rootjQuery,
-
- // A simple way to check for HTML strings or ID strings
- // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
- quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
-
- // Check if a string has a non-whitespace character in it
- rnotwhite = /\S/,
-
- // Used for trimming whitespace
- trimLeft = /^\s+/,
- trimRight = /\s+$/,
-
- // Match a standalone tag
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
-
- // JSON RegExp
- rvalidchars = /^[\],:{}\s]*$/,
- rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
- rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
-
- // Useragent RegExp
- rwebkit = /(webkit)[ \/]([\w.]+)/,
- ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
- rmsie = /(msie) ([\w.]+)/,
- rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
-
- // Matches dashed string for camelizing
- rdashAlpha = /-([a-z]|[0-9])/ig,
- rmsPrefix = /^-ms-/,
-
- // Used by jQuery.camelCase as callback to replace()
- fcamelCase = function( all, letter ) {
- return ( letter + "" ).toUpperCase();
- },
-
- // Keep a UserAgent string for use with jQuery.browser
- userAgent = navigator.userAgent,
-
- // For matching the engine and version of the browser
- browserMatch,
-
- // The deferred used on DOM ready
- readyList,
-
- // The ready event handler
- DOMContentLoaded,
-
- // Save a reference to some core methods
- toString = Object.prototype.toString,
- hasOwn = Object.prototype.hasOwnProperty,
- push = Array.prototype.push,
- slice = Array.prototype.slice,
- trim = String.prototype.trim,
- indexOf = Array.prototype.indexOf,
-
- // [[Class]] -> type pairs
- class2type = {};
-
-jQuery.fn = jQuery.prototype = {
- constructor: jQuery,
- init: function( selector, context, rootjQuery ) {
- var match, elem, ret, doc;
-
- // Handle $(""), $(null), or $(undefined)
- if ( !selector ) {
- return this;
- }
-
- // Handle $(DOMElement)
- if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
- }
-
- // The body element only exists once, optimize finding it
- if ( selector === "body" && !context && document.body ) {
- this.context = document;
- this[0] = document.body;
- this.selector = selector;
- this.length = 1;
- return this;
- }
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- // Are we dealing with HTML string or an ID?
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = quickExpr.exec( selector );
- }
-
- // Verify a match, and that no context was specified for #id
- if ( match && (match[1] || !context) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
- doc = ( context ? context.ownerDocument || context : document );
-
- // If a single string is passed in and it's a single tag
- // just do a createElement and skip the rest
- ret = rsingleTag.exec( selector );
-
- if ( ret ) {
- if ( jQuery.isPlainObject( context ) ) {
- selector = [ document.createElement( ret[1] ) ];
- jQuery.fn.attr.call( selector, context, true );
-
- } else {
- selector = [ doc.createElement( ret[1] ) ];
- }
-
- } else {
- ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
- selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
- }
-
- return jQuery.merge( this, selector );
-
- // HANDLE: $("#id")
- } else {
- elem = document.getElementById( match[2] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || rootjQuery ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
- }
-
- if ( selector.selector !== undefined ) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- },
-
- // Start with an empty selector
- selector: "",
-
- // The current version of jQuery being used
- jquery: "1.7.1",
-
- // The default length of a jQuery object is 0
- length: 0,
-
- // The number of elements contained in the matched element set
- size: function() {
- return this.length;
- },
-
- toArray: function() {
- return slice.call( this, 0 );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num == null ?
-
- // Return a 'clean' array
- this.toArray() :
-
- // Return just the object
- ( num < 0 ? this[ this.length + num ] : this[ num ] );
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems, name, selector ) {
- // Build a new jQuery matched element set
- var ret = this.constructor();
-
- if ( jQuery.isArray( elems ) ) {
- push.apply( ret, elems );
-
- } else {
- jQuery.merge( ret, elems );
- }
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
-
- ret.context = this.context;
-
- if ( name === "find" ) {
- ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
- } else if ( name ) {
- ret.selector = this.selector + "." + name + "(" + selector + ")";
- }
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- // (You can seed the arguments with an array of args, but this is
- // only used internally.)
- each: function( callback, args ) {
- return jQuery.each( this, callback, args );
- },
-
- ready: function( fn ) {
- // Attach the listeners
- jQuery.bindReady();
-
- // Add the callback
- readyList.add( fn );
-
- return this;
- },
-
- eq: function( i ) {
- i = +i;
- return i === -1 ?
- this.slice( i ) :
- this.slice( i, i + 1 );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ),
- "slice", slice.call(arguments).join(",") );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function( elem, i ) {
- return callback.call( elem, i, elem );
- }));
- },
-
- end: function() {
- return this.prevObject || this.constructor(null);
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: [].sort,
- splice: [].splice
-};
-
-// Give the init function the jQuery prototype for later instantiation
-jQuery.fn.init.prototype = jQuery.fn;
-
-jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend({
- noConflict: function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
- },
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
- // Either a released hold or an DOMready/load event and not yet ready
- if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.fireWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger( "ready" ).off( "ready" );
- }
- }
- },
-
- bindReady: function() {
- if ( readyList ) {
- return;
- }
-
- readyList = jQuery.Callbacks( "once memory" );
-
- // Catch cases where $(document).ready() is called after the
- // browser event has already occurred.
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- return setTimeout( jQuery.ready, 1 );
- }
-
- // Mozilla, Opera and webkit nightlies currently support this event
- if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", jQuery.ready, false );
-
- // If IE event model is used
- } else if ( document.attachEvent ) {
- // ensure firing before onload,
- // maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", DOMContentLoaded );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var toplevel = false;
-
- try {
- toplevel = window.frameElement == null;
- } catch(e) {}
-
- if ( document.documentElement.doScroll && toplevel ) {
- doScrollCheck();
- }
- }
- },
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
-
- // A crude way of determining if an object is a window
- isWindow: function( obj ) {
- return obj && typeof obj === "object" && "setInterval" in obj;
- },
-
- isNumeric: function( obj ) {
- return !isNaN( parseFloat(obj) ) && isFinite( obj );
- },
-
- type: function( obj ) {
- return obj == null ?
- String( obj ) :
- class2type[ toString.call(obj) ] || "object";
- },
-
- isPlainObject: function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- try {
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call(obj, "constructor") &&
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- } catch ( e ) {
- // IE8,9 Will throw exceptions on certain host objects #9897
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
-
- var key;
- for ( key in obj ) {}
-
- return key === undefined || hasOwn.call( obj, key );
- },
-
- isEmptyObject: function( obj ) {
- for ( var name in obj ) {
- return false;
- }
- return true;
- },
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- parseJSON: function( data ) {
- if ( typeof data !== "string" || !data ) {
- return null;
- }
-
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
- data = jQuery.trim( data );
-
- // Attempt to parse using the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
- return window.JSON.parse( data );
- }
-
- // Make sure the incoming data is actual JSON
- // Logic borrowed from http://json.org/json2.js
- if ( rvalidchars.test( data.replace( rvalidescape, "@" )
- .replace( rvalidtokens, "]" )
- .replace( rvalidbraces, "")) ) {
-
- return ( new Function( "return " + data ) )();
-
- }
- jQuery.error( "Invalid JSON: " + data );
- },
-
- // Cross-browser xml parsing
- parseXML: function( data ) {
- var xml, tmp;
- try {
- if ( window.DOMParser ) { // Standard
- tmp = new DOMParser();
- xml = tmp.parseFromString( data , "text/xml" );
- } else { // IE
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- } catch( e ) {
- xml = undefined;
- }
- if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
- },
-
- noop: function() {},
-
- // Evaluates a script in a global context
- // Workarounds based on findings by Jim Driscoll
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
- globalEval: function( data ) {
- if ( data && rnotwhite.test( data ) ) {
- // We use execScript on Internet Explorer
- // We use an anonymous function so that context is window
- // rather than jQuery in Firefox
- ( window.execScript || function( data ) {
- window[ "eval" ].call( window, data );
- } )( data );
- }
- },
-
- // Convert dashed to camelCase; used by the css and data modules
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
- },
-
- // args is for internal usage only
- each: function( object, callback, args ) {
- var name, i = 0,
- length = object.length,
- isObj = length === undefined || jQuery.isFunction( object );
-
- if ( args ) {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.apply( object[ name ], args ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.apply( object[ i++ ], args ) === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
- break;
- }
- }
- }
- }
-
- return object;
- },
-
- // Use native String.trim function wherever possible
- trim: trim ?
- function( text ) {
- return text == null ?
- "" :
- trim.call( text );
- } :
-
- // Otherwise use our own trimming functionality
- function( text ) {
- return text == null ?
- "" :
- text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
- },
-
- // results is for internal usage only
- makeArray: function( array, results ) {
- var ret = results || [];
-
- if ( array != null ) {
- // The window, strings (and functions) also have 'length'
- // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
- var type = jQuery.type( array );
-
- if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
- push.call( ret, array );
- } else {
- jQuery.merge( ret, array );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, array, i ) {
- var len;
-
- if ( array ) {
- if ( indexOf ) {
- return indexOf.call( array, elem, i );
- }
-
- len = array.length;
- i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
-
- for ( ; i < len; i++ ) {
- // Skip accessing in sparse arrays
- if ( i in array && array[ i ] === elem ) {
- return i;
- }
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var i = first.length,
- j = 0;
-
- if ( typeof second.length === "number" ) {
- for ( var l = second.length; j < l; j++ ) {
- first[ i++ ] = second[ j ];
- }
-
- } else {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, inv ) {
- var ret = [], retVal;
- inv = !!inv;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- retVal = !!callback( elems[ i ], i );
- if ( inv !== retVal ) {
- ret.push( elems[ i ] );
- }
- }
-
- return ret;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var value, key, ret = [],
- i = 0,
- length = elems.length,
- // jquery objects are treated as arrays
- isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
-
- // Go through the array, translating each of the items to their
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( key in elems ) {
- value = callback( elems[ key ], key, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
- }
-
- // Flatten any nested arrays
- return ret.concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // Bind a function to a context, optionally partially applying any
- // arguments.
- proxy: function( fn, context ) {
- if ( typeof context === "string" ) {
- var tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !jQuery.isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- var args = slice.call( arguments, 2 ),
- proxy = function() {
- return fn.apply( context, args.concat( slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
-
- return proxy;
- },
-
- // Mutifunctional method to get and set values to a collection
- // The value/s can optionally be executed if it's a function
- access: function( elems, key, value, exec, fn, pass ) {
- var length = elems.length;
-
- // Setting many attributes
- if ( typeof key === "object" ) {
- for ( var k in key ) {
- jQuery.access( elems, k, key[k], exec, fn, value );
- }
- return elems;
- }
-
- // Setting one attribute
- if ( value !== undefined ) {
- // Optionally, function values get executed if exec is true
- exec = !pass && exec && jQuery.isFunction(value);
-
- for ( var i = 0; i < length; i++ ) {
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
- }
-
- return elems;
- }
-
- // Getting an attribute
- return length ? fn( elems[0], key ) : undefined;
- },
-
- now: function() {
- return ( new Date() ).getTime();
- },
-
- // Use of jQuery.browser is frowned upon.
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
- uaMatch: function( ua ) {
- ua = ua.toLowerCase();
-
- var match = rwebkit.exec( ua ) ||
- ropera.exec( ua ) ||
- rmsie.exec( ua ) ||
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
- [];
-
- return { browser: match[1] || "", version: match[2] || "0" };
- },
-
- sub: function() {
- function jQuerySub( selector, context ) {
- return new jQuerySub.fn.init( selector, context );
- }
- jQuery.extend( true, jQuerySub, this );
- jQuerySub.superclass = this;
- jQuerySub.fn = jQuerySub.prototype = this();
- jQuerySub.fn.constructor = jQuerySub;
- jQuerySub.sub = this.sub;
- jQuerySub.fn.init = function init( selector, context ) {
- if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
- context = jQuerySub( context );
- }
-
- return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
- };
- jQuerySub.fn.init.prototype = jQuerySub.fn;
- var rootjQuerySub = jQuerySub(document);
- return jQuerySub;
- },
-
- browser: {}
-});
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-browserMatch = jQuery.uaMatch( userAgent );
-if ( browserMatch.browser ) {
- jQuery.browser[ browserMatch.browser ] = true;
- jQuery.browser.version = browserMatch.version;
-}
-
-// Deprecated, use jQuery.browser.webkit instead
-if ( jQuery.browser.webkit ) {
- jQuery.browser.safari = true;
-}
-
-// IE doesn't match non-breaking spaces with \s
-if ( rnotwhite.test( "\xA0" ) ) {
- trimLeft = /^[\s\xA0]+/;
- trimRight = /[\s\xA0]+$/;
-}
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-
-// Cleanup functions for the document ready method
-if ( document.addEventListener ) {
- DOMContentLoaded = function() {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- };
-
-} else if ( document.attachEvent ) {
- DOMContentLoaded = function() {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( document.readyState === "complete" ) {
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
- };
-}
-
-// The DOM ready check for Internet Explorer
-function doScrollCheck() {
- if ( jQuery.isReady ) {
- return;
- }
-
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll("left");
- } catch(e) {
- setTimeout( doScrollCheck, 1 );
- return;
- }
-
- // and execute any waiting functions
- jQuery.ready();
-}
-
-return jQuery;
-
-})();
-
-
-// String to Object flags format cache
-var flagsCache = {};
-
-// Convert String-formatted flags into Object-formatted ones and store in cache
-function createFlags( flags ) {
- var object = flagsCache[ flags ] = {},
- i, length;
- flags = flags.split( /\s+/ );
- for ( i = 0, length = flags.length; i < length; i++ ) {
- object[ flags[i] ] = true;
- }
- return object;
-}
-
-/*
- * Create a callback list using the following parameters:
- *
- * flags: an optional list of space-separated flags that will change how
- * the callback list behaves
- *
- * By default a callback list will act like an event callback list and can be
- * "fired" multiple times.
- *
- * Possible flags:
- *
- * once: will ensure the callback list can only be fired once (like a Deferred)
- *
- * memory: will keep track of previous values and will call any callback added
- * after the list has been fired right away with the latest "memorized"
- * values (like a Deferred)
- *
- * unique: will ensure a callback can only be added once (no duplicate in the list)
- *
- * stopOnFalse: interrupt callings when a callback returns false
- *
- */
-jQuery.Callbacks = function( flags ) {
-
- // Convert flags from String-formatted to Object-formatted
- // (we check in cache first)
- flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
-
- var // Actual callback list
- list = [],
- // Stack of fire calls for repeatable lists
- stack = [],
- // Last fire value (for non-forgettable lists)
- memory,
- // Flag to know if list is currently firing
- firing,
- // First callback to fire (used internally by add and fireWith)
- firingStart,
- // End of the loop when firing
- firingLength,
- // Index of currently firing callback (modified by remove if needed)
- firingIndex,
- // Add one or several callbacks to the list
- add = function( args ) {
- var i,
- length,
- elem,
- type,
- actual;
- for ( i = 0, length = args.length; i < length; i++ ) {
- elem = args[ i ];
- type = jQuery.type( elem );
- if ( type === "array" ) {
- // Inspect recursively
- add( elem );
- } else if ( type === "function" ) {
- // Add if not in unique mode and callback is not in
- if ( !flags.unique || !self.has( elem ) ) {
- list.push( elem );
- }
- }
- }
- },
- // Fire callbacks
- fire = function( context, args ) {
- args = args || [];
- memory = !flags.memory || [ context, args ];
- firing = true;
- firingIndex = firingStart || 0;
- firingStart = 0;
- firingLength = list.length;
- for ( ; list && firingIndex < firingLength; firingIndex++ ) {
- if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
- memory = true; // Mark as halted
- break;
- }
- }
- firing = false;
- if ( list ) {
- if ( !flags.once ) {
- if ( stack && stack.length ) {
- memory = stack.shift();
- self.fireWith( memory[ 0 ], memory[ 1 ] );
- }
- } else if ( memory === true ) {
- self.disable();
- } else {
- list = [];
- }
- }
- },
- // Actual Callbacks object
- self = {
- // Add a callback or a collection of callbacks to the list
- add: function() {
- if ( list ) {
- var length = list.length;
- add( arguments );
- // Do we need to add the callbacks to the
- // current firing batch?
- if ( firing ) {
- firingLength = list.length;
- // With memory, if we're not firing then
- // we should call right away, unless previous
- // firing was halted (stopOnFalse)
- } else if ( memory && memory !== true ) {
- firingStart = length;
- fire( memory[ 0 ], memory[ 1 ] );
- }
- }
- return this;
- },
- // Remove a callback from the list
- remove: function() {
- if ( list ) {
- var args = arguments,
- argIndex = 0,
- argLength = args.length;
- for ( ; argIndex < argLength ; argIndex++ ) {
- for ( var i = 0; i < list.length; i++ ) {
- if ( args[ argIndex ] === list[ i ] ) {
- // Handle firingIndex and firingLength
- if ( firing ) {
- if ( i <= firingLength ) {
- firingLength--;
- if ( i <= firingIndex ) {
- firingIndex--;
- }
- }
- }
- // Remove the element
- list.splice( i--, 1 );
- // If we have some unicity property then
- // we only need to do this once
- if ( flags.unique ) {
- break;
- }
- }
- }
- }
- }
- return this;
- },
- // Control if a given callback is in the list
- has: function( fn ) {
- if ( list ) {
- var i = 0,
- length = list.length;
- for ( ; i < length; i++ ) {
- if ( fn === list[ i ] ) {
- return true;
- }
- }
- }
- return false;
- },
- // Remove all callbacks from the list
- empty: function() {
- list = [];
- return this;
- },
- // Have the list do nothing anymore
- disable: function() {
- list = stack = memory = undefined;
- return this;
- },
- // Is it disabled?
- disabled: function() {
- return !list;
- },
- // Lock the list in its current state
- lock: function() {
- stack = undefined;
- if ( !memory || memory === true ) {
- self.disable();
- }
- return this;
- },
- // Is it locked?
- locked: function() {
- return !stack;
- },
- // Call all callbacks with the given context and arguments
- fireWith: function( context, args ) {
- if ( stack ) {
- if ( firing ) {
- if ( !flags.once ) {
- stack.push( [ context, args ] );
- }
- } else if ( !( flags.once && memory ) ) {
- fire( context, args );
- }
- }
- return this;
- },
- // Call all the callbacks with the given arguments
- fire: function() {
- self.fireWith( this, arguments );
- return this;
- },
- // To know if the callbacks have already been called at least once
- fired: function() {
- return !!memory;
- }
- };
-
- return self;
-};
-
-
-
-
-var // Static reference to slice
- sliceDeferred = [].slice;
-
-jQuery.extend({
-
- Deferred: function( func ) {
- var doneList = jQuery.Callbacks( "once memory" ),
- failList = jQuery.Callbacks( "once memory" ),
- progressList = jQuery.Callbacks( "memory" ),
- state = "pending",
- lists = {
- resolve: doneList,
- reject: failList,
- notify: progressList
- },
- promise = {
- done: doneList.add,
- fail: failList.add,
- progress: progressList.add,
-
- state: function() {
- return state;
- },
-
- // Deprecated
- isResolved: doneList.fired,
- isRejected: failList.fired,
-
- then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
- deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
- return this;
- },
- always: function() {
- deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
- return this;
- },
- pipe: function( fnDone, fnFail, fnProgress ) {
- return jQuery.Deferred(function( newDefer ) {
- jQuery.each( {
- done: [ fnDone, "resolve" ],
- fail: [ fnFail, "reject" ],
- progress: [ fnProgress, "notify" ]
- }, function( handler, data ) {
- var fn = data[ 0 ],
- action = data[ 1 ],
- returned;
- if ( jQuery.isFunction( fn ) ) {
- deferred[ handler ](function() {
- returned = fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
- } else {
- newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
- }
- });
- } else {
- deferred[ handler ]( newDefer[ action ] );
- }
- });
- }).promise();
- },
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- if ( obj == null ) {
- obj = promise;
- } else {
- for ( var key in promise ) {
- obj[ key ] = promise[ key ];
- }
- }
- return obj;
- }
- },
- deferred = promise.promise({}),
- key;
-
- for ( key in lists ) {
- deferred[ key ] = lists[ key ].fire;
- deferred[ key + "With" ] = lists[ key ].fireWith;
- }
-
- // Handle state
- deferred.done( function() {
- state = "resolved";
- }, failList.disable, progressList.lock ).fail( function() {
- state = "rejected";
- }, doneList.disable, progressList.lock );
-
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
-
- // All done!
- return deferred;
- },
-
- // Deferred helper
- when: function( firstParam ) {
- var args = sliceDeferred.call( arguments, 0 ),
- i = 0,
- length = args.length,
- pValues = new Array( length ),
- count = length,
- pCount = length,
- deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
- firstParam :
- jQuery.Deferred(),
- promise = deferred.promise();
- function resolveFunc( i ) {
- return function( value ) {
- args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
- if ( !( --count ) ) {
- deferred.resolveWith( deferred, args );
- }
- };
- }
- function progressFunc( i ) {
- return function( value ) {
- pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
- deferred.notifyWith( promise, pValues );
- };
- }
- if ( length > 1 ) {
- for ( ; i < length; i++ ) {
- if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
- args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
- } else {
- --count;
- }
- }
- if ( !count ) {
- deferred.resolveWith( deferred, args );
- }
- } else if ( deferred !== firstParam ) {
- deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
- }
- return promise;
- }
-});
-
-
-
-
-jQuery.support = (function() {
-
- var support,
- all,
- a,
- select,
- opt,
- input,
- marginDiv,
- fragment,
- tds,
- events,
- eventName,
- i,
- isSupported,
- div = document.createElement( "div" ),
- documentElement = document.documentElement;
-
- // Preliminary tests
- div.setAttribute("className", "t");
- div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
-
- all = div.getElementsByTagName( "*" );
- a = div.getElementsByTagName( "a" )[ 0 ];
-
- // Can't get basic test support
- if ( !all || !all.length || !a ) {
- return {};
- }
-
- // First batch of supports tests
- select = document.createElement( "select" );
- opt = select.appendChild( document.createElement("option") );
- input = div.getElementsByTagName( "input" )[ 0 ];
-
- support = {
- // IE strips leading whitespace when .innerHTML is used
- leadingWhitespace: ( div.firstChild.nodeType === 3 ),
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- tbody: !div.getElementsByTagName("tbody").length,
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- htmlSerialize: !!div.getElementsByTagName("link").length,
-
- // Get the style information from getAttribute
- // (IE uses .cssText instead)
- style: /top/.test( a.getAttribute("style") ),
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- hrefNormalized: ( a.getAttribute("href") === "/a" ),
-
- // Make sure that element opacity exists
- // (IE uses filter instead)
- // Use a regex to work around a WebKit issue. See #5145
- opacity: /^0.55/.test( a.style.opacity ),
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- cssFloat: !!a.style.cssFloat,
-
- // Make sure that if no value is specified for a checkbox
- // that it defaults to "on".
- // (WebKit defaults to "" instead)
- checkOn: ( input.value === "on" ),
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- optSelected: opt.selected,
-
- // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
- getSetAttribute: div.className !== "t",
-
- // Tests for enctype support on a form(#6743)
- enctype: !!document.createElement("form").enctype,
-
- // Makes sure cloning an html5 element does not cause problems
- // Where outerHTML is undefined, this still works
- html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
-
- // Will be defined later
- submitBubbles: true,
- changeBubbles: true,
- focusinBubbles: false,
- deleteExpando: true,
- noCloneEvent: true,
- inlineBlockNeedsLayout: false,
- shrinkWrapBlocks: false,
- reliableMarginRight: true
- };
-
- // Make sure checked status is properly cloned
- input.checked = true;
- support.noCloneChecked = input.cloneNode( true ).checked;
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as disabled)
- select.disabled = true;
- support.optDisabled = !opt.disabled;
-
- // Test to see if it's possible to delete an expando from an element
- // Fails in Internet Explorer
- try {
- delete div.test;
- } catch( e ) {
- support.deleteExpando = false;
- }
-
- if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
- div.attachEvent( "onclick", function() {
- // Cloning a node shouldn't copy over any
- // bound event handlers (IE does this)
- support.noCloneEvent = false;
- });
- div.cloneNode( true ).fireEvent( "onclick" );
- }
-
- // Check if a radio maintains its value
- // after being appended to the DOM
- input = document.createElement("input");
- input.value = "t";
- input.setAttribute("type", "radio");
- support.radioValue = input.value === "t";
-
- input.setAttribute("checked", "checked");
- div.appendChild( input );
- fragment = document.createDocumentFragment();
- fragment.appendChild( div.lastChild );
-
- // WebKit doesn't clone checked state correctly in fragments
- support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- // Check if a disconnected checkbox will retain its checked
- // value of true after appended to the DOM (IE6/7)
- support.appendChecked = input.checked;
-
- fragment.removeChild( input );
- fragment.appendChild( div );
-
- div.innerHTML = "";
-
- // Check if div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container. For more
- // info see bug #3333
- // Fails in WebKit before Feb 2011 nightlies
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- if ( window.getComputedStyle ) {
- marginDiv = document.createElement( "div" );
- marginDiv.style.width = "0";
- marginDiv.style.marginRight = "0";
- div.style.width = "2px";
- div.appendChild( marginDiv );
- support.reliableMarginRight =
- ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
- }
-
- // Technique from Juriy Zaytsev
- // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
- // We only care about the case where non-standard event systems
- // are used, namely in IE. Short-circuiting here helps us to
- // avoid an eval call (in setAttribute) which can cause CSP
- // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
- if ( div.attachEvent ) {
- for( i in {
- submit: 1,
- change: 1,
- focusin: 1
- }) {
- eventName = "on" + i;
- isSupported = ( eventName in div );
- if ( !isSupported ) {
- div.setAttribute( eventName, "return;" );
- isSupported = ( typeof div[ eventName ] === "function" );
- }
- support[ i + "Bubbles" ] = isSupported;
- }
- }
-
- fragment.removeChild( div );
-
- // Null elements to avoid leaks in IE
- fragment = select = opt = marginDiv = div = input = null;
-
- // Run tests that need a body at doc ready
- jQuery(function() {
- var container, outer, inner, table, td, offsetSupport,
- conMarginTop, ptlm, vb, style, html,
- body = document.getElementsByTagName("body")[0];
-
- if ( !body ) {
- // Return for frameset docs that don't have a body
- return;
- }
-
- conMarginTop = 1;
- ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
- vb = "visibility:hidden;border:0;";
- style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
- html = "<div " + style + "><div></div></div>" +
- "<table " + style + " cellpadding='0' cellspacing='0'>" +
- "<tr><td></td></tr></table>";
-
- container = document.createElement("div");
- container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
- body.insertBefore( container, body.firstChild );
-
- // Construct the test element
- div = document.createElement("div");
- container.appendChild( div );
-
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- // (only IE 8 fails this test)
- div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
- tds = div.getElementsByTagName( "td" );
- isSupported = ( tds[ 0 ].offsetHeight === 0 );
-
- tds[ 0 ].style.display = "";
- tds[ 1 ].style.display = "none";
-
- // Check if empty table cells still have offsetWidth/Height
- // (IE <= 8 fail this test)
- support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
-
- // Figure out if the W3C box model works as expected
- div.innerHTML = "";
- div.style.width = div.style.paddingLeft = "1px";
- jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
-
- if ( typeof div.style.zoom !== "undefined" ) {
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- // (IE < 8 does this)
- div.style.display = "inline";
- div.style.zoom = 1;
- support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
-
- // Check if elements with layout shrink-wrap their children
- // (IE 6 does this)
- div.style.display = "";
- div.innerHTML = "<div style='width:4px;'></div>";
- support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
- }
-
- div.style.cssText = ptlm + vb;
- div.innerHTML = html;
-
- outer = div.firstChild;
- inner = outer.firstChild;
- td = outer.nextSibling.firstChild.firstChild;
-
- offsetSupport = {
- doesNotAddBorder: ( inner.offsetTop !== 5 ),
- doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
- };
-
- inner.style.position = "fixed";
- inner.style.top = "20px";
-
- // safari subtracts parent border width here which is 5px
- offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
- inner.style.position = inner.style.top = "";
-
- outer.style.overflow = "hidden";
- outer.style.position = "relative";
-
- offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
- offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
-
- body.removeChild( container );
- div = container = null;
-
- jQuery.extend( support, offsetSupport );
- });
-
- return support;
-})();
-
-
-
-
-var rbrace = /^(?:\{.*\}|\[.*\])$/,
- rmultiDash = /([A-Z])/g;
-
-jQuery.extend({
- cache: {},
-
- // Please use with caution
- uuid: 0,
-
- // Unique for each copy of jQuery on the page
- // Non-digits removed to match rinlinejQuery
- expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
-
- // The following elements throw uncatchable exceptions if you
- // attempt to add expando properties to them.
- noData: {
- "embed": true,
- // Ban all objects except for Flash (which handle expandos)
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
- "applet": true
- },
-
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
- return !!elem && !isEmptyDataObject( elem );
- },
-
- data: function( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var privateCache, thisCache, ret,
- internalKey = jQuery.expando,
- getByName = typeof name === "string",
-
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
-
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
-
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
- isEvents = name === "events";
-
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
- return;
- }
-
- if ( !id ) {
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- elem[ internalKey ] = id = ++jQuery.uuid;
- } else {
- id = internalKey;
- }
- }
-
- if ( !cache[ id ] ) {
- cache[ id ] = {};
-
- // Avoids exposing jQuery metadata on plain JS objects when the object
- // is serialized using JSON.stringify
- if ( !isNode ) {
- cache[ id ].toJSON = jQuery.noop;
- }
- }
-
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" || typeof name === "function" ) {
- if ( pvt ) {
- cache[ id ] = jQuery.extend( cache[ id ], name );
- } else {
- cache[ id ].data = jQuery.extend( cache[ id ].data, name );
- }
- }
-
- privateCache = thisCache = cache[ id ];
-
- // jQuery data() is stored in a separate object inside the object's internal data
- // cache in order to avoid key collisions between internal data and user-defined
- // data.
- if ( !pvt ) {
- if ( !thisCache.data ) {
- thisCache.data = {};
- }
-
- thisCache = thisCache.data;
- }
-
- if ( data !== undefined ) {
- thisCache[ jQuery.camelCase( name ) ] = data;
- }
-
- // Users should not attempt to inspect the internal events object using jQuery.data,
- // it is undocumented and subject to change. But does anyone listen? No.
- if ( isEvents && !thisCache[ name ] ) {
- return privateCache.events;
- }
-
- // Check for both converted-to-camel and non-converted data property names
- // If a data property was specified
- if ( getByName ) {
-
- // First Try to find as-is property data
- ret = thisCache[ name ];
-
- // Test for null|undefined property data
- if ( ret == null ) {
-
- // Try to find the camelCased property
- ret = thisCache[ jQuery.camelCase( name ) ];
- }
- } else {
- ret = thisCache;
- }
-
- return ret;
- },
-
- removeData: function( elem, name, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache, i, l,
-
- // Reference to internal data cache key
- internalKey = jQuery.expando,
-
- isNode = elem.nodeType,
-
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
-
- // See jQuery.data for more information
- id = isNode ? elem[ internalKey ] : internalKey;
-
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
-
- if ( name ) {
-
- thisCache = pvt ? cache[ id ] : cache[ id ].data;
-
- if ( thisCache ) {
-
- // Support array or space separated string names for data keys
- if ( !jQuery.isArray( name ) ) {
-
- // try the string as a key before any manipulation
- if ( name in thisCache ) {
- name = [ name ];
- } else {
-
- // split the camel cased version by spaces unless a key with the spaces exists
- name = jQuery.camelCase( name );
- if ( name in thisCache ) {
- name = [ name ];
- } else {
- name = name.split( " " );
- }
- }
- }
-
- for ( i = 0, l = name.length; i < l; i++ ) {
- delete thisCache[ name[i] ];
- }
-
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
- return;
- }
- }
- }
-
- // See jQuery.data for more information
- if ( !pvt ) {
- delete cache[ id ].data;
-
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !isEmptyDataObject(cache[ id ]) ) {
- return;
- }
- }
-
- // Browsers that fail expando deletion also refuse to delete expandos on
- // the window, but it will allow it on all other JS objects; other browsers
- // don't care
- // Ensure that `cache` is not a window object #10080
- if ( jQuery.support.deleteExpando || !cache.setInterval ) {
- delete cache[ id ];
- } else {
- cache[ id ] = null;
- }
-
- // We destroyed the cache and need to eliminate the expando on the node to avoid
- // false lookups in the cache for entries that no longer exist
- if ( isNode ) {
- // IE does not allow us to delete expando properties from nodes,
- // nor does it have a removeAttribute function on Document nodes;
- // we must handle all of these cases
- if ( jQuery.support.deleteExpando ) {
- delete elem[ internalKey ];
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( internalKey );
- } else {
- elem[ internalKey ] = null;
- }
- }
- },
-
- // For internal use only.
- _data: function( elem, name, data ) {
- return jQuery.data( elem, name, data, true );
- },
-
- // A method for determining if a DOM node can handle the data expando
- acceptData: function( elem ) {
- if ( elem.nodeName ) {
- var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
-
- if ( match ) {
- return !(match === true || elem.getAttribute("classid") !== match);
- }
- }
-
- return true;
- }
-});
-
-jQuery.fn.extend({
- data: function( key, value ) {
- var parts, attr, name,
- data = null;
-
- if ( typeof key === "undefined" ) {
- if ( this.length ) {
- data = jQuery.data( this[0] );
-
- if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
- attr = this[0].attributes;
- for ( var i = 0, l = attr.length; i < l; i++ ) {
- name = attr[i].name;
-
- if ( name.indexOf( "data-" ) === 0 ) {
- name = jQuery.camelCase( name.substring(5) );
-
- dataAttr( this[0], name, data[ name ] );
- }
- }
- jQuery._data( this[0], "parsedAttrs", true );
- }
- }
-
- return data;
-
- } else if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
-
- parts = key.split(".");
- parts[1] = parts[1] ? "." + parts[1] : "";
-
- if ( value === undefined ) {
- data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
-
- // Try to fetch any internally stored data first
- if ( data === undefined && this.length ) {
- data = jQuery.data( this[0], key );
- data = dataAttr( this[0], key, data );
- }
-
- return data === undefined && parts[1] ?
- this.data( parts[0] ) :
- data;
-
- } else {
- return this.each(function() {
- var self = jQuery( this ),
- args = [ parts[0], value ];
-
- self.triggerHandler( "setData" + parts[1] + "!", args );
- jQuery.data( this, key, value );
- self.triggerHandler( "changeData" + parts[1] + "!", args );
- });
- }
- },
-
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
-});
-
-function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
-
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- jQuery.isNumeric( data ) ? parseFloat( data ) :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
-
-// checks a cache object for emptiness
-function isEmptyDataObject( obj ) {
- for ( var name in obj ) {
-
- // if the public data object is empty, the private is still empty
- if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
- continue;
- }
- if ( name !== "toJSON" ) {
- return false;
- }
- }
-
- return true;
-}
-
-
-
-
-function handleQueueMarkDefer( elem, type, src ) {
- var deferDataKey = type + "defer",
- queueDataKey = type + "queue",
- markDataKey = type + "mark",
- defer = jQuery._data( elem, deferDataKey );
- if ( defer &&
- ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
- ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
- // Give room for hard-coded callbacks to fire first
- // and eventually mark/queue something else on the element
- setTimeout( function() {
- if ( !jQuery._data( elem, queueDataKey ) &&
- !jQuery._data( elem, markDataKey ) ) {
- jQuery.removeData( elem, deferDataKey, true );
- defer.fire();
- }
- }, 0 );
- }
-}
-
-jQuery.extend({
-
- _mark: function( elem, type ) {
- if ( elem ) {
- type = ( type || "fx" ) + "mark";
- jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
- }
- },
-
- _unmark: function( force, elem, type ) {
- if ( force !== true ) {
- type = elem;
- elem = force;
- force = false;
- }
- if ( elem ) {
- type = type || "fx";
- var key = type + "mark",
- count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
- if ( count ) {
- jQuery._data( elem, key, count );
- } else {
- jQuery.removeData( elem, key, true );
- handleQueueMarkDefer( elem, type, "mark" );
- }
- }
- },
-
- queue: function( elem, type, data ) {
- var q;
- if ( elem ) {
- type = ( type || "fx" ) + "queue";
- q = jQuery._data( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !q || jQuery.isArray(data) ) {
- q = jQuery._data( elem, type, jQuery.makeArray(data) );
- } else {
- q.push( data );
- }
- }
- return q || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- fn = queue.shift(),
- hooks = {};
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- }
-
- if ( fn ) {
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift( "inprogress" );
- }
-
- jQuery._data( elem, type + ".run", hooks );
- fn.call( elem, function() {
- jQuery.dequeue( elem, type );
- }, hooks );
- }
-
- if ( !queue.length ) {
- jQuery.removeData( elem, type + "queue " + type + ".run", true );
- handleQueueMarkDefer( elem, type, "queue" );
- }
- }
-});
-
-jQuery.fn.extend({
- queue: function( type, data ) {
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- }
-
- if ( data === undefined ) {
- return jQuery.queue( this[0], type );
- }
- return this.each(function() {
- var queue = jQuery.queue( this, type, data );
-
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
-
- return this.queue( type, function( next, hooks ) {
- var timeout = setTimeout( next, time );
- hooks.stop = function() {
- clearTimeout( timeout );
- };
- });
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, object ) {
- if ( typeof type !== "string" ) {
- object = type;
- type = undefined;
- }
- type = type || "fx";
- var defer = jQuery.Deferred(),
- elements = this,
- i = elements.length,
- count = 1,
- deferDataKey = type + "defer",
- queueDataKey = type + "queue",
- markDataKey = type + "mark",
- tmp;
- function resolve() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- }
- while( i-- ) {
- if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
- ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
- jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
- jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
- count++;
- tmp.add( resolve );
- }
- }
- resolve();
- return defer.promise();
- }
-});
-
-
-
-
-var rclass = /[\n\t\r]/g,
- rspace = /\s+/,
- rreturn = /\r/g,
- rtype = /^(?:button|input)$/i,
- rfocusable = /^(?:button|input|object|select|textarea)$/i,
- rclickable = /^a(?:rea)?$/i,
- rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
- getSetAttribute = jQuery.support.getSetAttribute,
- nodeHook, boolHook, fixSpecified;
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.attr );
- },
-
- removeAttr: function( name ) {
- return this.each(function() {
- jQuery.removeAttr( this, name );
- });
- },
-
- prop: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.prop );
- },
-
- removeProp: function( name ) {
- name = jQuery.propFix[ name ] || name;
- return this.each(function() {
- // try/catch handles cases where IE balks (such as removing a property on window)
- try {
- this[ name ] = undefined;
- delete this[ name ];
- } catch( e ) {}
- });
- },
-
- addClass: function( value ) {
- var classNames, i, l, elem,
- setClass, c, cl;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call(this, j, this.className) );
- });
- }
-
- if ( value && typeof value === "string" ) {
- classNames = value.split( rspace );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- elem = this[ i ];
-
- if ( elem.nodeType === 1 ) {
- if ( !elem.className && classNames.length === 1 ) {
- elem.className = value;
-
- } else {
- setClass = " " + elem.className + " ";
-
- for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
- setClass += classNames[ c ] + " ";
- }
- }
- elem.className = jQuery.trim( setClass );
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classNames, i, l, elem, className, c, cl;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call(this, j, this.className) );
- });
- }
-
- if ( (value && typeof value === "string") || value === undefined ) {
- classNames = ( value || "" ).split( rspace );
-
- for ( i = 0, l = this.length; i < l; i++ ) {
- elem = this[ i ];
-
- if ( elem.nodeType === 1 && elem.className ) {
- if ( value ) {
- className = (" " + elem.className + " ").replace( rclass, " " );
- for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- className = className.replace(" " + classNames[ c ] + " ", " ");
- }
- elem.className = jQuery.trim( className );
-
- } else {
- elem.className = "";
- }
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isBool = typeof stateVal === "boolean";
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- state = stateVal,
- classNames = value.split( rspace );
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space seperated list
- state = isBool ? state : !self.hasClass( className );
- self[ state ? "addClass" : "removeClass" ]( className );
- }
-
- } else if ( type === "undefined" || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery._data( this, "__className__", this.className );
- }
-
- // toggle whole className
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ",
- i = 0,
- l = this.length;
- for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
- return true;
- }
- }
-
- return false;
- },
-
- val: function( value ) {
- var hooks, ret, isFunction,
- elem = this[0];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
-
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
- // handle most common string cases
- ret.replace(rreturn, "") :
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return;
- }
-
- isFunction = jQuery.isFunction( value );
-
- return this.each(function( i ) {
- var self = jQuery(this), val;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, self.val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map(val, function ( value ) {
- return value == null ? "" : value + "";
- });
- }
-
- hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- valHooks: {
- option: {
- get: function( elem ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
- },
- select: {
- get: function( elem ) {
- var value, i, max, option,
- index = elem.selectedIndex,
- values = [],
- options = elem.options,
- one = elem.type === "select-one";
-
- // Nothing was selected
- if ( index < 0 ) {
- return null;
- }
-
- // Loop through all the selected options
- i = one ? index : 0;
- max = one ? index + 1 : options.length;
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
- if ( one && !values.length && options.length ) {
- return jQuery( options[ index ] ).val();
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var values = jQuery.makeArray( value );
-
- jQuery(elem).find("option").each(function() {
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
- });
-
- if ( !values.length ) {
- elem.selectedIndex = -1;
- }
- return values;
- }
- }
- },
-
- attrFn: {
- val: true,
- css: true,
- html: true,
- text: true,
- data: true,
- width: true,
- height: true,
- offset: true
- },
-
- attr: function( elem, name, value, pass ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- if ( pass && name in jQuery.attrFn ) {
- return jQuery( elem )[ name ]( value );
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === "undefined" ) {
- return jQuery.prop( elem, name, value );
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- // All attributes are lowercase
- // Grab necessary hook if one is defined
- if ( notxml ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
- }
-
- if ( value !== undefined ) {
-
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
- return;
-
- } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- elem.setAttribute( name, "" + value );
- return value;
- }
-
- } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
-
- ret = elem.getAttribute( name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret === null ?
- undefined :
- ret;
- }
- },
-
- removeAttr: function( elem, value ) {
- var propName, attrNames, name, l,
- i = 0;
-
- if ( value && elem.nodeType === 1 ) {
- attrNames = value.toLowerCase().split( rspace );
- l = attrNames.length;
-
- for ( ; i < l; i++ ) {
- name = attrNames[ i ];
-
- if ( name ) {
- propName = jQuery.propFix[ name ] || name;
-
- // See #9699 for explanation of this approach (setting first, then removal)
- jQuery.attr( elem, name, "" );
- elem.removeAttribute( getSetAttribute ? name : propName );
-
- // Set corresponding property to false for boolean attributes
- if ( rboolean.test( name ) && propName in elem ) {
- elem[ propName ] = false;
- }
- }
- }
- }
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- // We can't allow the type property to be changed (since it causes problems in IE)
- if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
- jQuery.error( "type property can't be changed" );
- } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
- // Setting the type on a radio button after the value resets the value in IE6-9
- // Reset value to it's default in case type is set after value
- // This is for element creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- },
- // Use the value property for back compat
- // Use the nodeHook for button elements in IE6/7 (#1954)
- value: {
- get: function( elem, name ) {
- if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
- return nodeHook.get( elem, name );
- }
- return name in elem ?
- elem.value :
- null;
- },
- set: function( elem, value, name ) {
- if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
- return nodeHook.set( elem, value, name );
- }
- // Does not return so that setAttribute is also used
- elem.value = value;
- }
- }
- },
-
- propFix: {
- tabindex: "tabIndex",
- readonly: "readOnly",
- "for": "htmlFor",
- "class": "className",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- cellpadding: "cellPadding",
- rowspan: "rowSpan",
- colspan: "colSpan",
- usemap: "useMap",
- frameborder: "frameBorder",
- contenteditable: "contentEditable"
- },
-
- prop: function( elem, name, value ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- if ( notxml ) {
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- return ( elem[ name ] = value );
- }
-
- } else {
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
- return elem[ name ];
- }
- }
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- var attributeNode = elem.getAttributeNode("tabindex");
-
- return attributeNode && attributeNode.specified ?
- parseInt( attributeNode.value, 10 ) :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- undefined;
- }
- }
- }
-});
-
-// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
-jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
-
-// Hook for boolean attributes
-boolHook = {
- get: function( elem, name ) {
- // Align boolean attributes with corresponding properties
- // Fall back to attribute presence where some booleans are not supported
- var attrNode,
- property = jQuery.prop( elem, name );
- return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
- name.toLowerCase() :
- undefined;
- },
- set: function( elem, value, name ) {
- var propName;
- if ( value === false ) {
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else {
- // value is true since we know at this point it's type boolean and not false
- // Set boolean attributes to the same name and set the DOM property
- propName = jQuery.propFix[ name ] || name;
- if ( propName in elem ) {
- // Only set the IDL specifically if it already exists on the element
- elem[ propName ] = true;
- }
-
- elem.setAttribute( name, name.toLowerCase() );
- }
- return name;
- }
-};
-
-// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !getSetAttribute ) {
-
- fixSpecified = {
- name: true,
- id: true
- };
-
- // Use this for any attribute in IE6/7
- // This fixes almost every IE6/7 issue
- nodeHook = jQuery.valHooks.button = {
- get: function( elem, name ) {
- var ret;
- ret = elem.getAttributeNode( name );
- return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
- ret.nodeValue :
- undefined;
- },
- set: function( elem, value, name ) {
- // Set the existing or create a new attribute node
- var ret = elem.getAttributeNode( name );
- if ( !ret ) {
- ret = document.createAttribute( name );
- elem.setAttributeNode( ret );
- }
- return ( ret.nodeValue = value + "" );
- }
- };
-
- // Apply the nodeHook to tabindex
- jQuery.attrHooks.tabindex.set = nodeHook.set;
-
- // Set width and height to auto instead of 0 on empty string( Bug #8150 )
- // This is for removals
- jQuery.each([ "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- set: function( elem, value ) {
- if ( value === "" ) {
- elem.setAttribute( name, "auto" );
- return value;
- }
- }
- });
- });
-
- // Set contenteditable to false on removals(#10429)
- // Setting to empty string throws an error as an invalid value
- jQuery.attrHooks.contenteditable = {
- get: nodeHook.get,
- set: function( elem, value, name ) {
- if ( value === "" ) {
- value = "false";
- }
- nodeHook.set( elem, value, name );
- }
- };
-}
-
-
-// Some attributes require a special call on IE
-if ( !jQuery.support.hrefNormalized ) {
- jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- get: function( elem ) {
- var ret = elem.getAttribute( name, 2 );
- return ret === null ? undefined : ret;
- }
- });
- });
-}
-
-if ( !jQuery.support.style ) {
- jQuery.attrHooks.style = {
- get: function( elem ) {
- // Return undefined in the case of empty string
- // Normalize to lowercase since IE uppercases css property names
- return elem.style.cssText.toLowerCase() || undefined;
- },
- set: function( elem, value ) {
- return ( elem.style.cssText = "" + value );
- }
- };
-}
-
-// Safari mis-reports the default selected property of an option
-// Accessing the parent's selectedIndex property fixes it
-if ( !jQuery.support.optSelected ) {
- jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
- get: function( elem ) {
- var parent = elem.parentNode;
-
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- return null;
- }
- });
-}
-
-// IE6/7 call enctype encoding
-if ( !jQuery.support.enctype ) {
- jQuery.propFix.enctype = "encoding";
-}
-
-// Radios and checkboxes getter/setter
-if ( !jQuery.support.checkOn ) {
- jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- get: function( elem ) {
- // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
- return elem.getAttribute("value") === null ? "on" : elem.value;
- }
- };
- });
-}
-jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
- }
- }
- });
-});
-
-
-
-
-var rformElems = /^(?:textarea|input|select)$/i,
- rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
- rhoverHack = /\bhover(\.\S+)?\b/,
- rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|contextmenu)|click/,
- rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
- rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
- quickParse = function( selector ) {
- var quick = rquickIs.exec( selector );
- if ( quick ) {
- // 0 1 2 3
- // [ _, tag, id, class ]
- quick[1] = ( quick[1] || "" ).toLowerCase();
- quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
- }
- return quick;
- },
- quickIs = function( elem, m ) {
- var attrs = elem.attributes || {};
- return (
- (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
- (!m[2] || (attrs.id || {}).value === m[2]) &&
- (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
- );
- },
- hoverHack = function( events ) {
- return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
- };
-
-/*
- * Helper functions for managing events -- not part of the public interface.
- * Props to Dean Edwards' addEvent library for many of the ideas.
- */
-jQuery.event = {
-
- add: function( elem, types, handler, data, selector ) {
-
- var elemData, eventHandle, events,
- t, tns, type, namespaces, handleObj,
- handleObjIn, quick, handlers, special;
-
- // Don't attach events to noData or text/comment nodes (allow plain objects tho)
- if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
- return;
- }
-
- // Caller can pass in an object of custom data in lieu of the handler
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- }
-
- // Make sure that the handler has a unique ID, used to find/remove it later
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure and main handler, if this is the first
- events = elemData.events;
- if ( !events ) {
- elemData.events = events = {};
- }
- eventHandle = elemData.handle;
- if ( !eventHandle ) {
- elemData.handle = eventHandle = function( e ) {
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
- jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
- eventHandle.elem = elem;
- }
-
- // Handle multiple events separated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- types = jQuery.trim( hoverHack(types) ).split( " " );
- for ( t = 0; t < types.length; t++ ) {
-
- tns = rtypenamespace.exec( types[t] ) || [];
- type = tns[1];
- namespaces = ( tns[2] || "" ).split( "." ).sort();
-
- // If event changes its type, use the special event handlers for the changed type
- special = jQuery.event.special[ type ] || {};
-
- // If selector defined, determine special event api type, otherwise given type
- type = ( selector ? special.delegateType : special.bindType ) || type;
-
- // Update special based on newly reset type
- special = jQuery.event.special[ type ] || {};
-
- // handleObj is passed to all event handlers
- handleObj = jQuery.extend({
- type: type,
- origType: tns[1],
- data: data,
- handler: handler,
- guid: handler.guid,
- selector: selector,
- quick: quickParse( selector ),
- namespace: namespaces.join(".")
- }, handleObjIn );
-
- // Init the event handler queue if we're the first
- handlers = events[ type ];
- if ( !handlers ) {
- handlers = events[ type ] = [];
- handlers.delegateCount = 0;
-
- // Only use addEventListener/attachEvent if the special events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add to the element's handler list, delegates in front
- if ( selector ) {
- handlers.splice( handlers.delegateCount++, 0, handleObj );
- } else {
- handlers.push( handleObj );
- }
-
- // Keep track of which events have ever been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- global: {},
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, selector, mappedTypes ) {
-
- var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
- t, tns, type, origType, namespaces, origCount,
- j, events, special, handle, eventType, handleObj;
-
- if ( !elemData || !(events = elemData.events) ) {
- return;
- }
-
- // Once for each type.namespace in types; type may be omitted
- types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
- for ( t = 0; t < types.length; t++ ) {
- tns = rtypenamespace.exec( types[t] ) || [];
- type = origType = tns[1];
- namespaces = tns[2];
-
- // Unbind all events (on this namespace, if provided) for the element
- if ( !type ) {
- for ( type in events ) {
- jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
- }
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
- type = ( selector? special.delegateType : special.bindType ) || type;
- eventType = events[ type ] || [];
- origCount = eventType.length;
- namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
-
- // Remove matching events
- for ( j = 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
-
- if ( ( mappedTypes || origType === handleObj.origType ) &&
- ( !handler || handler.guid === handleObj.guid ) &&
- ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
- ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
- eventType.splice( j--, 1 );
-
- if ( handleObj.selector ) {
- eventType.delegateCount--;
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- }
-
- // Remove generic event handler if we removed something and no more handlers exist
- // (avoids potential for endless recursion during removal of special event handlers)
- if ( eventType.length === 0 && origCount !== eventType.length ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- handle = elemData.handle;
- if ( handle ) {
- handle.elem = null;
- }
-
- // removeData also checks for emptiness and clears the expando if empty
- // so use it instead of delete
- jQuery.removeData( elem, [ "events", "handle" ], true );
- }
- },
-
- // Events that are safe to short-circuit if no handlers are attached.
- // Native DOM events should not be added, they may have inline handlers.
- customEvent: {
- "getData": true,
- "setData": true,
- "changeData": true
- },
-
- trigger: function( event, data, elem, onlyHandlers ) {
- // Don't do events on text and comment nodes
- if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
- return;
- }
-
- // Event object or event type
- var type = event.type || event,
- namespaces = [],
- cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
-
- // focus/blur morphs to focusin/out; ensure we're not firing them right now
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
- return;
- }
-
- if ( type.indexOf( "!" ) >= 0 ) {
- // Exclusive events trigger only for the exact event (no namespaces)
- type = type.slice(0, -1);
- exclusive = true;
- }
-
- if ( type.indexOf( "." ) >= 0 ) {
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split(".");
- type = namespaces.shift();
- namespaces.sort();
- }
-
- if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
- // No jQuery handlers for this event type, and it can't have inline handlers
- return;
- }
-
- // Caller can pass in an Event, Object, or just an event type string
- event = typeof event === "object" ?
- // jQuery.Event object
- event[ jQuery.expando ] ? event :
- // Object literal
- new jQuery.Event( type, event ) :
- // Just the event type (string)
- new jQuery.Event( type );
-
- event.type = type;
- event.isTrigger = true;
- event.exclusive = exclusive;
- event.namespace = namespaces.join( "." );
- event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
- ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
-
- // Handle a global trigger
- if ( !elem ) {
-
- // TODO: Stop taunting the data cache; remove global events and always attach to document
- cache = jQuery.cache;
- for ( i in cache ) {
- if ( cache[ i ].events && cache[ i ].events[ type ] ) {
- jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
- }
- }
- return;
- }
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- if ( !event.target ) {
- event.target = elem;
- }
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data != null ? jQuery.makeArray( data ) : [];
- data.unshift( event );
-
- // Allow special events to draw outside the lines
- special = jQuery.event.special[ type ] || {};
- if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
- return;
- }
-
- // Determine event propagation path in advance, per W3C events spec (#9951)
- // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
- eventPath = [[ elem, special.bindType || type ]];
- if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
-
- bubbleType = special.delegateType || type;
- cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
- old = null;
- for ( ; cur; cur = cur.parentNode ) {
- eventPath.push([ cur, bubbleType ]);
- old = cur;
- }
-
- // Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( old && old === elem.ownerDocument ) {
- eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
- }
- }
-
- // Fire handlers on the event path
- for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
-
- cur = eventPath[i][0];
- event.type = eventPath[i][1];
-
- handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
- if ( handle ) {
- handle.apply( cur, data );
- }
- // Note that this is a bare JS function and not a jQuery handler
- handle = ontype && cur[ ontype ];
- if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
- event.preventDefault();
- }
- }
- event.type = type;
-
- // If nobody prevented the default action, do it now
- if ( !onlyHandlers && !event.isDefaultPrevented() ) {
-
- if ( (!special.
<TRUNCATED>
[29/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Helpers/UtilsTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Helpers/UtilsTest.php b/tests/src/Helpers/UtilsTest.php
index 38ac597..b9f816b 100644
--- a/tests/src/Helpers/UtilsTest.php
+++ b/tests/src/Helpers/UtilsTest.php
@@ -27,63 +27,65 @@ use Apache\Log4php\Helpers\Utils;
/**
* @group helpers
*/
-class LoggerUtilsTest extends \PHPUnit_Framework_TestCase {
+class LoggerUtilsTest extends \PHPUnit_Framework_TestCase
+{
+ public function testShorten()
+ {
+ $name = 'org\\apache\\logging\\log4php\\Foo';
- public function testShorten() {
- $name = 'org\\apache\\logging\\log4php\\Foo';
+ $actual = Utils::shortenClassName($name, null);
+ self::assertSame($name, $actual);
- $actual = Utils::shortenClassName($name, null);
- self::assertSame($name, $actual);
+ $actual = Utils::shortenClassName($name, 0);
+ self::assertSame('Foo', $actual);
- $actual = Utils::shortenClassName($name, 0);
- self::assertSame('Foo', $actual);
+ $actual = Utils::shortenClassName($name, 5);
+ self::assertSame('o\\a\\l\\l\\Foo', $actual);
- $actual = Utils::shortenClassName($name, 5);
- self::assertSame('o\\a\\l\\l\\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 16);
+ self::assertSame('o\\a\\l\\l\\Foo', $actual);
- $actual = Utils::shortenClassName($name, 16);
- self::assertSame('o\\a\\l\\l\\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 17);
+ self::assertSame('o\\a\\l\\log4php\\Foo', $actual);
- $actual = Utils::shortenClassName($name, 17);
- self::assertSame('o\\a\\l\\log4php\\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 25);
+ self::assertSame('o\\a\\logging\\log4php\\Foo', $actual);
- $actual = Utils::shortenClassName($name, 25);
- self::assertSame('o\\a\\logging\\log4php\\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 28);
+ self::assertSame('o\\apache\\logging\\log4php\\Foo', $actual);
- $actual = Utils::shortenClassName($name, 28);
- self::assertSame('o\\apache\\logging\\log4php\\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 30);
+ self::assertSame('org\\apache\\logging\\log4php\\Foo', $actual);
+ }
- $actual = Utils::shortenClassName($name, 30);
- self::assertSame('org\\apache\\logging\\log4php\\Foo', $actual);
- }
+ /** Dot separated notation must be supported for legacy reasons. */
+ public function testShortenWithDots()
+ {
+ $name = 'org.apache.logging.log4php.Foo';
- /** Dot separated notation must be supported for legacy reasons. */
- public function testShortenWithDots() {
- $name = 'org.apache.logging.log4php.Foo';
+ $actual = Utils::shortenClassName($name, null);
+ self::assertSame($name, $actual);
- $actual = Utils::shortenClassName($name, null);
- self::assertSame($name, $actual);
+ $actual = Utils::shortenClassName($name, 0);
+ self::assertSame('Foo', $actual);
- $actual = Utils::shortenClassName($name, 0);
- self::assertSame('Foo', $actual);
+ $actual = Utils::shortenClassName($name, 5);
+ self::assertSame('o\a\l\l\Foo', $actual);
- $actual = Utils::shortenClassName($name, 5);
- self::assertSame('o\a\l\l\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 16);
+ self::assertSame('o\a\l\l\Foo', $actual);
- $actual = Utils::shortenClassName($name, 16);
- self::assertSame('o\a\l\l\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 17);
+ self::assertSame('o\a\l\log4php\Foo', $actual);
- $actual = Utils::shortenClassName($name, 17);
- self::assertSame('o\a\l\log4php\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 25);
+ self::assertSame('o\a\logging\log4php\Foo', $actual);
- $actual = Utils::shortenClassName($name, 25);
- self::assertSame('o\a\logging\log4php\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 28);
+ self::assertSame('o\apache\logging\log4php\Foo', $actual);
- $actual = Utils::shortenClassName($name, 28);
- self::assertSame('o\apache\logging\log4php\Foo', $actual);
+ $actual = Utils::shortenClassName($name, 30);
+ self::assertSame('org\apache\logging\log4php\Foo', $actual);
+ }
- $actual = Utils::shortenClassName($name, 30);
- self::assertSame('org\apache\logging\log4php\Foo', $actual);
- }
-
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/HierarchyTest.php
----------------------------------------------------------------------
diff --git a/tests/src/HierarchyTest.php b/tests/src/HierarchyTest.php
index d9f5b49..183c75a 100644
--- a/tests/src/HierarchyTest.php
+++ b/tests/src/HierarchyTest.php
@@ -30,76 +30,81 @@ use Apache\Log4php\RootLogger;
/**
* @group main
*/
-class HierarchyTest extends \PHPUnit_Framework_TestCase {
-
- private $hierarchy;
-
- protected function setUp() {
- $this->hierarchy = new Hierarchy(new RootLogger());
- }
-
- public function testResetConfiguration() {
- $root = $this->hierarchy->getRootLogger();
- $appender = new ConsoleAppender('A1');
- $root->addAppender($appender);
-
- $logger = $this->hierarchy->getLogger('test');
- self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
-
- $this->hierarchy->resetConfiguration();
- self::assertEquals(Level::getLevelDebug(), $root->getLevel());
- self::assertEquals(Level::getLevelAll(), $this->hierarchy->getThreshold());
- self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
-
- foreach($this->hierarchy->getCurrentLoggers() as $logger) {
- self::assertNull($logger->getLevel());
- self::assertTrue($logger->getAdditivity());
- self::assertEquals(0, count($logger->getAllAppenders()), 0);
- }
- }
-
- public function testSettingParents() {
- $hierarchy = $this->hierarchy;
- $loggerDE = $hierarchy->getLogger("de");
- $root = $loggerDE->getParent();
- self::assertEquals('root', $root->getName());
-
- $loggerDEBLUB = $hierarchy->getLogger("de.blub");
- self::assertEquals('de.blub', $loggerDEBLUB->getName());
- $p = $loggerDEBLUB->getParent();
- self::assertEquals('de', $p->getName());
-
- $loggerDEBLA = $hierarchy->getLogger("de.bla");
- $p = $loggerDEBLA->getParent();
- self::assertEquals('de', $p->getName());
-
- $logger3 = $hierarchy->getLogger("de.bla.third");
- $p = $logger3->getParent();
- self::assertEquals('de.bla', $p->getName());
-
- $p = $p->getParent();
- self::assertEquals('de', $p->getName());
- }
-
- public function testExists() {
- $hierarchy = $this->hierarchy;
- $logger = $hierarchy->getLogger("de");
-
- self::assertTrue($hierarchy->exists("de"));
-
- $logger = $hierarchy->getLogger("de.blub");
- self::assertTrue($hierarchy->exists("de.blub"));
- self::assertTrue($hierarchy->exists("de"));
-
- $logger = $hierarchy->getLogger("de.de");
- self::assertTrue($hierarchy->exists("de.de"));
- }
-
- public function testClear() {
- $hierarchy = $this->hierarchy;
- $logger = $hierarchy->getLogger("de");
- self::assertTrue($hierarchy->exists("de"));
- $hierarchy->clear();
- self::assertFalse($hierarchy->exists("de"));
- }
+class HierarchyTest extends \PHPUnit_Framework_TestCase
+{
+ private $hierarchy;
+
+ protected function setUp()
+ {
+ $this->hierarchy = new Hierarchy(new RootLogger());
+ }
+
+ public function testResetConfiguration()
+ {
+ $root = $this->hierarchy->getRootLogger();
+ $appender = new ConsoleAppender('A1');
+ $root->addAppender($appender);
+
+ $logger = $this->hierarchy->getLogger('test');
+ self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
+
+ $this->hierarchy->resetConfiguration();
+ self::assertEquals(Level::getLevelDebug(), $root->getLevel());
+ self::assertEquals(Level::getLevelAll(), $this->hierarchy->getThreshold());
+ self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
+
+ foreach ($this->hierarchy->getCurrentLoggers() as $logger) {
+ self::assertNull($logger->getLevel());
+ self::assertTrue($logger->getAdditivity());
+ self::assertEquals(0, count($logger->getAllAppenders()), 0);
+ }
+ }
+
+ public function testSettingParents()
+ {
+ $hierarchy = $this->hierarchy;
+ $loggerDE = $hierarchy->getLogger("de");
+ $root = $loggerDE->getParent();
+ self::assertEquals('root', $root->getName());
+
+ $loggerDEBLUB = $hierarchy->getLogger("de.blub");
+ self::assertEquals('de.blub', $loggerDEBLUB->getName());
+ $p = $loggerDEBLUB->getParent();
+ self::assertEquals('de', $p->getName());
+
+ $loggerDEBLA = $hierarchy->getLogger("de.bla");
+ $p = $loggerDEBLA->getParent();
+ self::assertEquals('de', $p->getName());
+
+ $logger3 = $hierarchy->getLogger("de.bla.third");
+ $p = $logger3->getParent();
+ self::assertEquals('de.bla', $p->getName());
+
+ $p = $p->getParent();
+ self::assertEquals('de', $p->getName());
+ }
+
+ public function testExists()
+ {
+ $hierarchy = $this->hierarchy;
+ $logger = $hierarchy->getLogger("de");
+
+ self::assertTrue($hierarchy->exists("de"));
+
+ $logger = $hierarchy->getLogger("de.blub");
+ self::assertTrue($hierarchy->exists("de.blub"));
+ self::assertTrue($hierarchy->exists("de"));
+
+ $logger = $hierarchy->getLogger("de.de");
+ self::assertTrue($hierarchy->exists("de.de"));
+ }
+
+ public function testClear()
+ {
+ $hierarchy = $this->hierarchy;
+ $logger = $hierarchy->getLogger("de");
+ self::assertTrue($hierarchy->exists("de"));
+ $hierarchy->clear();
+ self::assertFalse($hierarchy->exists("de"));
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Layouts/HtmlLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/HtmlLayoutTest.php b/tests/src/Layouts/HtmlLayoutTest.php
index 902d3fc..b909328 100644
--- a/tests/src/Layouts/HtmlLayoutTest.php
+++ b/tests/src/Layouts/HtmlLayoutTest.php
@@ -30,50 +30,54 @@ use Apache\Log4php\Layouts\HtmlLayout;
/**
* @group layouts
*/
-class HtmlLayoutTest extends \PHPUnit_Framework_TestCase {
+class HtmlLayoutTest extends \PHPUnit_Framework_TestCase
+{
+ public function testErrorLayout()
+ {
+ $event = new LoggingEvent("HtmlLayoutTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- public function testErrorLayout() {
- $event = new LoggingEvent("HtmlLayoutTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
-
- $layout = new HtmlLayout();
- $v = $layout->format($event);
+ $layout = new HtmlLayout();
+ $v = $layout->format($event);
- $e = PHP_EOL."<tr>".PHP_EOL.
- "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
- "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
- "<td title=\"Level\">ERROR</td>".PHP_EOL.
- "<td title=\"TEST category\">TEST</td>".PHP_EOL.
- "<td title=\"Message\">testmessage</td>".PHP_EOL.
- "</tr>".PHP_EOL;
+ $e = PHP_EOL."<tr>".PHP_EOL.
+ "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
+ "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
+ "<td title=\"Level\">ERROR</td>".PHP_EOL.
+ "<td title=\"TEST category\">TEST</td>".PHP_EOL.
+ "<td title=\"Message\">testmessage</td>".PHP_EOL.
+ "</tr>".PHP_EOL;
- self::assertEquals($v, $e);
+ self::assertEquals($v, $e);
}
- public function testWarnLayout() {
- $event = new LoggingEvent("HtmlLayoutTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ public function testWarnLayout()
+ {
+ $event = new LoggingEvent("HtmlLayoutTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
- $layout = new HtmlLayout();
- $v = $layout->format($event);
+ $layout = new HtmlLayout();
+ $v = $layout->format($event);
- $e = PHP_EOL."<tr>".PHP_EOL.
- "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
- "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
- "<td title=\"Level\"><font color=\"#993300\"><strong>WARN</strong></font></td>".PHP_EOL.
- "<td title=\"TEST category\">TEST</td>".PHP_EOL.
- "<td title=\"Message\">testmessage</td>".PHP_EOL.
- "</tr>".PHP_EOL;
+ $e = PHP_EOL."<tr>".PHP_EOL.
+ "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
+ "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
+ "<td title=\"Level\"><font color=\"#993300\"><strong>WARN</strong></font></td>".PHP_EOL.
+ "<td title=\"TEST category\">TEST</td>".PHP_EOL.
+ "<td title=\"Message\">testmessage</td>".PHP_EOL.
+ "</tr>".PHP_EOL;
- self::assertEquals($v, $e);
+ self::assertEquals($v, $e);
}
- public function testContentType() {
+ public function testContentType()
+ {
$layout = new HtmlLayout();
$v = $layout->getContentType();
$e = "text/html";
self::assertEquals($v, $e);
}
- public function testTitle() {
+ public function testTitle()
+ {
$layout = new HtmlLayout();
$v = $layout->getTitle();
$e = "Log4php Log Messages";
@@ -85,13 +89,15 @@ class HtmlLayoutTest extends \PHPUnit_Framework_TestCase {
self::assertEquals($v, $e);
}
- public function testHeader() {
+ public function testHeader()
+ {
$layout = new HtmlLayout();
$v = $layout->getHeader();
self::assertTrue(strpos($v, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">") === 0);
}
- public function testFooter() {
+ public function testFooter()
+ {
$layout = new HtmlLayout();
$v = $layout->getFooter();
self::assertTrue(strpos($v, "</table>") === 0);
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Layouts/PatternLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/PatternLayoutTest.php b/tests/src/Layouts/PatternLayoutTest.php
index 71d331d..06d1999 100644
--- a/tests/src/Layouts/PatternLayoutTest.php
+++ b/tests/src/Layouts/PatternLayoutTest.php
@@ -28,29 +28,29 @@ use Apache\Log4php\Logger;
/**
* @group layouts
*/
-class PatternLayoutTest extends \PHPUnit_Framework_TestCase {
-
- /** Pattern used for testing. */
- private $pattern = "%-6level %logger: %msg from %class::%method() in %file at %line%n";
-
- public function testComplexLayout() {
-
- $config = TestHelper::getEchoPatternConfig($this->pattern);
- Logger::configure($config);
-
- ob_start();
- $log = Logger::getLogger('LoggerTest');
- $log->error("my message"); $line = __LINE__;
- $actual = ob_get_contents();
- ob_end_clean();
-
- $file = __FILE__;
- $class = __CLASS__;
- $method = __FUNCTION__;
-
- $expected = "ERROR LoggerTest: my message from $class::$method() in $file at $line" . PHP_EOL;
- self::assertSame($expected, $actual);
-
- Logger::resetConfiguration();
+class PatternLayoutTest extends \PHPUnit_Framework_TestCase
+{
+ /** Pattern used for testing. */
+ private $pattern = "%-6level %logger: %msg from %class::%method() in %file at %line%n";
+
+ public function testComplexLayout()
+ {
+ $config = TestHelper::getEchoPatternConfig($this->pattern);
+ Logger::configure($config);
+
+ ob_start();
+ $log = Logger::getLogger('LoggerTest');
+ $log->error("my message"); $line = __LINE__;
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $file = __FILE__;
+ $class = __CLASS__;
+ $method = __FUNCTION__;
+
+ $expected = "ERROR LoggerTest: my message from $class::$method() in $file at $line" . PHP_EOL;
+ self::assertSame($expected, $actual);
+
+ Logger::resetConfiguration();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Layouts/SerializedLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/SerializedLayoutTest.php b/tests/src/Layouts/SerializedLayoutTest.php
index 257fde2..8f33212 100644
--- a/tests/src/Layouts/SerializedLayoutTest.php
+++ b/tests/src/Layouts/SerializedLayoutTest.php
@@ -29,82 +29,86 @@ use Apache\Log4php\Logger;
/**
* @group layouts
*/
-class SerializedLayoutTest extends \PHPUnit_Framework_TestCase {
+class SerializedLayoutTest extends \PHPUnit_Framework_TestCase
+{
+ public function testLocationInfo()
+ {
+ $layout = new SerializedLayout();
+ self::assertFalse($layout->getLocationInfo());
+ $layout->setLocationInfo(true);
+ self::assertTrue($layout->getLocationInfo());
+ $layout->setLocationInfo(false);
+ self::assertFalse($layout->getLocationInfo());
+ }
- public function testLocationInfo() {
- $layout = new SerializedLayout();
- self::assertFalse($layout->getLocationInfo());
- $layout->setLocationInfo(true);
- self::assertTrue($layout->getLocationInfo());
- $layout->setLocationInfo(false);
- self::assertFalse($layout->getLocationInfo());
- }
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid value given for 'locationInfo' property: ['foo']. Expected a boolean value. Property not changed.
+ */
+ public function testLocationInfoFail()
+ {
+ $layout = new SerializedLayout();
+ $layout->setLocationInfo('foo');
+ }
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid value given for 'locationInfo' property: ['foo']. Expected a boolean value. Property not changed.
- */
- public function testLocationInfoFail() {
- $layout = new SerializedLayout();
- $layout->setLocationInfo('foo');
- }
+ public function testLayout()
+ {
+ Logger::configure(array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SerializedLayout'
+ )
+ )
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ )
+ ));
- public function testLayout() {
- Logger::configure(array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SerializedLayout'
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- )
- ));
+ ob_start();
+ $foo = Logger::getLogger('foo');
+ $foo->info("Interesting message.");
+ $actual = ob_get_contents();
+ ob_end_clean();
- ob_start();
- $foo = Logger::getLogger('foo');
- $foo->info("Interesting message.");
- $actual = ob_get_contents();
- ob_end_clean();
+ $event = unserialize($actual);
- $event = unserialize($actual);
+ self::assertInstanceOf('Apache\\Log4php\\LoggingEvent', $event);
+ self::assertEquals('Interesting message.', $event->getMessage());
+ self::assertEquals(Level::getLevelInfo(), $event->getLevel());
+ }
- self::assertInstanceOf('Apache\\Log4php\\LoggingEvent', $event);
- self::assertEquals('Interesting message.', $event->getMessage());
- self::assertEquals(Level::getLevelInfo(), $event->getLevel());
- }
+ public function testLayoutWithLocationInfo()
+ {
+ Logger::configure(array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SerializedLayout',
+ 'params' => array(
+ 'locationInfo' => true
+ )
+ )
+ )
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ )
+ ));
- public function testLayoutWithLocationInfo() {
- Logger::configure(array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SerializedLayout',
- 'params' => array(
- 'locationInfo' => true
- )
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- )
- ));
+ ob_start();
+ $foo = Logger::getLogger('foo');
+ $foo->info("Interesting message.");
+ $actual = ob_get_contents();
+ ob_end_clean();
- ob_start();
- $foo = Logger::getLogger('foo');
- $foo->info("Interesting message.");
- $actual = ob_get_contents();
- ob_end_clean();
+ $event = unserialize($actual);
- $event = unserialize($actual);
-
- self::assertInstanceOf('Apache\\Log4php\\LoggingEvent', $event);
- self::assertEquals('Interesting message.', $event->getMessage());
- self::assertEquals(Level::getLevelInfo(), $event->getLevel());
- }
+ self::assertInstanceOf('Apache\\Log4php\\LoggingEvent', $event);
+ self::assertEquals('Interesting message.', $event->getMessage());
+ self::assertEquals(Level::getLevelInfo(), $event->getLevel());
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Layouts/SimpleLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/SimpleLayoutTest.php b/tests/src/Layouts/SimpleLayoutTest.php
index f33057d..fa3bb3b 100644
--- a/tests/src/Layouts/SimpleLayoutTest.php
+++ b/tests/src/Layouts/SimpleLayoutTest.php
@@ -30,14 +30,15 @@ use Apache\Log4php\Layouts\SimpleLayout;
/**
* @group layouts
*/
-class SimpleLayoutTest extends \PHPUnit_Framework_TestCase {
+class SimpleLayoutTest extends \PHPUnit_Framework_TestCase
+{
+ public function testSimpleLayout()
+ {
+ $event = new LoggingEvent("SimpleLayoutTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- public function testSimpleLayout() {
- $event = new LoggingEvent("SimpleLayoutTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
-
- $layout = new SimpleLayout();
- $actual = $layout->format($event);
- $expected = "ERROR - testmessage" . PHP_EOL;
- self::assertEquals($expected, $actual);
- }
+ $layout = new SimpleLayout();
+ $actual = $layout->format($event);
+ $expected = "ERROR - testmessage" . PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Layouts/XmlLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/XmlLayoutTest.php b/tests/src/Layouts/XmlLayoutTest.php
index bbcb7dd..a55b9e8 100644
--- a/tests/src/Layouts/XmlLayoutTest.php
+++ b/tests/src/Layouts/XmlLayoutTest.php
@@ -31,123 +31,126 @@ use Apache\Log4php\MDC;
/**
* @group layouts
*/
-class XmlLayoutTest extends \PHPUnit_Framework_TestCase {
+class XmlLayoutTest extends \PHPUnit_Framework_TestCase
+{
+ public function testErrorLayout()
+ {
+ $event = TestHelper::getErrorEvent("testmessage");
- public function testErrorLayout() {
- $event = TestHelper::getErrorEvent("testmessage");
+ $layout = new XmlLayout();
+ $layout->activateOptions();
- $layout = new XmlLayout();
- $layout->activateOptions();
+ $actual = $layout->format($event);
- $actual = $layout->format($event);
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+ $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
- $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
- self::assertEquals($expected, $actual);
- }
+ public function testWarnLayout()
+ {
+ $event = TestHelper::getWarnEvent("testmessage");
- public function testWarnLayout() {
- $event = TestHelper::getWarnEvent("testmessage");
+ $layout = new XmlLayout();
+ $layout->activateOptions();
- $layout = new XmlLayout();
- $layout->activateOptions();
+ $actual = $layout->format($event);
- $actual = $layout->format($event);
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+ $expected = "<log4php:event logger=\"test\" level=\"WARN\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
- $expected = "<log4php:event logger=\"test\" level=\"WARN\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
- self::assertEquals($expected, $actual);
- }
+ public function testLog4JNamespaceErrorLayout()
+ {
+ $event = TestHelper::getErrorEvent("testmessage");
- public function testLog4JNamespaceErrorLayout() {
- $event = TestHelper::getErrorEvent("testmessage");
+ $layout = new XmlLayout();
+ $layout->setLog4jNamespace(true);
+ $layout->activateOptions();
- $layout = new XmlLayout();
- $layout->setLog4jNamespace(true);
- $layout->activateOptions();
+ $actual = $layout->format($event);
- $actual = $layout->format($event);
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+ $expected = "<log4j:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4j:message><![CDATA[testmessage]]></log4j:message>" . PHP_EOL .
+ "<log4j:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4j:event>" . PHP_EOL;
- $expected = "<log4j:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4j:message><![CDATA[testmessage]]></log4j:message>" . PHP_EOL .
- "<log4j:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4j:event>" . PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
- self::assertEquals($expected, $actual);
- }
+ public function testNDC()
+ {
+ NDC::push('foo');
+ NDC::push('bar');
- public function testNDC()
- {
- NDC::push('foo');
- NDC::push('bar');
+ $event = TestHelper::getErrorEvent("testmessage");
- $event = TestHelper::getErrorEvent("testmessage");
+ $layout = new XmlLayout();
+ $layout->activateOptions();
- $layout = new XmlLayout();
- $layout->activateOptions();
+ $actual = $layout->format($event);
- $actual = $layout->format($event);
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+ $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:NDC><![CDATA[<![CDATA[foo bar]]>]]></log4php:NDC>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
- $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:NDC><![CDATA[<![CDATA[foo bar]]>]]></log4php:NDC>" . PHP_EOL .
- "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
+ self::assertEquals($expected, $actual);
- self::assertEquals($expected, $actual);
+ NDC::clear();
+ }
- NDC::clear();
- }
+ public function testMDC()
+ {
+ MDC::put('foo', 'bar');
+ MDC::put('bla', 'tra');
- public function testMDC()
- {
- MDC::put('foo', 'bar');
- MDC::put('bla', 'tra');
+ $event = TestHelper::getErrorEvent("testmessage");
- $event = TestHelper::getErrorEvent("testmessage");
+ $layout = new XmlLayout();
+ $layout->activateOptions();
- $layout = new XmlLayout();
- $layout->activateOptions();
+ $actual = $layout->format($event);
- $actual = $layout->format($event);
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+ $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:properties>" . PHP_EOL .
+ "<log4php:data name=\"foo\" value=\"bar\" />" . PHP_EOL .
+ "<log4php:data name=\"bla\" value=\"tra\" />" . PHP_EOL .
+ "</log4php:properties>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
- $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:properties>" . PHP_EOL .
- "<log4php:data name=\"foo\" value=\"bar\" />" . PHP_EOL .
- "<log4php:data name=\"bla\" value=\"tra\" />" . PHP_EOL .
- "</log4php:properties>" . PHP_EOL .
- "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
+ self::assertEquals($expected, $actual);
- self::assertEquals($expected, $actual);
-
- MDC::clear();
- }
+ MDC::clear();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/LevelTest.php
----------------------------------------------------------------------
diff --git a/tests/src/LevelTest.php b/tests/src/LevelTest.php
index 29ece9b..0933bf2 100644
--- a/tests/src/LevelTest.php
+++ b/tests/src/LevelTest.php
@@ -27,60 +27,69 @@ use Apache\Log4php\Level;
/**
* @group main
*/
-class LevelTest extends \PHPUnit_Framework_TestCase {
-
- protected function doTestLevel($level, $code, $str, $syslog) {
- self::assertTrue($level instanceof Level);
- self::assertEquals($level->toInt(), $code);
- self::assertEquals($level->toString(), $str);
- self::assertEquals($level->getSyslogEquivalent(), $syslog);
- }
+class LevelTest extends \PHPUnit_Framework_TestCase
+{
+ protected function doTestLevel($level, $code, $str, $syslog)
+ {
+ self::assertTrue($level instanceof Level);
+ self::assertEquals($level->toInt(), $code);
+ self::assertEquals($level->toString(), $str);
+ self::assertEquals($level->getSyslogEquivalent(), $syslog);
+ }
- public function testLevelOff() {
- $this->doTestLevel(Level::getLevelOff(), Level::OFF, 'OFF', LOG_ALERT);
- $this->doTestLevel(Level::toLevel(Level::OFF), Level::OFF, 'OFF', LOG_ALERT);
- $this->doTestLevel(Level::toLevel('OFF'), Level::OFF, 'OFF', LOG_ALERT);
+ public function testLevelOff()
+ {
+ $this->doTestLevel(Level::getLevelOff(), Level::OFF, 'OFF', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel(Level::OFF), Level::OFF, 'OFF', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel('OFF'), Level::OFF, 'OFF', LOG_ALERT);
}
- public function testLevelFatal() {
- $this->doTestLevel(Level::getLevelFatal(), Level::FATAL, 'FATAL', LOG_ALERT);
- $this->doTestLevel(Level::toLevel(Level::FATAL), Level::FATAL, 'FATAL', LOG_ALERT);
- $this->doTestLevel(Level::toLevel('FATAL'), Level::FATAL, 'FATAL', LOG_ALERT);
+ public function testLevelFatal()
+ {
+ $this->doTestLevel(Level::getLevelFatal(), Level::FATAL, 'FATAL', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel(Level::FATAL), Level::FATAL, 'FATAL', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel('FATAL'), Level::FATAL, 'FATAL', LOG_ALERT);
}
- public function testLevelError() {
- $this->doTestLevel(Level::getLevelError(), Level::ERROR, 'ERROR', LOG_ERR);
- $this->doTestLevel(Level::toLevel(Level::ERROR), Level::ERROR, 'ERROR', LOG_ERR);
- $this->doTestLevel(Level::toLevel('ERROR'), Level::ERROR, 'ERROR', LOG_ERR);
+ public function testLevelError()
+ {
+ $this->doTestLevel(Level::getLevelError(), Level::ERROR, 'ERROR', LOG_ERR);
+ $this->doTestLevel(Level::toLevel(Level::ERROR), Level::ERROR, 'ERROR', LOG_ERR);
+ $this->doTestLevel(Level::toLevel('ERROR'), Level::ERROR, 'ERROR', LOG_ERR);
}
- public function testLevelWarn() {
- $this->doTestLevel(Level::getLevelWarn(), Level::WARN, 'WARN', LOG_WARNING);
- $this->doTestLevel(Level::toLevel(Level::WARN), Level::WARN, 'WARN', LOG_WARNING);
- $this->doTestLevel(Level::toLevel('WARN'), Level::WARN, 'WARN', LOG_WARNING);
+ public function testLevelWarn()
+ {
+ $this->doTestLevel(Level::getLevelWarn(), Level::WARN, 'WARN', LOG_WARNING);
+ $this->doTestLevel(Level::toLevel(Level::WARN), Level::WARN, 'WARN', LOG_WARNING);
+ $this->doTestLevel(Level::toLevel('WARN'), Level::WARN, 'WARN', LOG_WARNING);
}
- public function testLevelInfo() {
- $this->doTestLevel(Level::getLevelInfo(), Level::INFO, 'INFO', LOG_INFO);
- $this->doTestLevel(Level::toLevel(Level::INFO), Level::INFO, 'INFO', LOG_INFO);
- $this->doTestLevel(Level::toLevel('INFO'), Level::INFO, 'INFO', LOG_INFO);
+ public function testLevelInfo()
+ {
+ $this->doTestLevel(Level::getLevelInfo(), Level::INFO, 'INFO', LOG_INFO);
+ $this->doTestLevel(Level::toLevel(Level::INFO), Level::INFO, 'INFO', LOG_INFO);
+ $this->doTestLevel(Level::toLevel('INFO'), Level::INFO, 'INFO', LOG_INFO);
}
- public function testLevelDebug() {
- $this->doTestLevel(Level::getLevelDebug(), Level::DEBUG, 'DEBUG', LOG_DEBUG);
- $this->doTestLevel(Level::toLevel(Level::DEBUG), Level::DEBUG, 'DEBUG', LOG_DEBUG);
- $this->doTestLevel(Level::toLevel('DEBUG'), Level::DEBUG, 'DEBUG', LOG_DEBUG);
- }
+ public function testLevelDebug()
+ {
+ $this->doTestLevel(Level::getLevelDebug(), Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel(Level::DEBUG), Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel('DEBUG'), Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ }
- public function testLevelTrace() {
- $this->doTestLevel(Level::getLevelTrace(), Level::TRACE, 'TRACE', LOG_DEBUG);
- $this->doTestLevel(Level::toLevel(Level::TRACE), Level::TRACE, 'TRACE', LOG_DEBUG);
- $this->doTestLevel(Level::toLevel('TRACE'), Level::TRACE, 'TRACE', LOG_DEBUG);
+ public function testLevelTrace()
+ {
+ $this->doTestLevel(Level::getLevelTrace(), Level::TRACE, 'TRACE', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel(Level::TRACE), Level::TRACE, 'TRACE', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel('TRACE'), Level::TRACE, 'TRACE', LOG_DEBUG);
}
- public function testLevelAll() {
- $this->doTestLevel(Level::getLevelAll(), Level::ALL, 'ALL', LOG_DEBUG);
- $this->doTestLevel(Level::toLevel(Level::ALL), Level::ALL, 'ALL', LOG_DEBUG);
- $this->doTestLevel(Level::toLevel('ALL'), Level::ALL, 'ALL', LOG_DEBUG);
+ public function testLevelAll()
+ {
+ $this->doTestLevel(Level::getLevelAll(), Level::ALL, 'ALL', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel(Level::ALL), Level::ALL, 'ALL', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel('ALL'), Level::ALL, 'ALL', LOG_DEBUG);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/LoggerTest.php
----------------------------------------------------------------------
diff --git a/tests/src/LoggerTest.php b/tests/src/LoggerTest.php
index a511aa4..e231248 100644
--- a/tests/src/LoggerTest.php
+++ b/tests/src/LoggerTest.php
@@ -27,199 +27,209 @@ use Apache\Log4php\Logger;
/**
* @group main
*/
-class LoggerTest extends \PHPUnit_Framework_TestCase {
-
- private $testConfig1 = array (
- 'rootLogger' => array (
- 'level' => 'ERROR',
- 'appenders' => array (
- 'default',
- ),
- ),
- 'appenders' => array (
- 'default' => array (
- 'class' => 'EchoAppender',
- ),
- ),
- 'loggers' => array (
- 'mylogger' => array (
- 'additivity' => 'false',
- 'level' => 'DEBUG',
- 'appenders' => array (
- 'default',
- ),
- ),
- ),
- );
-
- // For testing additivity
- private $testConfig2 = array (
- 'appenders' => array (
- 'default' => array (
- 'class' => 'EchoAppender',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'loggers' => array (
- 'foo' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar.baz' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- ),
- );
-
- // For testing additivity
- private $testConfig3 = array (
- 'appenders' => array (
- 'default' => array (
- 'class' => 'EchoAppender',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'loggers' => array (
- 'foo' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar.baz' => array (
- 'level' => 'ERROR',
- 'appenders' => array (
- 'default',
- ),
- ),
- ),
- );
-
- protected function setUp() {
- Logger::clear();
- Logger::resetConfiguration();
- }
-
- protected function tearDown() {
- Logger::clear();
- Logger::resetConfiguration();
- }
-
- public function testLoggerExist() {
- $l = Logger::getLogger('test');
- self::assertEquals($l->getName(), 'test');
- self::assertTrue(Logger::exists('test'));
- }
-
- public function testCanGetRootLogger() {
- $l = Logger::getRootLogger();
- self::assertEquals($l->getName(), 'root');
- }
-
- public function testCanGetASpecificLogger() {
- $l = Logger::getLogger('test');
- self::assertEquals($l->getName(), 'test');
- }
-
- public function testCanLogToAllLevels() {
- Logger::configure($this->testConfig1);
-
- $logger = Logger::getLogger('mylogger');
- ob_start();
- $logger->info('this is an info');
- $logger->warn('this is a warning');
- $logger->error('this is an error');
- $logger->debug('this is a debug message');
- $logger->fatal('this is a fatal message');
- $v = ob_get_contents();
- ob_end_clean();
-
- $e = 'INFO - this is an info'.PHP_EOL;
- $e .= 'WARN - this is a warning'.PHP_EOL;
- $e .= 'ERROR - this is an error'.PHP_EOL;
- $e .= 'DEBUG - this is a debug message'.PHP_EOL;
- $e .= 'FATAL - this is a fatal message'.PHP_EOL;
-
- self::assertEquals($v, $e);
- }
-
- public function testIsEnabledFor() {
- Logger::configure($this->testConfig1);
-
- $logger = Logger::getLogger('mylogger');
-
- self::assertFalse($logger->isTraceEnabled());
- self::assertTrue($logger->isDebugEnabled());
- self::assertTrue($logger->isInfoEnabled());
- self::assertTrue($logger->isWarnEnabled());
- self::assertTrue($logger->isErrorEnabled());
- self::assertTrue($logger->isFatalEnabled());
-
- $logger = Logger::getRootLogger();
-
- self::assertFalse($logger->isTraceEnabled());
- self::assertFalse($logger->isDebugEnabled());
- self::assertFalse($logger->isInfoEnabled());
- self::assertFalse($logger->isWarnEnabled());
- self::assertTrue($logger->isErrorEnabled());
- self::assertTrue($logger->isFatalEnabled());
- }
-
- public function testGetCurrentLoggers() {
- Logger::clear();
- Logger::resetConfiguration();
-
- self::assertEquals(0, count(Logger::getCurrentLoggers()));
-
- Logger::configure($this->testConfig1);
- self::assertEquals(1, count(Logger::getCurrentLoggers()));
- $list = Logger::getCurrentLoggers();
- self::assertEquals('mylogger', $list[0]->getName());
- }
-
- public function testAdditivity() {
- Logger::configure($this->testConfig2);
-
- $logger = Logger::getLogger('foo.bar.baz');
- ob_start();
- $logger->info('test');
- $actual = ob_get_contents();
- ob_end_clean();
-
- // The message should get logged 4 times: once by every logger in the
- // hierarchy (including root)
- $expected = str_repeat('INFO - test' . PHP_EOL, 4);
- self::assertSame($expected, $actual);
- }
-
- public function testAdditivity2() {
- Logger::configure($this->testConfig3);
-
- $logger = Logger::getLogger('foo.bar.baz');
- ob_start();
- $logger->info('test');
- $actual = ob_get_contents();
- ob_end_clean();
-
- // The message should get logged 3 times: once by every logger in the
- // hierarchy, except foo.bar.baz which is set to level ERROR
- $expected = str_repeat('INFO - test' . PHP_EOL, 3);
- self::assertSame($expected, $actual);
- }
+class LoggerTest extends \PHPUnit_Framework_TestCase
+{
+ private $testConfig1 = array (
+ 'rootLogger' => array (
+ 'level' => 'ERROR',
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'appenders' => array (
+ 'default' => array (
+ 'class' => 'EchoAppender',
+ ),
+ ),
+ 'loggers' => array (
+ 'mylogger' => array (
+ 'additivity' => 'false',
+ 'level' => 'DEBUG',
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ ),
+ );
+
+ // For testing additivity
+ private $testConfig2 = array (
+ 'appenders' => array (
+ 'default' => array (
+ 'class' => 'EchoAppender',
+ ),
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'loggers' => array (
+ 'foo' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar.baz' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ ),
+ );
+
+ // For testing additivity
+ private $testConfig3 = array (
+ 'appenders' => array (
+ 'default' => array (
+ 'class' => 'EchoAppender',
+ ),
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'loggers' => array (
+ 'foo' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar' => array (
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ 'foo.bar.baz' => array (
+ 'level' => 'ERROR',
+ 'appenders' => array (
+ 'default',
+ ),
+ ),
+ ),
+ );
+
+ protected function setUp()
+ {
+ Logger::clear();
+ Logger::resetConfiguration();
+ }
+
+ protected function tearDown()
+ {
+ Logger::clear();
+ Logger::resetConfiguration();
+ }
+
+ public function testLoggerExist()
+ {
+ $l = Logger::getLogger('test');
+ self::assertEquals($l->getName(), 'test');
+ self::assertTrue(Logger::exists('test'));
+ }
+
+ public function testCanGetRootLogger()
+ {
+ $l = Logger::getRootLogger();
+ self::assertEquals($l->getName(), 'root');
+ }
+
+ public function testCanGetASpecificLogger()
+ {
+ $l = Logger::getLogger('test');
+ self::assertEquals($l->getName(), 'test');
+ }
+
+ public function testCanLogToAllLevels()
+ {
+ Logger::configure($this->testConfig1);
+
+ $logger = Logger::getLogger('mylogger');
+ ob_start();
+ $logger->info('this is an info');
+ $logger->warn('this is a warning');
+ $logger->error('this is an error');
+ $logger->debug('this is a debug message');
+ $logger->fatal('this is a fatal message');
+ $v = ob_get_contents();
+ ob_end_clean();
+
+ $e = 'INFO - this is an info'.PHP_EOL;
+ $e .= 'WARN - this is a warning'.PHP_EOL;
+ $e .= 'ERROR - this is an error'.PHP_EOL;
+ $e .= 'DEBUG - this is a debug message'.PHP_EOL;
+ $e .= 'FATAL - this is a fatal message'.PHP_EOL;
+
+ self::assertEquals($v, $e);
+ }
+
+ public function testIsEnabledFor()
+ {
+ Logger::configure($this->testConfig1);
+
+ $logger = Logger::getLogger('mylogger');
+
+ self::assertFalse($logger->isTraceEnabled());
+ self::assertTrue($logger->isDebugEnabled());
+ self::assertTrue($logger->isInfoEnabled());
+ self::assertTrue($logger->isWarnEnabled());
+ self::assertTrue($logger->isErrorEnabled());
+ self::assertTrue($logger->isFatalEnabled());
+
+ $logger = Logger::getRootLogger();
+
+ self::assertFalse($logger->isTraceEnabled());
+ self::assertFalse($logger->isDebugEnabled());
+ self::assertFalse($logger->isInfoEnabled());
+ self::assertFalse($logger->isWarnEnabled());
+ self::assertTrue($logger->isErrorEnabled());
+ self::assertTrue($logger->isFatalEnabled());
+ }
+
+ public function testGetCurrentLoggers()
+ {
+ Logger::clear();
+ Logger::resetConfiguration();
+
+ self::assertEquals(0, count(Logger::getCurrentLoggers()));
+
+ Logger::configure($this->testConfig1);
+ self::assertEquals(1, count(Logger::getCurrentLoggers()));
+ $list = Logger::getCurrentLoggers();
+ self::assertEquals('mylogger', $list[0]->getName());
+ }
+
+ public function testAdditivity()
+ {
+ Logger::configure($this->testConfig2);
+
+ $logger = Logger::getLogger('foo.bar.baz');
+ ob_start();
+ $logger->info('test');
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ // The message should get logged 4 times: once by every logger in the
+ // hierarchy (including root)
+ $expected = str_repeat('INFO - test' . PHP_EOL, 4);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testAdditivity2()
+ {
+ Logger::configure($this->testConfig3);
+
+ $logger = Logger::getLogger('foo.bar.baz');
+ ob_start();
+ $logger->info('test');
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ // The message should get logged 3 times: once by every logger in the
+ // hierarchy, except foo.bar.baz which is set to level ERROR
+ $expected = str_repeat('INFO - test' . PHP_EOL, 3);
+ self::assertSame($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/LoggingEventTest.php
----------------------------------------------------------------------
diff --git a/tests/src/LoggingEventTest.php b/tests/src/LoggingEventTest.php
index f07e7c3..9aff60e 100644
--- a/tests/src/LoggingEventTest.php
+++ b/tests/src/LoggingEventTest.php
@@ -29,111 +29,120 @@ use Apache\Log4php\Level;
use Apache\Log4php\Logger;
use Apache\Log4php\LoggingEvent;
-class LoggingEventTestCaseAppender extends NullAppender {
-
- protected $requiresLayout = true;
-
- public function append(LoggingEvent $event) {
- $this->layout->format($event);
- }
+class LoggingEventTestCaseAppender extends NullAppender
+{
+ protected $requiresLayout = true;
+
+ public function append(LoggingEvent $event)
+ {
+ $this->layout->format($event);
+ }
}
-class LoggingEventTestCaseLayout extends AbstractLayout {
-
- public function activateOptions() {
- return;
- }
+class LoggingEventTestCaseLayout extends AbstractLayout
+{
+ public function activateOptions()
+ {
+ return;
+ }
- public function format(LoggingEvent $event) {
- LoggingEventTest::$locationInfo = $event->getLocationInformation();
+ public function format(LoggingEvent $event)
+ {
+ LoggingEventTest::$locationInfo = $event->getLocationInformation();
LoggingEventTest::$throwableInfo = $event->getThrowableInformation();
- }
+ }
}
/**
* @group main
*/
-class LoggingEventTest extends \PHPUnit_Framework_TestCase {
-
- public static $locationInfo;
+class LoggingEventTest extends \PHPUnit_Framework_TestCase
+{
+ public static $locationInfo;
public static $throwableInfo;
- public function testConstructWithLoggerName() {
- $l = Level::getLevelDebug();
- $e = new LoggingEvent('fqcn', 'TestLogger', $l, 'test');
- self::assertEquals($e->getLoggerName(), 'TestLogger');
- }
-
- public function testConstructWithTimestamp() {
- $l = Level::getLevelDebug();
- $timestamp = microtime(true);
- $e = new LoggingEvent('fqcn', 'TestLogger', $l, 'test', $timestamp);
- self::assertEquals($e->getTimeStamp(), $timestamp);
- }
-
- public function testGetStartTime() {
- $time = LoggingEvent::getStartTime();
- self::assertInternalType('float', $time);
- $time2 = LoggingEvent::getStartTime();
- self::assertEquals($time, $time2);
- }
-
- public function testGetLocationInformation() {
- $hierarchy = Logger::getHierarchy();
- $root = $hierarchy->getRootLogger();
-
- $a = new LoggingEventTestCaseAppender('A1');
- $a->setLayout(new LoggingEventTestCaseLayout());
- $root->addAppender($a);
-
- $logger = $hierarchy->getLogger('test');
-
- $line = __LINE__; $logger->debug('test');
- $hierarchy->shutdown();
-
- $li = self::$locationInfo;
-
- self::assertEquals(get_class($this), $li->getClassName());
- self::assertEquals(__FILE__, $li->getFileName());
- self::assertEquals($line, $li->getLineNumber());
- self::assertEquals(__FUNCTION__, $li->getMethodName());
- }
-
- public function testGetThrowableInformation1() {
- $hierarchy = Logger::getHierarchy();
- $root = $hierarchy->getRootLogger();
-
- $a = new LoggingEventTestCaseAppender('A1');
- $a->setLayout( new LoggingEventTestCaseLayout() );
- $root->addAppender($a);
-
- $logger = $hierarchy->getLogger('test');
- $logger->debug('test');
- $hierarchy->shutdown();
-
- $ti = self::$throwableInfo;
-
- self::assertEquals($ti, null);
- }
-
- public function testGetThrowableInformation2() {
- $hierarchy = Logger::getHierarchy();
- $root = $hierarchy->getRootLogger();
-
- $a = new LoggingEventTestCaseAppender('A1');
- $a->setLayout( new LoggingEventTestCaseLayout() );
- $root->addAppender($a);
-
- $ex = new \Exception('Message1');
- $logger = $hierarchy->getLogger('test');
- $logger->debug('test', $ex);
- $hierarchy->shutdown();
-
- $ti = self::$throwableInfo;
-
- self::assertInstanceOf("Apache\\Log4php\\ThrowableInformation", $ti);
-
- $result = $ti->getStringRepresentation();
- self::assertInternalType('array', $result);
- }
+ public function testConstructWithLoggerName()
+ {
+ $l = Level::getLevelDebug();
+ $e = new LoggingEvent('fqcn', 'TestLogger', $l, 'test');
+ self::assertEquals($e->getLoggerName(), 'TestLogger');
+ }
+
+ public function testConstructWithTimestamp()
+ {
+ $l = Level::getLevelDebug();
+ $timestamp = microtime(true);
+ $e = new LoggingEvent('fqcn', 'TestLogger', $l, 'test', $timestamp);
+ self::assertEquals($e->getTimeStamp(), $timestamp);
+ }
+
+ public function testGetStartTime()
+ {
+ $time = LoggingEvent::getStartTime();
+ self::assertInternalType('float', $time);
+ $time2 = LoggingEvent::getStartTime();
+ self::assertEquals($time, $time2);
+ }
+
+ public function testGetLocationInformation()
+ {
+ $hierarchy = Logger::getHierarchy();
+ $root = $hierarchy->getRootLogger();
+
+ $a = new LoggingEventTestCaseAppender('A1');
+ $a->setLayout(new LoggingEventTestCaseLayout());
+ $root->addAppender($a);
+
+ $logger = $hierarchy->getLogger('test');
+
+ $line = __LINE__; $logger->debug('test');
+ $hierarchy->shutdown();
+
+ $li = self::$locationInfo;
+
+ self::assertEquals(get_class($this), $li->getClassName());
+ self::assertEquals(__FILE__, $li->getFileName());
+ self::assertEquals($line, $li->getLineNumber());
+ self::assertEquals(__FUNCTION__, $li->getMethodName());
+ }
+
+ public function testGetThrowableInformation1()
+ {
+ $hierarchy = Logger::getHierarchy();
+ $root = $hierarchy->getRootLogger();
+
+ $a = new LoggingEventTestCaseAppender('A1');
+ $a->setLayout( new LoggingEventTestCaseLayout() );
+ $root->addAppender($a);
+
+ $logger = $hierarchy->getLogger('test');
+ $logger->debug('test');
+ $hierarchy->shutdown();
+
+ $ti = self::$throwableInfo;
+
+ self::assertEquals($ti, null);
+ }
+
+ public function testGetThrowableInformation2()
+ {
+ $hierarchy = Logger::getHierarchy();
+ $root = $hierarchy->getRootLogger();
+
+ $a = new LoggingEventTestCaseAppender('A1');
+ $a->setLayout( new LoggingEventTestCaseLayout() );
+ $root->addAppender($a);
+
+ $ex = new \Exception('Message1');
+ $logger = $hierarchy->getLogger('test');
+ $logger->debug('test', $ex);
+ $hierarchy->shutdown();
+
+ $ti = self::$throwableInfo;
+
+ self::assertInstanceOf("Apache\\Log4php\\ThrowableInformation", $ti);
+
+ $result = $ti->getStringRepresentation();
+ self::assertInternalType('array', $result);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/MDCTest.php
----------------------------------------------------------------------
diff --git a/tests/src/MDCTest.php b/tests/src/MDCTest.php
index 0d33383..020b7e6 100644
--- a/tests/src/MDCTest.php
+++ b/tests/src/MDCTest.php
@@ -29,91 +29,93 @@ use Apache\Log4php\Layouts\PatternLayout;
/**
* @group main
*/
-class MDCTest extends \PHPUnit_Framework_TestCase {
+class MDCTest extends \PHPUnit_Framework_TestCase
+{
+ /** A pattern with 1 key. */
+ private $pattern1 = "%-5p %c: %X{key1} %m";
- /** A pattern with 1 key. */
- private $pattern1 = "%-5p %c: %X{key1} %m";
+ /** A pattern with 2 keys. */
+ private $pattern2 = "%-5p %c: %X{key1} %X{key2} %m";
- /** A pattern with 2 keys. */
- private $pattern2 = "%-5p %c: %X{key1} %X{key2} %m";
+ /** A pattern with 3 keys (one is numeric). */
+ private $pattern3 = "%-5p %c: %X{key1} %X{key2} %X{3} %m";
- /** A pattern with 3 keys (one is numeric). */
- private $pattern3 = "%-5p %c: %X{key1} %X{key2} %X{3} %m";
+ /** A pattern with a non-existant key. */
+ private $pattern4 = "%-5p %c: %X{key_does_not_exist} %m";
- /** A pattern with a non-existant key. */
- private $pattern4 = "%-5p %c: %X{key_does_not_exist} %m";
+ /** A pattern without a key. */
+ private $pattern5 = "%-5p %c: %X %m";
- /** A pattern without a key. */
- private $pattern5 = "%-5p %c: %X %m";
-
- protected function setUp() {
- MDC::clear();
- }
-
- protected function tearDown() {
- MDC::clear();
- }
-
- public function testPatterns() {
-
- // Create some data to test with
- MDC::put('key1', 'valueofkey1');
- MDC::put('key2', 'valueofkey2');
- MDC::put(3, 'valueofkey3');
-
- $expected = array(
- 'key1' => 'valueofkey1',
- 'key2' => 'valueofkey2',
- 3 => 'valueofkey3',
- );
- $actual = MDC::getMap();
-
- self::assertSame($expected, $actual);
-
- $event = TestHelper::getInfoEvent("Test message");
-
- // Pattern with 1 key
- $actual = $this->formatEvent($event, $this->pattern1);
- $expected = "INFO test: valueofkey1 Test message";
- self::assertEquals($expected, $actual);
-
- // Pattern with 2 keys
- $actual = $this->formatEvent($event, $this->pattern2);
- $expected = "INFO test: valueofkey1 valueofkey2 Test message";
- self::assertEquals($expected, $actual);
-
- // Pattern with 3 keys (one numeric)
- $actual = $this->formatEvent($event, $this->pattern3);
- $expected = "INFO test: valueofkey1 valueofkey2 valueofkey3 Test message";
- self::assertEquals($expected, $actual);
+ protected function setUp()
+ {
+ MDC::clear();
+ }
- // Pattern with non-existant key
- $actual = $this->formatEvent($event, $this->pattern4);
- $expected = "INFO test: Test message";
- self::assertEquals($expected, $actual);
+ protected function tearDown()
+ {
+ MDC::clear();
+ }
- // Pattern with an empty key
- $actual = $this->formatEvent($event, $this->pattern5);
- $expected = "INFO test: key1=valueofkey1, key2=valueofkey2, 3=valueofkey3 Test message";
- self::assertEquals($expected, $actual);
+ public function testPatterns()
+ {
+ // Create some data to test with
+ MDC::put('key1', 'valueofkey1');
+ MDC::put('key2', 'valueofkey2');
+ MDC::put(3, 'valueofkey3');
+
+ $expected = array(
+ 'key1' => 'valueofkey1',
+ 'key2' => 'valueofkey2',
+ 3 => 'valueofkey3',
+ );
+ $actual = MDC::getMap();
+
+ self::assertSame($expected, $actual);
+
+ $event = TestHelper::getInfoEvent("Test message");
+
+ // Pattern with 1 key
+ $actual = $this->formatEvent($event, $this->pattern1);
+ $expected = "INFO test: valueofkey1 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with 2 keys
+ $actual = $this->formatEvent($event, $this->pattern2);
+ $expected = "INFO test: valueofkey1 valueofkey2 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with 3 keys (one numeric)
+ $actual = $this->formatEvent($event, $this->pattern3);
+ $expected = "INFO test: valueofkey1 valueofkey2 valueofkey3 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with non-existant key
+ $actual = $this->formatEvent($event, $this->pattern4);
+ $expected = "INFO test: Test message";
+ self::assertEquals($expected, $actual);
+
+ // Pattern with an empty key
+ $actual = $this->formatEvent($event, $this->pattern5);
+ $expected = "INFO test: key1=valueofkey1, key2=valueofkey2, 3=valueofkey3 Test message";
+ self::assertEquals($expected, $actual);
+
+ // Test key removal
+ MDC::remove('key1');
+ $value = MDC::get('key1');
+ self::assertEquals('', $value);
+
+ // Pattern with 1 key, now removed
+ $actual = $this->formatEvent($event, $this->pattern1);
+ $expected = "INFO test: Test message";
+ self::assertEquals($expected, $actual);
+ }
- // Test key removal
- MDC::remove('key1');
- $value = MDC::get('key1');
- self::assertEquals('', $value);
+ private function formatEvent($event, $pattern)
+ {
+ $layout = new PatternLayout();
+ $layout->setConversionPattern($pattern);
+ $layout->activateOptions();
- // Pattern with 1 key, now removed
- $actual = $this->formatEvent($event, $this->pattern1);
- $expected = "INFO test: Test message";
- self::assertEquals($expected, $actual);
+ return $layout->format($event);
}
-
- private function formatEvent($event, $pattern) {
- $layout = new PatternLayout();
- $layout->setConversionPattern($pattern);
- $layout->activateOptions();
- return $layout->format($event);
- }
}
-
-?>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/NDCTest.php
----------------------------------------------------------------------
diff --git a/tests/src/NDCTest.php b/tests/src/NDCTest.php
index b65b822..c07d2d6 100644
--- a/tests/src/NDCTest.php
+++ b/tests/src/NDCTest.php
@@ -28,67 +28,65 @@ use Apache\Log4php\NDC;
/**
* @group main
*/
-class NDCTest extends \PHPUnit_Framework_TestCase {
-
- public function testItemHandling()
- {
- // Test the empty stack
- self::assertSame('', NDC::get());
- self::assertSame('', NDC::peek());
- self::assertSame(0, NDC::getDepth());
- self::assertSame('', NDC::pop());
-
- // Add some data to the stack
- NDC::push('1');
- NDC::push('2');
- NDC::push('3');
-
- self::assertSame('1 2 3', NDC::get());
- self::assertSame('3', NDC::peek());
- self::assertSame(3, NDC::getDepth());
-
- // Remove last item
- self::assertSame('3', NDC::pop());
- self::assertSame('1 2', NDC::get());
- self::assertSame('2', NDC::peek());
- self::assertSame(2, NDC::getDepth());
-
- // Remove all items
- NDC::remove();
-
- // Test the empty stack
- self::assertSame('', NDC::get());
- self::assertSame('', NDC::peek());
- self::assertSame(0, NDC::getDepth());
- self::assertSame('', NDC::pop());
- }
-
- public function testMaxDepth()
- {
- // Clear stack; add some testing data
- NDC::clear();
- NDC::push('1');
- NDC::push('2');
- NDC::push('3');
- NDC::push('4');
- NDC::push('5');
- NDC::push('6');
-
- self::assertSame('1 2 3 4 5 6', NDC::get());
-
- // Edge case, should not change stack
- NDC::setMaxDepth(6);
- self::assertSame('1 2 3 4 5 6', NDC::get());
- self::assertSame(6, NDC::getDepth());
-
- NDC::setMaxDepth(3);
- self::assertSame('1 2 3', NDC::get());
- self::assertSame(3, NDC::getDepth());
-
- NDC::setMaxDepth(0);
- self::assertSame('', NDC::get());
- self::assertSame(0, NDC::getDepth());
- }
+class NDCTest extends \PHPUnit_Framework_TestCase
+{
+ public function testItemHandling()
+ {
+ // Test the empty stack
+ self::assertSame('', NDC::get());
+ self::assertSame('', NDC::peek());
+ self::assertSame(0, NDC::getDepth());
+ self::assertSame('', NDC::pop());
+
+ // Add some data to the stack
+ NDC::push('1');
+ NDC::push('2');
+ NDC::push('3');
+
+ self::assertSame('1 2 3', NDC::get());
+ self::assertSame('3', NDC::peek());
+ self::assertSame(3, NDC::getDepth());
+
+ // Remove last item
+ self::assertSame('3', NDC::pop());
+ self::assertSame('1 2', NDC::get());
+ self::assertSame('2', NDC::peek());
+ self::assertSame(2, NDC::getDepth());
+
+ // Remove all items
+ NDC::remove();
+
+ // Test the empty stack
+ self::assertSame('', NDC::get());
+ self::assertSame('', NDC::peek());
+ self::assertSame(0, NDC::getDepth());
+ self::assertSame('', NDC::pop());
+ }
+
+ public function testMaxDepth()
+ {
+ // Clear stack; add some testing data
+ NDC::clear();
+ NDC::push('1');
+ NDC::push('2');
+ NDC::push('3');
+ NDC::push('4');
+ NDC::push('5');
+ NDC::push('6');
+
+ self::assertSame('1 2 3 4 5 6', NDC::get());
+
+ // Edge case, should not change stack
+ NDC::setMaxDepth(6);
+ self::assertSame('1 2 3 4 5 6', NDC::get());
+ self::assertSame(6, NDC::getDepth());
+
+ NDC::setMaxDepth(3);
+ self::assertSame('1 2 3', NDC::get());
+ self::assertSame(3, NDC::getDepth());
+
+ NDC::setMaxDepth(0);
+ self::assertSame('', NDC::get());
+ self::assertSame(0, NDC::getDepth());
+ }
}
-
-?>
[09/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/pdo.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/pdo.xml b/src/site/xdoc/docs/appenders/pdo.xml
deleted file mode 100644
index e978c77..0000000
--- a/src/site/xdoc/docs/appenders/pdo.xml
+++ /dev/null
@@ -1,444 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderPDO</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderPDO">
-
- <p><code>LoggerAppenderPDO</code> appender logs to a database using the PHP's
- <a href="http://php.net/manual/en/book.pdo.php" class="external">PDO extension</a>.</p>
-
- <subsection name="Layout">
- <p>This appender does not require a layout.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>dsn</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>The Data Source Name (DSN) used to connect to the database.</td>
- </tr>
- <tr>
- <td>user</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Username used to connect to the database.</td>
- </tr>
- <tr>
- <td>password</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Password used to connect to the database.</td>
- </tr>
- <tr>
- <td>table</td>
- <td>string</td>
- <td>No</td>
- <td>-</td>
- <td>Name of the table to which log entries are be inserted.</td>
- </tr>
- <tr>
- <td>insertSql</td>
- <td>string</td>
- <td>No</td>
- <td><em><a href="#Advanced_configuration">see below</a></em></td>
- <td>SQL query used to insert a log event.</td>
- </tr>
- <tr>
- <td>insertPattern</td>
- <td>string</td>
- <td>No</td>
- <td><em><a href="#Advanced_configuration">see below</a></em></td>
- <td>A comma separated list of format strings used in conjunction with <code>insertSql</code> parameter.</td>
- </tr>
- </tbody>
- </table>
-
- <p>Parameters <code>dsn</code>, <code>user</code> and <code>password</code> are used by PDO to connect to
- the database which will be used for logging.</p>
- </subsection>
-
- <subsection name="Data Source Name">
- <p>The Data Source Name or DSN is a database-specific string which contains the information required
- to connect to the database.</p>
-
- <p>Some common examples of DSNs:</p>
-
- <table class="table table-compact table-bordered table-not-wide">
- <tbody>
- <tr>
- <th>MySQL</th>
- <td><code>mysql:host=localhost;dbname=logdb</code></td>
- <td><a href="http://php.net/manual/en/ref.pdo-mysql.connection.php" class="external">full reference</a> </td>
- </tr>
- <tr>
- <th>SQLite</th>
- <td><code>sqlite:/path/to/log.db</code></td>
- <td><a href="http://php.net/manual/en/ref.pdo-sqlite.connection.php" class="external">full reference</a> </td>
- </tr>
- <tr>
- <th>PostgreSQL </th>
- <td><code>pgsql:host=localhost;port=5432</code></td>
- <td><a href="http://php.net/manual/en/ref.pdo-pgsql.connection.php" class="external">full reference</a> </td>
- </tr>
- </tbody>
- </table>
-
- <p>For other available database drivers and corresponding DSN format, please see the
- <a href="http://www.php.net/manual/en/pdo.drivers.php" class="external">PDO driver documentation</a>.
- </p>
- </subsection>
-
- <subsection name="Database table">
-
- <p>Since version 2.3.0, the appender will <strong>not</strong> create a database table by itself. You
- have to create a database table yourself. The reason for this is that various databases use various
- create statements and column types. Some common databases are covered in this chapter.</p>
-
- <p>By default the table should contain the following columns: </p>
-
- <ul>
- <li>timestamp DATETIME</li>
- <li>logger VARCHAR</li>
- <li>level VARCHAR</li>
- <li>message VARCHAR</li>
- <li>thread VARCHAR</li>
- <li>file VARCHAR</li>
- <li>line VARCHAR</li>
- </ul>
-
- <p>If you wish to use an alternative table structure, see the next chapter.</p>
-
- <p>The following examples show CREATE TABLE statements for some popular databases.</p>
-
- <h4>MySQL</h4>
-
-<pre class="prettyprint">
-CREATE TABLE log4php_log (
- timestamp DATETIME,
- logger VARCHAR(256),
- level VARCHAR(32),
- message VARCHAR(4000),
- thread INTEGER,
- file VARCHAR(255),
- line VARCHAR(10)
-);
-</pre>
-
- <h4>SQLite</h4>
-
- <p>SQLite does not have a datetime type, so varchar is used instead.</p>
-
-<pre class="prettyprint">
-CREATE TABLE log4php_log (
- timestamp VARCHAR(50),
- logger VARCHAR(256),
- level VARCHAR(32),
- message VARCHAR(4000),
- thread INTEGER,
- file VARCHAR(255),
- line VARCHAR(10)
-);
-</pre>
-
- <h4>PostgreSQL</h4>
-
-<pre class="prettyprint">
-CREATE TABLE log4php_log (
- timestamp TIMESTAMP,
- logger VARCHAR(256),
- level VARCHAR(32),
- message VARCHAR(4000),
- thread INTEGER,
- file VARCHAR(255),
- line VARCHAR(10)
-);
-</pre>
- </subsection>
-
- <subsection name="Advanced configuration" id="Advanced_configuration">
- <p>Parameters <code>insertSql</code> and <code>insertPattern</code> can be used to change how events are
- inserted into the database. By manipulating them, it is possible to use a custom table structure to
- suit your needs.</p>
-
- <p class="alert alert-warning"><strong>WARNING:</strong> Change these settings only if you are sure you
- know what you are doing.</p>
-
- <p>The default values of these parameters are:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Default value</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>insertSql</td>
- <td>INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)</td>
- </tr>
- <tr>
- <td>insertPattern</td>
- <td>%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line</td>
- </tr>
- </tbody>
- </table>
-
- <p>The string <em>__TABLE__</em> in <code>insertSql</code> will be replaced with the table name
- defined in <code>table</code>. Question marks in <code>insertSql</code> will be replaced by evaluated
- <code><a href="../layouts/pattern.html">LoggerPatternLayout</a></code> format strings defined in
- <code>insertPattern</code>. See <code><a href="../layouts/pattern.html">LoggerPatternLayout</a></code>
- documentation for format string description.</p>
-
- </subsection>
-
-
- <subsection name="Examples">
-
- <h4>Example 1</h4>
-
- <p>The simplest example is connecting to an SQLite database which does not require any
- authentication.</p>
-
- <p>SQLite databases are contained in simple files and don't reuquire a server to run. This example will
- log to the database contained in <code>/var/log/log.sqlite</code>.</p>
-
- <p>First, create a database and a table for logging. In this example, let's create the database at
- <code>/tmp/log.db</code>.</p>
-
-<pre><![CDATA[
-$ sqlite3 /tmp/log.db
-SQLite version 3.7.9 2011-11-01 00:52:41
-Enter ".help" for instructions
-Enter SQL statements terminated with a ";"
-sqlite> CREATE TABLE log4php_log (
- ...> timestamp VARCHAR(256),
- ...> logger VARCHAR(256),
- ...> level VARCHAR(32),
- ...> message VARCHAR(4000),
- ...> thread INTEGER,
- ...> file VARCHAR(255),
- ...> line VARCHAR(10)
- ...> );
-]]></pre>
-
- <p>When the database is set up, use the following configuration to set up log4php.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderPDO">
- <param name="dsn" value="sqlite:/tmp/log.db" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderPDO',
- 'params' => array(
- 'dsn' => 'sqlite:/tmp/log.db',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>Now the database is ready to accept some logging data.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-require 'log4php/Logger.php';
-Logger::configure('config.xml');
-
-$log = Logger::getLogger('foo');
-$log->info("foo");
-$log->info("bar");
-$log->info("baz");
-]]></pre>
-
- <p>And you can .</p>
-
-<pre><![CDATA[
-$ sqlite3 /tmp/log.db
-SQLite version 3.7.9 2011-11-01 00:52:41
-Enter ".help" for instructions
-Enter SQL statements terminated with a ";"
-sqlite> select * from log4php_log;
-2012-08-18 17:14:11|foo|INFO|foo|23531|/home/ihabunek/apache/sqlite.php|5
-2012-08-18 17:14:11|foo|INFO|bar|23531|/home/ihabunek/apache/sqlite.php|6
-2012-08-18 17:14:11|foo|INFO|baz|23531|/home/ihabunek/apache/sqlite.php|7
-]]></pre>
-
- <h4>Example 2</h4>
-
- <p>A slightly more complex example is connecting to a MySQL database which requires user credentials
- to be provided. Additionally, a user-specified table name is used.</p>
-
- <p>First, a log table has to be created. For this example a database named <code>logdb</code> will be
- created, and within it a table named <code>log</code>.</p>
-
-<pre><![CDATA[
-$ mysql -u root -p
-Enter password: *******
-Welcome to the MySQL monitor. Commands end with ; or \g.
-Your MySQL connection id is 47
-Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
-
-mysql> CREATE DATABASE logdb;
-Query OK, 1 row affected (0.00 sec)
-
-mysql> USE logdb;
-Database changed
-
-mysql> CREATE TABLE log (
- -> timestamp DATETIME,
- -> logger VARCHAR(256),
- -> level VARCHAR(32),
- -> message VARCHAR(4000),
- -> thread INTEGER,
- -> file VARCHAR(255),
- -> line VARCHAR(10)
- -> );
-Query OK, 0 rows affected (0.01 sec)
-]]></pre>
-
- <p>The following configuration allows log4php to write to the newly created table.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderPDO">
- <param name="dsn" value="mysql:host=localhost;dbname=logdb" />
- <param name="user" value="root" />
- <param name="password" value="secret" />
- <param name="table" value="log" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderPDO',
- 'params' => array(
- 'dsn' => 'mysql:host=localhost;dbname=logdb',
- 'user' => 'root',
- 'password' => 'secret',
- 'table' => 'log',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>Now the database is ready to accept some logging data.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-require 'log4php/Logger.php';
-Logger::configure('config.xml');
-
-$log = Logger::getLogger('main');
-$log->info("foo");
-$log->info("bar");
-$log->info("baz");
-]]></pre>
-
- <p>Finally, to see the newly logged data.</p>
-
-<pre><![CDATA[
-$ mysql -u root -p
-Enter password: *******
-Welcome to the MySQL monitor. Commands end with ; or \g.
-Your MySQL connection id is 47
-Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
-
-mysql> select * from log;
-+---------------------+--------+-------+---------+--------+---------------------------------+------+
-| timestamp | logger | level | message | thread | file | line |
-+---------------------+--------+-------+---------+--------+---------------------------------+------+
-| 2012-08-18 17:30:05 | main | INFO | foo | 23638 | /home/ihabunek/apache/mysql.php | 5 |
-| 2012-08-18 17:30:05 | main | INFO | bar | 23638 | /home/ihabunek/apache/mysql.php | 6 |
-| 2012-08-18 17:30:05 | main | INFO | baz | 23638 | /home/ihabunek/apache/mysql.php | 7 |
-+---------------------+--------+-------+---------+--------+---------------------------------+------+
-3 rows in set (0.00 sec)
-]]></pre>
-
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/php.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/php.xml b/src/site/xdoc/docs/appenders/php.xml
deleted file mode 100644
index 6331afd..0000000
--- a/src/site/xdoc/docs/appenders/php.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderPhp</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderPhp">
-
- <p><code>LoggerAppenderPhp</code> logs events by creating a PHP user-level message using the PHP's
- <code><a href="http://www.php.net/manual/en/function.trigger-error.php"
- class="external">trigger_error()</a></code>function.</p>
-
- <p>The message type depends on the event's severity level:</p>
- <ul>
- <li><code>E_USER_NOTICE</code> when the event's level is equal to or less than INFO</li>
- <li><code>E_USER_WARNING</code> when the event's level is equal to WARN</li>
- <li><code>E_USER_ERROR</code> when the event's level is equal to or greater than ERROR</li>
- </ul>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>This appender has no configurable parameters.</p>
- </subsection>
-
- <subsection name="Examples">
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderPhp">
- <layout class="LoggerLayoutSimple" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderPhp',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/rolling-file.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/rolling-file.xml b/src/site/xdoc/docs/appenders/rolling-file.xml
deleted file mode 100644
index 733687c..0000000
--- a/src/site/xdoc/docs/appenders/rolling-file.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderRollingFile</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderRollingFile">
-
- <p><code>LoggerAppenderRollingFile</code> writes logging events to a specified file. The file is rolled over
- after a specified size has been reached.</p>
-
- <p>For example, if logging to a file named <code>file.log</code>, when the file size reaches the specified
- size limit, the contents are archived in a file named <code>file.log.1</code> and <code>file.log</code>
- is truncated. When the size limit is reached the second time, <code>file.log.1</code> is renamed to
- <code>file.log.2</code>; contents from <code>file.log</code> are archived to <code>file.log.1</code> and
- <code>file.log</code> is truncated</p>
-
- <p>This continues until the maximum backup index is reached, after which the oldest log file is deleted
- on each rollover.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>file</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Path to the target file. Should contain a <code>%s</code> which gets substituted by the
- date.</td>
- </tr>
- <tr>
- <td>append</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the appender will append to the file, otherwise the file contents will be
- overwritten.</td>
- </tr>
- <tr>
- <td>maxFileSize</td>
- <td>string</td>
- <td>No</td>
- <td>10M</td>
- <td>Maximum allowed file size (in bytes) before rolling over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.</td>
- </tr>
- <tr>
- <td>maxBackupIndex</td>
- <td>integer</td>
- <td>No</td>
- <td>1</td>
- <td>Maximum number of backup files to keep.</td>
- </tr>
- <tr>
- <td>compress</td>
- <td>boolean</td>
- <td>No</td>
- <td>false</td>
- <td>If set to true, the rollover files are compressed and saved with the .gz extension.</td>
- </tr>
- </tbody>
- </table>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>This example shows how to configure <code>LoggerAppenderRollingFile</code> to rollover after reaching
- the size of 1MB and for keeping the last 5 backup files.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderRollingFile">
- <layout class="LoggerLayoutSimple" />
- <param name="file" value="file.log" />
- <param name="maxFileSize" value="1MB" />
- <param name="maxBackupIndex" value="5" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderRollingFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'file' => 'file.log',
- 'maxFileSize' => '1MB',
- 'maxBackupIndex' => 5,
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/socket.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/socket.xml b/src/site/xdoc/docs/appenders/socket.xml
deleted file mode 100644
index ed2f351..0000000
--- a/src/site/xdoc/docs/appenders/socket.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderSocket</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderSocket">
-
- <p><code>LoggerAppenderSocket</code> appends to a network socket.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/serialized.html">LoggerLayoutSerialized</a></code> will be used by default.</p>
-
- <p>Prior to version <code>2.2</code>, a layout was not required.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>remoteHost</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Target host. On how to define a remote hostname see <code>
- <a href="http://php.net/manual/en/function.fsockopen.php" class="external">fsockopen()</a>
- </code> documentation. </td>
- </tr>
- <tr>
- <td>port</td>
- <td>integer</td>
- <td>No</td>
- <td>4446</td>
- <td>Target port of the socket.</td>
- </tr>
- <tr>
- <td>timeout</td>
- <td>integer</td>
- <td>No</td>
- <td><code>ini_get('default_socket_timeout')</code></td>
- <td>Timeout in ms.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Changelog">
- <table class="table table-striped table-bordered table-not-wide">
- <thead>
- <tr>
- <th>Version</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>2.2.0</code></td>
- <td>From this version, the socket appender uses a layout to format the logging events.
- Because of this change, the following parameters are no longer used: <code>useXml</code>,
- <code>locationInfo</code>, <code>log4jNamespace</code>. These settings can be configured
- on the layout.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
-
- <p>In this example, log events are sent to a socket server at <code>localhost:4242</code>, using the
- default (serialized) layout.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderSocket">
- <param name="remoteHost" value="localhost" />
- <param name="port" value="4242" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderSocket',
- 'params' => array(
- 'remoteHost' => 'localhost',
- 'port' => 4242
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/syslog.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/syslog.xml b/src/site/xdoc/docs/appenders/syslog.xml
deleted file mode 100644
index 5874eca..0000000
--- a/src/site/xdoc/docs/appenders/syslog.xml
+++ /dev/null
@@ -1,355 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderSyslog</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderSyslog">
-
- <p><code>LoggerAppenderSyslog</code> logs events to the syslog.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>ident</td>
- <td>string</td>
- <td>no</td>
- <td>Apache log4php</td>
- <td>A string which will identify your appender.</td>
- </tr>
- <tr>
- <td>overridePriority</td>
- <td>boolean</td>
- <td>No</td>
- <td>false</td>
- <td>If set to true, all messages will be sent to the syslog using the priority specified
- in the <code>priority</code> parameter. Otherwise, the pririty will depend on the level
- of the event being logged. See below.</td>
- </tr>
- <tr>
- <td>priority</td>
- <td>string</td>
- <td>Yes/No</td>
- <td>-</td>
- <td>The syslog priority to use when overriding priority. This setting is required if
- <code>overridePriority</code> is set to true. <a href="#Priorities">See below</a> for
- available priorities.</td>
- </tr>
- <tr>
- <td>facility</td>
- <td>string</td>
- <td>No</td>
- <td><code>USER</code></td>
- <td>The syslog facility. Identifies the part of the system from which the event originated.
- <a href="#Facilities">See below</a> for available facilities.</td>
- </tr>
- <tr>
- <td>option</td>
- <td>string</td>
- <td>No</td>
- <td><code>PID|CONS</code></td>
- <td>Syslog options. <a href="#Options">See below</a> for available options.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Priorities" id="Priorities">
-
- <p>The <em>priority</em> is the syslog equivalent of the log4php level. Here's a list of priorities
- available in syslog and the equivalent log4php levels.</p>
-
- <table>
- <thead>
- <tr>
- <th>Priority</th>
- <th>Description</th>
- <th>Equivalent level</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>EMERG</td>
- <td>System is unusable.</td>
- <td>-</td>
- </tr>
- <tr>
- <td>ALERT</td>
- <td>Action must be taken immediately.</td>
- <td>FATAL</td>
- </tr>
- <tr>
- <td>CRIT</td>
- <td>Critical conditions.</td>
- <td>-</td>
- </tr>
- <tr>
- <td>ERR</td>
- <td>Error conditions.</td>
- <td>ERROR</td>
- </tr>
- <tr>
- <td>WARNING</td>
- <td>Warning conditions</td>
- <td>WARN</td>
- </tr>
- <tr>
- <td>NOTICE</td>
- <td>Normal, but significant, condition</td>
- <td>-</td>
- </tr>
- <tr>
- <td>INFO</td>
- <td>Informational message</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td>DEBUG</td>
- <td>Debug-level message</td>
- <td>DEBUG, TRACE</td>
- </tr>
- </tbody>
- </table>
-
- <p>Messages with level <code>FATAL</code> will be logged using the syslog's <code>ALERT</code> priority;
- <code>ERROR</code> level message will use <code>ERR</code> priority, etc.</p>
-
- <p>Note that there is no priority below <code>DEBUG</code>, therefore both <code>TRACE</code> and
- <code>DEBUG</code> level mesages will be logged using the <code>DEBUG</code> syslog priority.</p>
-
- </subsection>
-
- <subsection name="Facilities" id="Facilities">
-
- <p>The <em>facility</em> parameter is used to specify what type of program is logging the message. This
- allows you to specify (in your machine's syslog configuration) how messages coming from different
- facilities will be handled.</p>
-
- <p>The following facilities are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>KERN</td>
- <td>Kernel messages</td>
- </tr>
- <tr>
- <td>USER</td>
- <td>Generic user-level messages</td>
- </tr>
- <tr>
- <td>MAIL</td>
- <td>Mail system</td>
- </tr>
- <tr>
- <td>DAEMON</td>
- <td>System daemons</td>
- </tr>
- <tr>
- <td>AUTH</td>
- <td>Security/authorization messages</td>
- </tr>
- <tr>
- <td>SYSLOG</td>
- <td>Messages generated internally by syslogd</td>
- </tr>
- <tr>
- <td>LPR</td>
- <td>Line printer subsystem</td>
- </tr>
- <tr>
- <td>NEWS</td>
- <td>Network news subsystem</td>
- </tr>
- <tr>
- <td>UUCP</td>
- <td>UUCP subsystem</td>
- </tr>
- <tr>
- <td>CRON</td>
- <td>Clock daemon</td>
- </tr>
- <tr>
- <td>AUTHPRIV</td>
- <td>Security/authorization messages (private)</td>
- </tr>
- <tr>
- <td>LOCAL0</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL1</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL2</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL3</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL4</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL5</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL6</td>
- <td>Reserved for local use</td>
- </tr>
- <tr>
- <td>LOCAL7</td>
- <td>Reserved for local use</td>
- </tr>
- </tbody>
- </table>
-
- <p class="alert alert-warning">Warning: <code>USER</code> is the only facility available on
- Windows operating systems.</p>
-
- </subsection>
-
- <subsection name="Options" id="Options">
-
- <p>The following additional syslog options may be defined via the <em>option</em> parameter:</p>
-
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>CONS</td>
- <td>If there is an error while sending data to the system logger, write directly to the
- system console</td>
- </tr>
- <tr>
- <td>NDELAY</td>
- <td>Open the connection to the logger immediately.</td>
- </tr>
- <tr>
- <td>ODELAY</td>
- <td>Delay opening the connection until the first message is logged (default).</td>
- </tr>
- <tr>
- <td>PERROR</td>
- <td>Print log messages also to standard error.</td>
- </tr>
- <tr>
- <td>PID</td>
- <td>Include the PID with each message.</td>
- </tr>
- </tbody>
- </table>
-
- <p>Multiple options may be set by separating them with a pipe character. For example
- <code>CONS|PID|NODELAY</code>.</p>
-
- <p class="alert-message warning">Warning: When setting multiple options in an INI configuration file,
- be sure to put the options string in quotes. Otherwise they will not be parsed correctly.</p>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>Here is a sample configuration:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content">
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderSyslog">
- <layout class="LoggerLayoutSimple" />
- <param name="ident" value="log4php-test" />
- <param name="facility" value="LOCAL0" />
- <param name="option" value="NDELAY|PID" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderSyslog',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'ident' => 'log4php-test',
- 'facility' => 'LOCAL0',
- 'option' => 'NDELAY|PID'
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/configuration.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/configuration.xml b/src/site/xdoc/docs/configuration.xml
deleted file mode 100644
index 1e12a2e..0000000
--- a/src/site/xdoc/docs/configuration.xml
+++ /dev/null
@@ -1,285 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Configuration</title>
- </properties>
-
- <body>
- <section name="Configuration">
-
- <p>Most components of log4php have various settings which determing their behaviour. They can all be
- configured programatically, but a much more common way is by providing the configuration options
- in a file.</p>
-
- <p>Log4php understands three configuration formats: XML, PHP and Properties, all of which are covered in
- more details in the following sections.</p>
-
- <p>The configuration is passed to log4php by calling the static method <code>Logger::configure()</code>
- before issuing any logging requests. In case log4php is not configured by the time a logging request is
- issued, log4php will configure itself using the <a href="#Default_configuration">default configuration</a>.</p>
-
- <subsection name="XML" id="XML">
-
- <p>XML is the most common configuration format, and it is the most prominently featured in the
- documentation and examples.</p>
-
- <p>A simple configuration looks like this:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderFile">
- <layout class="LoggerLayoutSimple" />
- <param name="file" value="/var/log/my.log" />
- <param name="append" value="true" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
-
- <p>Detailed instructions on configuring each component is outlined in the corresponding compomnent's
- documentation:
- <a href="loggers.html">loggers</a>,
- <a href="appenders.html">appenders</a>,
- <a href="layouts.html">layouts</a>,
- <a href="filters.html">filters</a>,
- <a href="renderers.html">renderers</a>
- </p>
- </subsection>
-
- <subsection name="PHP" id="PHP">
-
- <p>Configuration can also be stored in a PHP array. This is the format used internally by log4php. All
- other formats are converted to a PHP array before being used by the configurator. Because of this, the
- PHP configuration format should be used when performance is important since it will avoid the overhead
- of parsing the ini or XML file.</p>
-
- <p>This format can be used in one of two ways:</p>
-
- <p>The configuration array can directly be passed to <code>Logger::configure()</code>.</p>
-
-<pre class="prettyprint linenums">
-Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'params' => array(
- 'file' => '/var/log/my.log',
- 'append' => true
- )
- )
- )
-));
-</pre>
-
- <p>Alternatively a file can be created which holds the PHP configuration array. The file must
- have the <code>php</code> extension and it should <em>return</em> the configuration array. For example,
- a file named <code>config.php</code> with the following content:</p>
-
-<pre class="prettyprint linenums">
-return array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'params' => array(
- 'file' => '/var/log/my.log',
- 'append' => true
- )
- )
- )
-);
-</pre>
-
- <p>This file can then be used to configure log4php:</p>
-
- <pre class="prettyprint">Logger::configure('config.php');</pre>
-
- <div class="alert alert-info">
- <p><strong>Hint:</strong> to translate a XML or properties configuration file to PHP, run the following code:</p>
-<pre class="prettyprint">
-$configurator = new LoggerConfiguratorDefault();
-$config = $configurator->parse('/path/to/config.xml');
-</pre>
- </div>
- </subsection>
-
-
- <subsection name="Properties (INI)" id="INI">
-
- <p>The properties configuration format is a legacy method of configuring log4php. It was inherited from
- <a href="logging.apache.org/log4j/1.2/manual.html">Apache log4j</a> and uses the same format. The only
- difference is that lines begin with <code>log4php</code> instead of <code>log4j</code>.</p>
-
- <div class="alert alert-warning">
- <p>This format has been deprecated. Support will not be removed for the foreseeable future, however
- it may not be updated to include newly introduced features. It is recommended that you use either
- the <a href="#XML">XML</a> or <a href="#PHP">PHP</a> configuration format.</p>
- </div>
-
- <p>The properites configuration format does not support filters.</p>
-
- <p>The following is a high level overview of this format:</p>
-
-
-<pre class="prettyprint">
-# Appender named "default"
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutSimple
-
-# Appender named "file"
-log4php.appender.file = LoggerAppenderDailyFile
-log4php.appender.file.layout = LoggerLayoutPattern
-log4php.appender.file.layout.conversionPattern = %d{ISO8601} [%p] %c: %m (at %F line %L)%n
-log4php.appender.file.datePattern = Ymd
-log4php.appender.file.file = target/examples/daily_%s.log
-log4php.appender.file.threshold = warn
-
-# Root logger, linked to "default" appender
-log4php.rootLogger = DEBUG, default
-
-# Logger named "foo", linked to "default" appender
-log4php.logger.foo = warn, default
-
-# Logger named "foo.bar", linked to "file" appender
-log4php.logger.foo.bar = debug, file
-log4php.additivity.foo.bar = true
-
-# Logger named "foo.bar.baz", linked to both "file" and "default" appenders
-log4php.logger.foo.bar.baz = trace, default, file
-log4php.additivity.foo.bar.baz = false
-
-# Renderers for Fruit and Beer classes
-log4php.renderer.Fruit = FruitRenderer
-log4php.renderer.Beer = BeerRenderer
-
-# Setting base threshold
-log4php.threshold = debug
-</pre>
- </subsection>
-
- <subsection name="Default configuration" id="Default_configuration">
- <p>If no configuration is provided before the initial logging request is issued, log4php will configure
- using the default configuration. This consists of a single <code>LoggerAppenderEcho</code> appender,
- using <code>LoggerLayoutSimple</code>, attached to the root logger and set to the DEBUG level.</p>
-
- <p>The default configuration in PHP format is:</p>
-
-<pre class="prettyprint linenums">
-array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderConsole',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- )
- )
- )
-)
-</pre>
-
- <div class="alert alert-info">
- <p><strong>Hint:</strong> You can fetch the default configuration as a PHP array by running:</p>
- <pre class="prettyprint">LoggerConfiguratorDefault::getDefaultConfiguration();</pre>
- </div>
- </subsection>
-
- <subsection name="Programmatic configuration">
-
- <p>It is possible to configure log4php fully programmatically. This requires the user to implement
- their own configurator object. Configurators must implement the <code>LoggerConfigurator</code>
- interface.</p>
-
- <p>Here is an example:</p>
-
-<pre class="prettyprint linenums">
-class MyConfigurator implements LoggerConfigurator {
-
- public function configure(LoggerHierarchy $hierarchy, $input = null) {
-
- // Create an appender which logs to file
- $appFile = new LoggerAppenderFile('foo');
- $appFile->setFile('D:/Temp/log.txt');
- $appFile->setAppend(true);
- $appFile->setThreshold('all');
- $appFile->activateOptions();
-
- // Use a different layout for the next appender
- $layout = new LoggerLayoutPattern();
- $layout->setConversionPattern("%date %logger %msg%newline");
- $layout->activateOptions();
-
- // Create an appender which echoes log events, using a custom layout
- // and with the threshold set to INFO
- $appEcho = new LoggerAppenderEcho('bar');
- $appEcho->setLayout($layout);
- $appEcho->setThreshold('info');
- $appEcho->activateOptions();
-
- // Add both appenders to the root logger
- $root = $hierarchy->getRootLogger();
- $root->addAppender($appFile);
- $root->addAppender($appEcho);
- }
-}
-</pre>
-
- <p>To use the configurator, pass it as a second parameter to <code>Logger::configure()</code> (either
- the name of the class as a string or an instance). Any value passed as <code>$configuration</code>
- will be available in the configure() method of the LoggerConfigurator as <code>$input</code>.</p>
-
-<pre class="prettyprint linenums">
-// User defined configuration (optional)
-$configuration = array(
- 'foo' => 1,
- 'bar' => 2
-);
-
-// Passing the configurator as string
-Logger::configure($configuration, 'MyConfigurator');
-
-// Passing the configurator as an instance
-Logger::configure($configuration, new MyConfigurator());
-</pre>
- <div class="alert alert-warning">
- <p><strong>Note: </strong>Always call <code>activateOptions()</code> on all appenders, filters and layouts after setting
- their configuration parameters. Otherwise, the configuration may not be properly activated.</p>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/filters.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/filters.xml b/src/site/xdoc/docs/filters.xml
deleted file mode 100644
index 555205d..0000000
--- a/src/site/xdoc/docs/filters.xml
+++ /dev/null
@@ -1,327 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Filters</title>
- </properties>
-
- <body>
- <section name="Filters">
-
- <p>Filtering is a mechanism which allows the user to configure more precisely which logging events will be
- logged by an appender, and which will be ignored.</p>
-
- <p>Multiple filters can be defined on any appender; they will form a filter chain. When a logging event is
- passed onto an appender, the event will first pass through the filter chain. Each filter in the chain will
- examine the logging event and make a decision to either:</p>
-
- <ol type="a">
- <li><strong>ACCEPT</strong> the logging event - The event will be logged without consulting the
- remaining filters in the chain.</li>
- <li><strong>DENY</strong> the logging event - The event will be not logged without consulting the
- remaining filters in the chain.</li>
- <li>Remain <strong>NEUTRAL</strong> - No decision is made, therefore the next filter in the chain is
- consulted. If there are no remaining filters in the chain, the event is logged.</li>
- </ol>
-
- <subsection name="Configuring filters" id="Configuring_filters">
-
- <p>Filters are configurable in the XML and PHP configuration format. They cannot be configured using
- the properties configuration format.</p>
-
- <p>Like appenders and layouts, depending on the class used, filters may have configurable parameters
- which determine their behaviour.</p>
-
- <p>Here is a configuration example:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="defualt" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple"/>
- <filter class="LoggerFilterStringMatch">
- <param name="stringToMatch" value="interesting" />
- <param name="acceptOnMatch" value="true" />
- </filter>
- <filter class="LoggerFilterLevelRange">
- <param name="levelMin" value="debug" />
- <param name="levelMax" value="error" />
- </filter>
- </appender>
- <root>
- <level value="TRACE" />
- <appender_ref ref="defualt" />
- </root>
-</configuration>
-]]></pre>
-
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho'
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'filters' => array(
- array(
- 'class' => 'LoggerFilterStringMatch',
- 'params' => array(
- 'stringToMatch' => 'interesting',
- 'acceptOnMatch' => true,
- )
- ),
- array(
- 'class' => 'LoggerFilterLevelRange',
- 'params' => array(
- 'levelMin' => 'debug',
- 'levelMax' => 'error',
- )
- )
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- )
-)
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>In this example, there are two filters defined for the <em>default</em> appender.</p>
-
- <p>The first filter <code>LoggerFilterStringMatch</code> searches for the string "interesting" in the
- logging event's message. If the string is found, the filter will ACCEPT the logging event, and the
- event will be logged. If the string is not found, the filter will remain NEUTRAL, and the event will be
- passed on to the next filter.</p>
-
- <p>The second filter <code>LoggerFilterLevelRange</code> ACCEPTS all events which have a level between
- DEBUG and ERROR (in other words, levels DEBUG, INFO, WARN and ERROR). It DENIES all other events.</p>
-
- <p>Therefore, this filter configuration will log events which which have a level between DEBUG and
- ERROR, except of theose which have the string "interesting" in the message. Those will be logged
- regardless of their level.</p>
-
- </subsection>
-
- <subsection name="Filter reference">
-
- <p>The following filters are available in log4php:</p>
-
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Destination</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a href="#LoggerFilterDenyAll">LoggerFilterDenyAll</a></td>
- <td>Denies all logging events.</td>
- </tr>
- <tr>
- <td><a href="#LoggerFilterLevelMatch">LoggerFilterLevelMatch</a></td>
- <td>Filters based on logging event level.</td>
- </tr>
- <tr>
- <td><a href="#LoggerFilterLevelRange">LoggerFilterLevelRange</a></td>
- <td>Filters based on logging event level range.</td>
- </tr>
- <tr>
- <td><a href="#LoggerFilterStringMatch">LoggerFilterStringMatch</a></td>
- <td>Filters by searching for a string in the logging event message.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
-
- <subsection name="LoggerFilterDenyAll" id="LoggerFilterDenyAll">
- <p>This filters simply denies all logging events. It has no configurable parameters.</p>
- </subsection>
-
- <subsection name="LoggerFilterLevelMatch" id="LoggerFilterLevelMatch">
- <p>This filter either accepts the specified logger level or denies it.</p>
-
- <h4>Configurable parameters</h4>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>levelToMatch</td>
- <td>LoggerLevel</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>The level to match</td>
- </tr>
- <tr>
- <td>acceptOnMatch</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If true, the matching log level is accepted, denied otherwise.</td>
- </tr>
- </tbody>
- </table>
-
- <h4>Example</h4>
-
- <p>The following filter configuration will deny all logging events with level DEBUG. It will remain
- neutral for others.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<filter class="LoggerFilterLevelMatch">
- <param name="levelToMatch" value="debug" />
- <param name="acceptOnMatch" value="false" />
-</filter>
-]]></pre>
-
- </subsection>
-
- <subsection name="LoggerFilterLevelRange" id="LoggerFilterLevelRange">
- <p>This filter accepts or denies logging events if their log level is within the specified range.</p>
-
- <h4>Configurable parameters</h4>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>levelMin</td>
- <td>LoggerLevel</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>The minimum level to log. If set, levels lower than this will be denied.</td>
- </tr>
- <tr>
- <td>levelMax</td>
- <td>LoggerLevel</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>The maximum level to log. If set, levels higher than this will be denied.</td>
- </tr>
- <tr>
- <td>acceptOnMatch</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If true, the matching log level is accepted, denied otherwise.</td>
- </tr>
- </tbody>
- </table>
-
- <h4>Example</h4>
-
- <p>The following filter configuration denies levels greater than WARN.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<filter class="LoggerFilterLevelRange">
- <param name="levelMax" value="warn" />
- <param name="acceptOnMatch" value="false" />
-</filter>
-]]></pre>
-
- </subsection>
-
- <subsection name="LoggerFilterStringMatch" id="LoggerFilterStringMatch">
- <p>This filter allows or denies logging events if their message contains a given string.</p>
-
- <h4>Configurable parameters</h4>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>stringToMatch</td>
- <td>LoggerLevel</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>The level to match</td>
- </tr>
- <tr>
- <td>levelMax</td>
- <td>LoggerLevel</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>The level to match</td>
- </tr>
- <tr>
- <td>acceptOnMatch</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If true, the matching log level is accepted, denied otherwise.</td>
- </tr>
- </tbody>
- </table>
-
- <h4>Example</h4>
-
- <p>The following filter configuration denies events which contain the string "not-interesting" in
- their message.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<filter class="LoggerFilterStringMatch">
- <param name="StringToMatch" value="not-interesting" />
- <param name="AcceptOnMatch" value="false" />
-</filter>
-]]></pre>
-
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/introduction.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/introduction.xml b/src/site/xdoc/docs/introduction.xml
deleted file mode 100644
index 6db5ca9..0000000
--- a/src/site/xdoc/docs/introduction.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Introduction</title>
- </properties>
-
- <body>
- <section name="Introduction">
-
- <p>There are three main concepts in Apache log4php: loggers, appenders and layouts. These three types of
- components work together to enable developers to log messages according to message type and level, and to
- control at runtime how these messages are formatted and where they are reported.</p>
-
- <subsection name="Loggers" id="Loggers">
- <p>A logger is a component which will take your logging request and log it. Each class in a project
- can have an individual logger, or they can all use a common logger. Loggers are named entities; it is
- common to name them after the class which will use it for logging.</p>
- </subsection>
-
- <subsection name="Appenders" id="Appenders">
- <p>Logging requests can be sent to multiple destinations and such destinations are called appenders.
- Appenders exist for console, files, syslog, database, sockets and other output destinations. One or
- more appenders can be attached to a logger. Each enabled logging request for a given logger will be
- forwarded to all the appenders in that logger.</p>
- </subsection>
-
- <subsection name="Layouts" id="Layouts">
- <p>Layouts are components responsible for transforming a logging event into a string. Most appender
- classes require a layout class to convert the event to a string so that it can be logged.</p>
- </subsection>
-
- <subsection name="Levels" id ="Levels">
- <p>A level describes the severity of a logging message. There are six levels, show here in descending order
- of severity.</p>
-
- <table>
- <thead>
- <tr>
- <th>Level</th>
- <th>Severity</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>FATAL</td>
- <td>Highest</td>
- <td>Very severe error events that will presumably lead the application to abort.</td>
- </tr>
- <tr>
- <td>ERROR</td>
- <td>...</td>
- <td>Error events that might still allow the application to continue running.</td>
- </tr>
- <tr>
- <td>WARN</td>
- <td>...</td>
- <td>Potentially harmful situations which still allow the application to continue running.</td>
- </tr>
- <tr>
- <td>INFO</td>
- <td>...</td>
- <td>Informational messages that highlight the progress of the application at coarse-grained level.</td>
- </tr>
- <tr>
- <td>DEBUG</td>
- <td>...</td>
- <td>Fine-grained informational events that are most useful to debug an application.</td>
- </tr>
- <tr>
- <td>TRACE</td>
- <td>Lowest</td>
- <td>Finest-grained informational events.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts.xml b/src/site/xdoc/docs/layouts.xml
deleted file mode 100644
index 974f381..0000000
--- a/src/site/xdoc/docs/layouts.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Layouts</title>
- </properties>
-
- <body>
- <section name="Layouts">
-
- <p>Layouts are components responsible for transforming a logging event into a string.</p>
-
- <p>More often than not, users wish to customize not only the output destination but also the output format. This is
- accomplished by associating a layout with an appender. All messages logged by that appender will use the given layout.</p>
-
- <subsection name="Layout reference" id="Layout_reference">
-
- <p>The following layout classes are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a href="layouts/html.html">LoggerLayoutHTML</a></td>
- <td> Outputs events in a HTML table.</td>
- </tr>
- <tr>
- <td><a href="layouts/pattern.html">LoggerLayoutPattern</a></td>
- <td>A flexible layout configurable via a pattern string.</td>
- </tr>
- <tr>
- <td><a href="layouts/simple.html">LoggerLayoutSimple</a></td>
- <td>A simple, non configurable layout.</td>
- </tr>
- <tr>
- <td><a href="layouts/serialized.html">LoggerLayoutSerialized</a></td>
- <td>Outputs serialized objects.</td>
- </tr>
- <tr>
- <td><a href="layouts/ttcc.html">LoggerLayoutTTCC</a></td>
- <td>Consists of Time, Thread, Category and nested diagnostic Context.
- <span class="label label-warning">DEPRECATED</span></td>
- </tr>
- <tr>
- <td><a href="layouts/xml.html">LoggerLayoutXml</a></td>
- <td>Outputs events as an XML document.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts/html.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts/html.xml b/src/site/xdoc/docs/layouts/html.xml
deleted file mode 100644
index ef77c4b..0000000
--- a/src/site/xdoc/docs/layouts/html.xml
+++ /dev/null
@@ -1,202 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerLayoutHTML</title>
- </properties>
-
- <body>
- <section name="LoggerLayoutHTML" id="LoggerLayoutHTML">
-
- <p>LoggerLayoutHTML formats the log as an HTML document.</p>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>locationInfo</td>
- <td>boolean</td>
- <td>No</td>
- <td>false</td>
- <td>If set to true, adds the file name and line number at which the log statement originated.</td>
- </tr>
- <tr>
- <td>title</td>
- <td>string</td>
- <td>No</td>
- <td>Log4php Log Messages</td>
- <td>Sets the <![CDATA[<title>]]> of the generated HTML document.</td>
- </tr>
- </tbody>
- </table>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>Configuration:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutHtml">
- <param name="locationInfo" value="true" />
- </layout>
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutHtml',
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>Running the following code:</p>
-
-<pre class="prettyprint linenums">
-Logger::configure("layout_xml.xml");
-$log = Logger::getRootLogger();
-$log->debug("Hello World!");
-$log->info("Hello World!");
-</pre>
-
- <p>Produces the output as a HTML table:</p>
-
- <table>
- <thead>
- <tr>
- <th>Time</th>
- <th>Thread</th>
- <th>Level</th>
- <th>Category</th>
- <th>File:Line</th>
- <th>Message</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>0</td>
- <td title="5868 thread">5868</td>
- <td title="Level"><font color="#339933">DEBUG</font></td>
- <td title="root category">root</td>
- <td>D:\Projects\apache\log4php-config-adapters\src\examples\php\layout_html.php:23</td>
- <td title="Message">Hello World!</td>
- </tr>
-
- <tr>
- <td>2</td>
- <td title="5868 thread">5868</td>
- <td title="Level">INFO</td>
- <td title="root category">root</td>
- <td>D:\Projects\apache\log4php-config-adapters\src\examples\php\layout_html.php:24</td>
- <td title="Message">Hello World!</td>
- </tr>
- </tbody>
- </table>
-
- <p>Source of the output:</p>
-
-<pre class="prettyprint"><![CDATA[
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <title>Log4php Log Messages</title>
- <style type="text/css">
- <!--
- body, table {font-family: arial,sans-serif; font-size: x-small;}
- th {background: #336699; color: #FFFFFF; text-align: left;}
- -->
- </style>
-</head>
-<body bgcolor="#FFFFFF" topmargin="6" leftmargin="6">
-<hr size="1" noshade>
-Log session start time 09/22/11 13:19:23<br>
-<br>
-<table cellspacing="0" cellpadding="4" border="1" bordercolor="#224466" width="100%">
- <tr>
- <th>Time</th>
- <th>Thread</th>
- <th>Level</th>
- <th>Category</th>
- <th>File:Line</th>
- <th>Message</th>
- </tr>
- <tr>
- <td>0</td>
- <td title="5868 thread">5868</td>
- <td title="Level"><font color="#339933">DEBUG</font></td>
- <td title="root category">root</td>
- <td>D:\Projects\apache\log4php-config-adapters\src\examples\php\layout_html.php:23</td>
- <td title="Message">Hello World!</td>
- </tr>
- <tr>
- <td>2</td>
- <td title="5868 thread">5868</td>
- <td title="Level">INFO</td>
- <td title="root category">root</td>
- <td>D:\Projects\apache\log4php-config-adapters\src\examples\php\layout_html.php:24</td>
- <td title="Message">Hello World!</td>
- </tr>
-</table>
-<br>
-</body>
-</html>]]></pre>
-
- </subsection>
- </section>
- </body>
-</document>
[11/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/prettify.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/prettify.js b/src/site/resources/js/prettify.js
deleted file mode 100644
index 037c26d..0000000
--- a/src/site/resources/js/prettify.js
+++ /dev/null
@@ -1,1477 +0,0 @@
-// Copyright (C) 2006 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-/**
- * @fileoverview
- * some functions for browser-side pretty printing of code contained in html.
- *
- * <p>
- * For a fairly comprehensive set of languages see the
- * <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs">README</a>
- * file that came with this source. At a minimum, the lexer should work on a
- * number of languages including C and friends, Java, Python, Bash, SQL, HTML,
- * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk
- * and a subset of Perl, but, because of commenting conventions, doesn't work on
- * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class.
- * <p>
- * Usage: <ol>
- * <li> include this source file in an html page via
- * {@code <script type="text/javascript" src="/path/to/prettify.js"></script>}
- * <li> define style rules. See the example page for examples.
- * <li> mark the {@code <pre>} and {@code <code>} tags in your source with
- * {@code class=prettyprint.}
- * You can also use the (html deprecated) {@code <xmp>} tag, but the pretty
- * printer needs to do more substantial DOM manipulations to support that, so
- * some css styles may not be preserved.
- * </ol>
- * That's it. I wanted to keep the API as simple as possible, so there's no
- * need to specify which language the code is in, but if you wish, you can add
- * another class to the {@code <pre>} or {@code <code>} element to specify the
- * language, as in {@code <pre class="prettyprint lang-java">}. Any class that
- * starts with "lang-" followed by a file extension, specifies the file type.
- * See the "lang-*.js" files in this directory for code that implements
- * per-language file handlers.
- * <p>
- * Change log:<br>
- * cbeust, 2006/08/22
- * <blockquote>
- * Java annotations (start with "@") are now captured as literals ("lit")
- * </blockquote>
- * @requires console
- */
-
-// JSLint declarations
-/*global console, document, navigator, setTimeout, window */
-
-/**
- * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
- * UI events.
- * If set to {@code false}, {@code prettyPrint()} is synchronous.
- */
-window['PR_SHOULD_USE_CONTINUATION'] = true;
-
-(function () {
- // Keyword lists for various languages.
- // We use things that coerce to strings to make them compact when minified
- // and to defeat aggressive optimizers that fold large string constants.
- var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
- var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
- "double,enum,extern,float,goto,int,long,register,short,signed,sizeof," +
- "static,struct,switch,typedef,union,unsigned,void,volatile"];
- var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
- "new,operator,private,protected,public,this,throw,true,try,typeof"];
- var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
- "concept,concept_map,const_cast,constexpr,decltype," +
- "dynamic_cast,explicit,export,friend,inline,late_check," +
- "mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast," +
- "template,typeid,typename,using,virtual,where"];
- var JAVA_KEYWORDS = [COMMON_KEYWORDS,
- "abstract,boolean,byte,extends,final,finally,implements,import," +
- "instanceof,null,native,package,strictfp,super,synchronized,throws," +
- "transient"];
- var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
- "as,base,by,checked,decimal,delegate,descending,dynamic,event," +
- "fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock," +
- "object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed," +
- "stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];
- var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
- "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
- "true,try,unless,until,when,while,yes";
- var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
- "debugger,eval,export,function,get,null,set,undefined,var,with," +
- "Infinity,NaN"];
- var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
- "goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
- "sub,undef,unless,until,use,wantarray,while,BEGIN,END";
- var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
- "elif,except,exec,finally,from,global,import,in,is,lambda," +
- "nonlocal,not,or,pass,print,raise,try,with,yield," +
- "False,True,None"];
- var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
- "def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
- "rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
- "BEGIN,END"];
- var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
- "function,in,local,set,then,until"];
- var ALL_KEYWORDS = [
- CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS +
- PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
- var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;
-
- // token style names. correspond to css classes
- /**
- * token style for a string literal
- * @const
- */
- var PR_STRING = 'str';
- /**
- * token style for a keyword
- * @const
- */
- var PR_KEYWORD = 'kwd';
- /**
- * token style for a comment
- * @const
- */
- var PR_COMMENT = 'com';
- /**
- * token style for a type
- * @const
- */
- var PR_TYPE = 'typ';
- /**
- * token style for a literal value. e.g. 1, null, true.
- * @const
- */
- var PR_LITERAL = 'lit';
- /**
- * token style for a punctuation string.
- * @const
- */
- var PR_PUNCTUATION = 'pun';
- /**
- * token style for a punctuation string.
- * @const
- */
- var PR_PLAIN = 'pln';
-
- /**
- * token style for an sgml tag.
- * @const
- */
- var PR_TAG = 'tag';
- /**
- * token style for a markup declaration such as a DOCTYPE.
- * @const
- */
- var PR_DECLARATION = 'dec';
- /**
- * token style for embedded source.
- * @const
- */
- var PR_SOURCE = 'src';
- /**
- * token style for an sgml attribute name.
- * @const
- */
- var PR_ATTRIB_NAME = 'atn';
- /**
- * token style for an sgml attribute value.
- * @const
- */
- var PR_ATTRIB_VALUE = 'atv';
-
- /**
- * A class that indicates a section of markup that is not code, e.g. to allow
- * embedding of line numbers within code listings.
- * @const
- */
- var PR_NOCODE = 'nocode';
-
-
-
-/**
- * A set of tokens that can precede a regular expression literal in
- * javascript
- * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
- * has the full list, but I've removed ones that might be problematic when
- * seen in languages that don't support regular expression literals.
- *
- * <p>Specifically, I've removed any keywords that can't precede a regexp
- * literal in a syntactically legal javascript program, and I've removed the
- * "in" keyword since it's not a keyword in many languages, and might be used
- * as a count of inches.
- *
- * <p>The link a above does not accurately describe EcmaScript rules since
- * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
- * very well in practice.
- *
- * @private
- * @const
- */
-var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
-
-// CAVEAT: this does not properly handle the case where a regular
-// expression immediately follows another since a regular expression may
-// have flags for case-sensitivity and the like. Having regexp tokens
-// adjacent is not valid in any language I'm aware of, so I'm punting.
-// TODO: maybe style special characters inside a regexp as punctuation.
-
-
- /**
- * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
- * matches the union of the sets of strings matched by the input RegExp.
- * Since it matches globally, if the input strings have a start-of-input
- * anchor (/^.../), it is ignored for the purposes of unioning.
- * @param {Array.<RegExp>} regexs non multiline, non-global regexs.
- * @return {RegExp} a global regex.
- */
- function combinePrefixPatterns(regexs) {
- var capturedGroupIndex = 0;
-
- var needToFoldCase = false;
- var ignoreCase = false;
- for (var i = 0, n = regexs.length; i < n; ++i) {
- var regex = regexs[i];
- if (regex.ignoreCase) {
- ignoreCase = true;
- } else if (/[a-z]/i.test(regex.source.replace(
- /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
- needToFoldCase = true;
- ignoreCase = false;
- break;
- }
- }
-
- var escapeCharToCodeUnit = {
- 'b': 8,
- 't': 9,
- 'n': 0xa,
- 'v': 0xb,
- 'f': 0xc,
- 'r': 0xd
- };
-
- function decodeEscape(charsetPart) {
- var cc0 = charsetPart.charCodeAt(0);
- if (cc0 !== 92 /* \\ */) {
- return cc0;
- }
- var c1 = charsetPart.charAt(1);
- cc0 = escapeCharToCodeUnit[c1];
- if (cc0) {
- return cc0;
- } else if ('0' <= c1 && c1 <= '7') {
- return parseInt(charsetPart.substring(1), 8);
- } else if (c1 === 'u' || c1 === 'x') {
- return parseInt(charsetPart.substring(2), 16);
- } else {
- return charsetPart.charCodeAt(1);
- }
- }
-
- function encodeEscape(charCode) {
- if (charCode < 0x20) {
- return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
- }
- var ch = String.fromCharCode(charCode);
- if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
- ch = '\\' + ch;
- }
- return ch;
- }
-
- function caseFoldCharset(charSet) {
- var charsetParts = charSet.substring(1, charSet.length - 1).match(
- new RegExp(
- '\\\\u[0-9A-Fa-f]{4}'
- + '|\\\\x[0-9A-Fa-f]{2}'
- + '|\\\\[0-3][0-7]{0,2}'
- + '|\\\\[0-7]{1,2}'
- + '|\\\\[\\s\\S]'
- + '|-'
- + '|[^-\\\\]',
- 'g'));
- var groups = [];
- var ranges = [];
- var inverse = charsetParts[0] === '^';
- for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
- var p = charsetParts[i];
- if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
- groups.push(p);
- } else {
- var start = decodeEscape(p);
- var end;
- if (i + 2 < n && '-' === charsetParts[i + 1]) {
- end = decodeEscape(charsetParts[i + 2]);
- i += 2;
- } else {
- end = start;
- }
- ranges.push([start, end]);
- // If the range might intersect letters, then expand it.
- // This case handling is too simplistic.
- // It does not deal with non-latin case folding.
- // It works for latin source code identifiers though.
- if (!(end < 65 || start > 122)) {
- if (!(end < 65 || start > 90)) {
- ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
- }
- if (!(end < 97 || start > 122)) {
- ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
- }
- }
- }
- }
-
- // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
- // -> [[1, 12], [14, 14], [16, 17]]
- ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
- var consolidatedRanges = [];
- var lastRange = [NaN, NaN];
- for (var i = 0; i < ranges.length; ++i) {
- var range = ranges[i];
- if (range[0] <= lastRange[1] + 1) {
- lastRange[1] = Math.max(lastRange[1], range[1]);
- } else {
- consolidatedRanges.push(lastRange = range);
- }
- }
-
- var out = ['['];
- if (inverse) { out.push('^'); }
- out.push.apply(out, groups);
- for (var i = 0; i < consolidatedRanges.length; ++i) {
- var range = consolidatedRanges[i];
- out.push(encodeEscape(range[0]));
- if (range[1] > range[0]) {
- if (range[1] + 1 > range[0]) { out.push('-'); }
- out.push(encodeEscape(range[1]));
- }
- }
- out.push(']');
- return out.join('');
- }
-
- function allowAnywhereFoldCaseAndRenumberGroups(regex) {
- // Split into character sets, escape sequences, punctuation strings
- // like ('(', '(?:', ')', '^'), and runs of characters that do not
- // include any of the above.
- var parts = regex.source.match(
- new RegExp(
- '(?:'
- + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
- + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
- + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
- + '|\\\\[0-9]+' // a back-reference or octal escape
- + '|\\\\[^ux0-9]' // other escape sequence
- + '|\\(\\?[:!=]' // start of a non-capturing group
- + '|[\\(\\)\\^]' // start/emd of a group, or line start
- + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
- + ')',
- 'g'));
- var n = parts.length;
-
- // Maps captured group numbers to the number they will occupy in
- // the output or to -1 if that has not been determined, or to
- // undefined if they need not be capturing in the output.
- var capturedGroups = [];
-
- // Walk over and identify back references to build the capturedGroups
- // mapping.
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- var p = parts[i];
- if (p === '(') {
- // groups are 1-indexed, so max group index is count of '('
- ++groupIndex;
- } else if ('\\' === p.charAt(0)) {
- var decimalValue = +p.substring(1);
- if (decimalValue && decimalValue <= groupIndex) {
- capturedGroups[decimalValue] = -1;
- }
- }
- }
-
- // Renumber groups and reduce capturing groups to non-capturing groups
- // where possible.
- for (var i = 1; i < capturedGroups.length; ++i) {
- if (-1 === capturedGroups[i]) {
- capturedGroups[i] = ++capturedGroupIndex;
- }
- }
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- var p = parts[i];
- if (p === '(') {
- ++groupIndex;
- if (capturedGroups[groupIndex] === undefined) {
- parts[i] = '(?:';
- }
- } else if ('\\' === p.charAt(0)) {
- var decimalValue = +p.substring(1);
- if (decimalValue && decimalValue <= groupIndex) {
- parts[i] = '\\' + capturedGroups[groupIndex];
- }
- }
- }
-
- // Remove any prefix anchors so that the output will match anywhere.
- // ^^ really does mean an anchored match though.
- for (var i = 0, groupIndex = 0; i < n; ++i) {
- if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
- }
-
- // Expand letters to groups to handle mixing of case-sensitive and
- // case-insensitive patterns if necessary.
- if (regex.ignoreCase && needToFoldCase) {
- for (var i = 0; i < n; ++i) {
- var p = parts[i];
- var ch0 = p.charAt(0);
- if (p.length >= 2 && ch0 === '[') {
- parts[i] = caseFoldCharset(p);
- } else if (ch0 !== '\\') {
- // TODO: handle letters in numeric escapes.
- parts[i] = p.replace(
- /[a-zA-Z]/g,
- function (ch) {
- var cc = ch.charCodeAt(0);
- return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
- });
- }
- }
- }
-
- return parts.join('');
- }
-
- var rewritten = [];
- for (var i = 0, n = regexs.length; i < n; ++i) {
- var regex = regexs[i];
- if (regex.global || regex.multiline) { throw new Error('' + regex); }
- rewritten.push(
- '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
- }
-
- return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
- }
-
-
- /**
- * Split markup into a string of source code and an array mapping ranges in
- * that string to the text nodes in which they appear.
- *
- * <p>
- * The HTML DOM structure:</p>
- * <pre>
- * (Element "p"
- * (Element "b"
- * (Text "print ")) ; #1
- * (Text "'Hello '") ; #2
- * (Element "br") ; #3
- * (Text " + 'World';")) ; #4
- * </pre>
- * <p>
- * corresponds to the HTML
- * {@code <p><b>print </b>'Hello '<br> + 'World';</p>}.</p>
- *
- * <p>
- * It will produce the output:</p>
- * <pre>
- * {
- * sourceCode: "print 'Hello '\n + 'World';",
- * // 1 2
- * // 012345678901234 5678901234567
- * spans: [0, #1, 6, #2, 14, #3, 15, #4]
- * }
- * </pre>
- * <p>
- * where #1 is a reference to the {@code "print "} text node above, and so
- * on for the other text nodes.
- * </p>
- *
- * <p>
- * The {@code} spans array is an array of pairs. Even elements are the start
- * indices of substrings, and odd elements are the text nodes (or BR elements)
- * that contain the text for those substrings.
- * Substrings continue until the next index or the end of the source.
- * </p>
- *
- * @param {Node} node an HTML DOM subtree containing source-code.
- * @return {Object} source code and the text nodes in which they occur.
- */
- function extractSourceSpans(node) {
- var nocode = /(?:^|\s)nocode(?:\s|$)/;
-
- var chunks = [];
- var length = 0;
- var spans = [];
- var k = 0;
-
- var whitespace;
- if (node.currentStyle) {
- whitespace = node.currentStyle.whiteSpace;
- } else if (window.getComputedStyle) {
- whitespace = document.defaultView.getComputedStyle(node, null)
- .getPropertyValue('white-space');
- }
- var isPreformatted = whitespace && 'pre' === whitespace.substring(0, 3);
-
- function walk(node) {
- switch (node.nodeType) {
- case 1: // Element
- if (nocode.test(node.className)) { return; }
- for (var child = node.firstChild; child; child = child.nextSibling) {
- walk(child);
- }
- var nodeName = node.nodeName;
- if ('BR' === nodeName || 'LI' === nodeName) {
- chunks[k] = '\n';
- spans[k << 1] = length++;
- spans[(k++ << 1) | 1] = node;
- }
- break;
- case 3: case 4: // Text
- var text = node.nodeValue;
- if (text.length) {
- if (!isPreformatted) {
- text = text.replace(/[ \t\r\n]+/g, ' ');
- } else {
- text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
- }
- // TODO: handle tabs here?
- chunks[k] = text;
- spans[k << 1] = length;
- length += text.length;
- spans[(k++ << 1) | 1] = node;
- }
- break;
- }
- }
-
- walk(node);
-
- return {
- sourceCode: chunks.join('').replace(/\n$/, ''),
- spans: spans
- };
- }
-
-
- /**
- * Apply the given language handler to sourceCode and add the resulting
- * decorations to out.
- * @param {number} basePos the index of sourceCode within the chunk of source
- * whose decorations are already present on out.
- */
- function appendDecorations(basePos, sourceCode, langHandler, out) {
- if (!sourceCode) { return; }
- var job = {
- sourceCode: sourceCode,
- basePos: basePos
- };
- langHandler(job);
- out.push.apply(out, job.decorations);
- }
-
- var notWs = /\S/;
-
- /**
- * Given an element, if it contains only one child element and any text nodes
- * it contains contain only space characters, return the sole child element.
- * Otherwise returns undefined.
- * <p>
- * This is meant to return the CODE element in {@code <pre><code ...>} when
- * there is a single child element that contains all the non-space textual
- * content, but not to return anything where there are multiple child elements
- * as in {@code <pre><code>...</code><code>...</code></pre>} or when there
- * is textual content.
- */
- function childContentWrapper(element) {
- var wrapper = undefined;
- for (var c = element.firstChild; c; c = c.nextSibling) {
- var type = c.nodeType;
- wrapper = (type === 1) // Element Node
- ? (wrapper ? element : c)
- : (type === 3) // Text Node
- ? (notWs.test(c.nodeValue) ? element : wrapper)
- : wrapper;
- }
- return wrapper === element ? undefined : wrapper;
- }
-
- /** Given triples of [style, pattern, context] returns a lexing function,
- * The lexing function interprets the patterns to find token boundaries and
- * returns a decoration list of the form
- * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
- * where index_n is an index into the sourceCode, and style_n is a style
- * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
- * all characters in sourceCode[index_n-1:index_n].
- *
- * The stylePatterns is a list whose elements have the form
- * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
- *
- * Style is a style constant like PR_PLAIN, or can be a string of the
- * form 'lang-FOO', where FOO is a language extension describing the
- * language of the portion of the token in $1 after pattern executes.
- * E.g., if style is 'lang-lisp', and group 1 contains the text
- * '(hello (world))', then that portion of the token will be passed to the
- * registered lisp handler for formatting.
- * The text before and after group 1 will be restyled using this decorator
- * so decorators should take care that this doesn't result in infinite
- * recursion. For example, the HTML lexer rule for SCRIPT elements looks
- * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
- * '<script>foo()<\/script>', which would cause the current decorator to
- * be called with '<script>' which would not match the same rule since
- * group 1 must not be empty, so it would be instead styled as PR_TAG by
- * the generic tag rule. The handler registered for the 'js' extension would
- * then be called with 'foo()', and finally, the current decorator would
- * be called with '<\/script>' which would not match the original rule and
- * so the generic tag rule would identify it as a tag.
- *
- * Pattern must only match prefixes, and if it matches a prefix, then that
- * match is considered a token with the same style.
- *
- * Context is applied to the last non-whitespace, non-comment token
- * recognized.
- *
- * Shortcut is an optional string of characters, any of which, if the first
- * character, gurantee that this pattern and only this pattern matches.
- *
- * @param {Array} shortcutStylePatterns patterns that always start with
- * a known character. Must have a shortcut string.
- * @param {Array} fallthroughStylePatterns patterns that will be tried in
- * order if the shortcut ones fail. May have shortcuts.
- *
- * @return {function (Object)} a
- * function that takes source code and returns a list of decorations.
- */
- function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
- var shortcuts = {};
- var tokenizer;
- (function () {
- var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
- var allRegexs = [];
- var regexKeys = {};
- for (var i = 0, n = allPatterns.length; i < n; ++i) {
- var patternParts = allPatterns[i];
- var shortcutChars = patternParts[3];
- if (shortcutChars) {
- for (var c = shortcutChars.length; --c >= 0;) {
- shortcuts[shortcutChars.charAt(c)] = patternParts;
- }
- }
- var regex = patternParts[1];
- var k = '' + regex;
- if (!regexKeys.hasOwnProperty(k)) {
- allRegexs.push(regex);
- regexKeys[k] = null;
- }
- }
- allRegexs.push(/[\0-\uffff]/);
- tokenizer = combinePrefixPatterns(allRegexs);
- })();
-
- var nPatterns = fallthroughStylePatterns.length;
-
- /**
- * Lexes job.sourceCode and produces an output array job.decorations of
- * style classes preceded by the position at which they start in
- * job.sourceCode in order.
- *
- * @param {Object} job an object like <pre>{
- * sourceCode: {string} sourceText plain text,
- * basePos: {int} position of job.sourceCode in the larger chunk of
- * sourceCode.
- * }</pre>
- */
- var decorate = function (job) {
- var sourceCode = job.sourceCode, basePos = job.basePos;
- /** Even entries are positions in source in ascending order. Odd enties
- * are style markers (e.g., PR_COMMENT) that run from that position until
- * the end.
- * @type {Array.<number|string>}
- */
- var decorations = [basePos, PR_PLAIN];
- var pos = 0; // index into sourceCode
- var tokens = sourceCode.match(tokenizer) || [];
- var styleCache = {};
-
- for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
- var token = tokens[ti];
- var style = styleCache[token];
- var match = void 0;
-
- var isEmbedded;
- if (typeof style === 'string') {
- isEmbedded = false;
- } else {
- var patternParts = shortcuts[token.charAt(0)];
- if (patternParts) {
- match = token.match(patternParts[1]);
- style = patternParts[0];
- } else {
- for (var i = 0; i < nPatterns; ++i) {
- patternParts = fallthroughStylePatterns[i];
- match = token.match(patternParts[1]);
- if (match) {
- style = patternParts[0];
- break;
- }
- }
-
- if (!match) { // make sure that we make progress
- style = PR_PLAIN;
- }
- }
-
- isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
- if (isEmbedded && !(match && typeof match[1] === 'string')) {
- isEmbedded = false;
- style = PR_SOURCE;
- }
-
- if (!isEmbedded) { styleCache[token] = style; }
- }
-
- var tokenStart = pos;
- pos += token.length;
-
- if (!isEmbedded) {
- decorations.push(basePos + tokenStart, style);
- } else { // Treat group 1 as an embedded block of source code.
- var embeddedSource = match[1];
- var embeddedSourceStart = token.indexOf(embeddedSource);
- var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
- if (match[2]) {
- // If embeddedSource can be blank, then it would match at the
- // beginning which would cause us to infinitely recurse on the
- // entire token, so we catch the right context in match[2].
- embeddedSourceEnd = token.length - match[2].length;
- embeddedSourceStart = embeddedSourceEnd - embeddedSource.length;
- }
- var lang = style.substring(5);
- // Decorate the left of the embedded source
- appendDecorations(
- basePos + tokenStart,
- token.substring(0, embeddedSourceStart),
- decorate, decorations);
- // Decorate the embedded source
- appendDecorations(
- basePos + tokenStart + embeddedSourceStart,
- embeddedSource,
- langHandlerForExtension(lang, embeddedSource),
- decorations);
- // Decorate the right of the embedded section
- appendDecorations(
- basePos + tokenStart + embeddedSourceEnd,
- token.substring(embeddedSourceEnd),
- decorate, decorations);
- }
- }
- job.decorations = decorations;
- };
- return decorate;
- }
-
- /** returns a function that produces a list of decorations from source text.
- *
- * This code treats ", ', and ` as string delimiters, and \ as a string
- * escape. It does not recognize perl's qq() style strings.
- * It has no special handling for double delimiter escapes as in basic, or
- * the tripled delimiters used in python, but should work on those regardless
- * although in those cases a single string literal may be broken up into
- * multiple adjacent string literals.
- *
- * It recognizes C, C++, and shell style comments.
- *
- * @param {Object} options a set of optional parameters.
- * @return {function (Object)} a function that examines the source code
- * in the input job and builds the decoration list.
- */
- function sourceDecorator(options) {
- var shortcutStylePatterns = [], fallthroughStylePatterns = [];
- if (options['tripleQuotedStrings']) {
- // '''multi-line-string''', 'single-line-string', and double-quoted
- shortcutStylePatterns.push(
- [PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
- null, '\'"']);
- } else if (options['multiLineStrings']) {
- // 'multi-line-string', "multi-line-string"
- shortcutStylePatterns.push(
- [PR_STRING, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
- null, '\'"`']);
- } else {
- // 'single-line-string', "single-line-string"
- shortcutStylePatterns.push(
- [PR_STRING,
- /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
- null, '"\'']);
- }
- if (options['verbatimStrings']) {
- // verbatim-string-literal production from the C# grammar. See issue 93.
- fallthroughStylePatterns.push(
- [PR_STRING, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]);
- }
- var hc = options['hashComments'];
- if (hc) {
- if (options['cStyleComments']) {
- if (hc > 1) { // multiline hash comments
- shortcutStylePatterns.push(
- [PR_COMMENT, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, '#']);
- } else {
- // Stop C preprocessor declarations at an unclosed open comment
- shortcutStylePatterns.push(
- [PR_COMMENT, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,
- null, '#']);
- }
- fallthroughStylePatterns.push(
- [PR_STRING,
- /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
- null]);
- } else {
- shortcutStylePatterns.push([PR_COMMENT, /^#[^\r\n]*/, null, '#']);
- }
- }
- if (options['cStyleComments']) {
- fallthroughStylePatterns.push([PR_COMMENT, /^\/\/[^\r\n]*/, null]);
- fallthroughStylePatterns.push(
- [PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
- }
- if (options['regexLiterals']) {
- /**
- * @const
- */
- var REGEX_LITERAL = (
- // A regular expression literal starts with a slash that is
- // not followed by * or / so that it is not confused with
- // comments.
- '/(?=[^/*])'
- // and then contains any number of raw characters,
- + '(?:[^/\\x5B\\x5C]'
- // escape sequences (\x5C),
- + '|\\x5C[\\s\\S]'
- // or non-nesting character sets (\x5B\x5D);
- + '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
- // finally closed by a /.
- + '/');
- fallthroughStylePatterns.push(
- ['lang-regex',
- new RegExp('^' + REGEXP_PRECEDER_PATTERN + '(' + REGEX_LITERAL + ')')
- ]);
- }
-
- var types = options['types'];
- if (types) {
- fallthroughStylePatterns.push([PR_TYPE, types]);
- }
-
- var keywords = ("" + options['keywords']).replace(/^ | $/g, '');
- if (keywords.length) {
- fallthroughStylePatterns.push(
- [PR_KEYWORD,
- new RegExp('^(?:' + keywords.replace(/[\s,]+/g, '|') + ')\\b'),
- null]);
- }
-
- shortcutStylePatterns.push([PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0']);
- fallthroughStylePatterns.push(
- // TODO(mikesamuel): recognize non-latin letters and numerals in idents
- [PR_LITERAL, /^@[a-z_$][a-z_$@0-9]*/i, null],
- [PR_TYPE, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null],
- [PR_PLAIN, /^[a-z_$][a-z_$@0-9]*/i, null],
- [PR_LITERAL,
- new RegExp(
- '^(?:'
- // A hex number
- + '0x[a-f0-9]+'
- // or an octal or decimal number,
- + '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
- // possibly in scientific notation
- + '(?:e[+\\-]?\\d+)?'
- + ')'
- // with an optional modifier like UL for unsigned long
- + '[a-z]*', 'i'),
- null, '0123456789'],
- // Don't treat escaped quotes in bash as starting strings. See issue 144.
- [PR_PLAIN, /^\\[\s\S]?/, null],
- [PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);
-
- return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
- }
-
- var decorateSource = sourceDecorator({
- 'keywords': ALL_KEYWORDS,
- 'hashComments': true,
- 'cStyleComments': true,
- 'multiLineStrings': true,
- 'regexLiterals': true
- });
-
- /**
- * Given a DOM subtree, wraps it in a list, and puts each line into its own
- * list item.
- *
- * @param {Node} node modified in place. Its content is pulled into an
- * HTMLOListElement, and each line is moved into a separate list item.
- * This requires cloning elements, so the input might not have unique
- * IDs after numbering.
- */
- function numberLines(node, opt_startLineNum) {
- var nocode = /(?:^|\s)nocode(?:\s|$)/;
- var lineBreak = /\r\n?|\n/;
-
- var document = node.ownerDocument;
-
- var whitespace;
- if (node.currentStyle) {
- whitespace = node.currentStyle.whiteSpace;
- } else if (window.getComputedStyle) {
- whitespace = document.defaultView.getComputedStyle(node, null)
- .getPropertyValue('white-space');
- }
- // If it's preformatted, then we need to split lines on line breaks
- // in addition to <BR>s.
- var isPreformatted = whitespace && 'pre' === whitespace.substring(0, 3);
-
- var li = document.createElement('LI');
- while (node.firstChild) {
- li.appendChild(node.firstChild);
- }
- // An array of lines. We split below, so this is initialized to one
- // un-split line.
- var listItems = [li];
-
- function walk(node) {
- switch (node.nodeType) {
- case 1: // Element
- if (nocode.test(node.className)) { break; }
- if ('BR' === node.nodeName) {
- breakAfter(node);
- // Discard the <BR> since it is now flush against a </LI>.
- if (node.parentNode) {
- node.parentNode.removeChild(node);
- }
- } else {
- for (var child = node.firstChild; child; child = child.nextSibling) {
- walk(child);
- }
- }
- break;
- case 3: case 4: // Text
- if (isPreformatted) {
- var text = node.nodeValue;
- var match = text.match(lineBreak);
- if (match) {
- var firstLine = text.substring(0, match.index);
- node.nodeValue = firstLine;
- var tail = text.substring(match.index + match[0].length);
- if (tail) {
- var parent = node.parentNode;
- parent.insertBefore(
- document.createTextNode(tail), node.nextSibling);
- }
- breakAfter(node);
- if (!firstLine) {
- // Don't leave blank text nodes in the DOM.
- node.parentNode.removeChild(node);
- }
- }
- }
- break;
- }
- }
-
- // Split a line after the given node.
- function breakAfter(lineEndNode) {
- // If there's nothing to the right, then we can skip ending the line
- // here, and move root-wards since splitting just before an end-tag
- // would require us to create a bunch of empty copies.
- while (!lineEndNode.nextSibling) {
- lineEndNode = lineEndNode.parentNode;
- if (!lineEndNode) { return; }
- }
-
- function breakLeftOf(limit, copy) {
- // Clone shallowly if this node needs to be on both sides of the break.
- var rightSide = copy ? limit.cloneNode(false) : limit;
- var parent = limit.parentNode;
- if (parent) {
- // We clone the parent chain.
- // This helps us resurrect important styling elements that cross lines.
- // E.g. in <i>Foo<br>Bar</i>
- // should be rewritten to <li><i>Foo</i></li><li><i>Bar</i></li>.
- var parentClone = breakLeftOf(parent, 1);
- // Move the clone and everything to the right of the original
- // onto the cloned parent.
- var next = limit.nextSibling;
- parentClone.appendChild(rightSide);
- for (var sibling = next; sibling; sibling = next) {
- next = sibling.nextSibling;
- parentClone.appendChild(sibling);
- }
- }
- return rightSide;
- }
-
- var copiedListItem = breakLeftOf(lineEndNode.nextSibling, 0);
-
- // Walk the parent chain until we reach an unattached LI.
- for (var parent;
- // Check nodeType since IE invents document fragments.
- (parent = copiedListItem.parentNode) && parent.nodeType === 1;) {
- copiedListItem = parent;
- }
- // Put it on the list of lines for later processing.
- listItems.push(copiedListItem);
- }
-
- // Split lines while there are lines left to split.
- for (var i = 0; // Number of lines that have been split so far.
- i < listItems.length; // length updated by breakAfter calls.
- ++i) {
- walk(listItems[i]);
- }
-
- // Make sure numeric indices show correctly.
- if (opt_startLineNum === (opt_startLineNum|0)) {
- listItems[0].setAttribute('value', opt_startLineNum);
- }
-
- var ol = document.createElement('OL');
- ol.className = 'linenums';
- var offset = Math.max(0, ((opt_startLineNum - 1 /* zero index */)) | 0) || 0;
- for (var i = 0, n = listItems.length; i < n; ++i) {
- li = listItems[i];
- // Stick a class on the LIs so that stylesheets can
- // color odd/even rows, or any other row pattern that
- // is co-prime with 10.
- li.className = 'L' + ((i + offset) % 10);
- if (!li.firstChild) {
- li.appendChild(document.createTextNode('\xA0'));
- }
- ol.appendChild(li);
- }
-
- node.appendChild(ol);
- }
-
- /**
- * Breaks {@code job.sourceCode} around style boundaries in
- * {@code job.decorations} and modifies {@code job.sourceNode} in place.
- * @param {Object} job like <pre>{
- * sourceCode: {string} source as plain text,
- * spans: {Array.<number|Node>} alternating span start indices into source
- * and the text node or element (e.g. {@code <BR>}) corresponding to that
- * span.
- * decorations: {Array.<number|string} an array of style classes preceded
- * by the position at which they start in job.sourceCode in order
- * }</pre>
- * @private
- */
- function recombineTagsAndDecorations(job) {
- var isIE = /\bMSIE\b/.test(navigator.userAgent);
- var newlineRe = /\n/g;
-
- var source = job.sourceCode;
- var sourceLength = source.length;
- // Index into source after the last code-unit recombined.
- var sourceIndex = 0;
-
- var spans = job.spans;
- var nSpans = spans.length;
- // Index into spans after the last span which ends at or before sourceIndex.
- var spanIndex = 0;
-
- var decorations = job.decorations;
- var nDecorations = decorations.length;
- // Index into decorations after the last decoration which ends at or before
- // sourceIndex.
- var decorationIndex = 0;
-
- // Remove all zero-length decorations.
- decorations[nDecorations] = sourceLength;
- var decPos, i;
- for (i = decPos = 0; i < nDecorations;) {
- if (decorations[i] !== decorations[i + 2]) {
- decorations[decPos++] = decorations[i++];
- decorations[decPos++] = decorations[i++];
- } else {
- i += 2;
- }
- }
- nDecorations = decPos;
-
- // Simplify decorations.
- for (i = decPos = 0; i < nDecorations;) {
- var startPos = decorations[i];
- // Conflate all adjacent decorations that use the same style.
- var startDec = decorations[i + 1];
- var end = i + 2;
- while (end + 2 <= nDecorations && decorations[end + 1] === startDec) {
- end += 2;
- }
- decorations[decPos++] = startPos;
- decorations[decPos++] = startDec;
- i = end;
- }
-
- nDecorations = decorations.length = decPos;
-
- var decoration = null;
- while (spanIndex < nSpans) {
- var spanStart = spans[spanIndex];
- var spanEnd = spans[spanIndex + 2] || sourceLength;
-
- var decStart = decorations[decorationIndex];
- var decEnd = decorations[decorationIndex + 2] || sourceLength;
-
- var end = Math.min(spanEnd, decEnd);
-
- var textNode = spans[spanIndex + 1];
- var styledText;
- if (textNode.nodeType !== 1 // Don't muck with <BR>s or <LI>s
- // Don't introduce spans around empty text nodes.
- && (styledText = source.substring(sourceIndex, end))) {
- // This may seem bizarre, and it is. Emitting LF on IE causes the
- // code to display with spaces instead of line breaks.
- // Emitting Windows standard issue linebreaks (CRLF) causes a blank
- // space to appear at the beginning of every line but the first.
- // Emitting an old Mac OS 9 line separator makes everything spiffy.
- if (isIE) { styledText = styledText.replace(newlineRe, '\r'); }
- textNode.nodeValue = styledText;
- var document = textNode.ownerDocument;
- var span = document.createElement('SPAN');
- span.className = decorations[decorationIndex + 1];
- var parentNode = textNode.parentNode;
- parentNode.replaceChild(span, textNode);
- span.appendChild(textNode);
- if (sourceIndex < spanEnd) { // Split off a text node.
- spans[spanIndex + 1] = textNode
- // TODO: Possibly optimize by using '' if there's no flicker.
- = document.createTextNode(source.substring(end, spanEnd));
- parentNode.insertBefore(textNode, span.nextSibling);
- }
- }
-
- sourceIndex = end;
-
- if (sourceIndex >= spanEnd) {
- spanIndex += 2;
- }
- if (sourceIndex >= decEnd) {
- decorationIndex += 2;
- }
- }
- }
-
-
- /** Maps language-specific file extensions to handlers. */
- var langHandlerRegistry = {};
- /** Register a language handler for the given file extensions.
- * @param {function (Object)} handler a function from source code to a list
- * of decorations. Takes a single argument job which describes the
- * state of the computation. The single parameter has the form
- * {@code {
- * sourceCode: {string} as plain text.
- * decorations: {Array.<number|string>} an array of style classes
- * preceded by the position at which they start in
- * job.sourceCode in order.
- * The language handler should assigned this field.
- * basePos: {int} the position of source in the larger source chunk.
- * All positions in the output decorations array are relative
- * to the larger source chunk.
- * } }
- * @param {Array.<string>} fileExtensions
- */
- function registerLangHandler(handler, fileExtensions) {
- for (var i = fileExtensions.length; --i >= 0;) {
- var ext = fileExtensions[i];
- if (!langHandlerRegistry.hasOwnProperty(ext)) {
- langHandlerRegistry[ext] = handler;
- } else if (window['console']) {
- console['warn']('cannot override language handler %s', ext);
- }
- }
- }
- function langHandlerForExtension(extension, source) {
- if (!(extension && langHandlerRegistry.hasOwnProperty(extension))) {
- // Treat it as markup if the first non whitespace character is a < and
- // the last non-whitespace character is a >.
- extension = /^\s*</.test(source)
- ? 'default-markup'
- : 'default-code';
- }
- return langHandlerRegistry[extension];
- }
- registerLangHandler(decorateSource, ['default-code']);
- registerLangHandler(
- createSimpleLexer(
- [],
- [
- [PR_PLAIN, /^[^<?]+/],
- [PR_DECLARATION, /^<!\w[^>]*(?:>|$)/],
- [PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/],
- // Unescaped content in an unknown language
- ['lang-', /^<\?([\s\S]+?)(?:\?>|$)/],
- ['lang-', /^<%([\s\S]+?)(?:%>|$)/],
- [PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/],
- ['lang-', /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
- // Unescaped content in javascript. (Or possibly vbscript).
- ['lang-js', /^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],
- // Contains unescaped stylesheet content
- ['lang-css', /^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],
- ['lang-in.tag', /^(<\/?[a-z][^<>]*>)/i]
- ]),
- ['default-markup', 'htm', 'html', 'mxml', 'xhtml', 'xml', 'xsl']);
- registerLangHandler(
- createSimpleLexer(
- [
- [PR_PLAIN, /^[\s]+/, null, ' \t\r\n'],
- [PR_ATTRIB_VALUE, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, '\"\'']
- ],
- [
- [PR_TAG, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],
- [PR_ATTRIB_NAME, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],
- ['lang-uq.val', /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],
- [PR_PUNCTUATION, /^[=<>\/]+/],
- ['lang-js', /^on\w+\s*=\s*\"([^\"]+)\"/i],
- ['lang-js', /^on\w+\s*=\s*\'([^\']+)\'/i],
- ['lang-js', /^on\w+\s*=\s*([^\"\'>\s]+)/i],
- ['lang-css', /^style\s*=\s*\"([^\"]+)\"/i],
- ['lang-css', /^style\s*=\s*\'([^\']+)\'/i],
- ['lang-css', /^style\s*=\s*([^\"\'>\s]+)/i]
- ]),
- ['in.tag']);
- registerLangHandler(
- createSimpleLexer([], [[PR_ATTRIB_VALUE, /^[\s\S]+/]]), ['uq.val']);
- registerLangHandler(sourceDecorator({
- 'keywords': CPP_KEYWORDS,
- 'hashComments': true,
- 'cStyleComments': true,
- 'types': C_TYPES
- }), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
- registerLangHandler(sourceDecorator({
- 'keywords': 'null,true,false'
- }), ['json']);
- registerLangHandler(sourceDecorator({
- 'keywords': CSHARP_KEYWORDS,
- 'hashComments': true,
- 'cStyleComments': true,
- 'verbatimStrings': true,
- 'types': C_TYPES
- }), ['cs']);
- registerLangHandler(sourceDecorator({
- 'keywords': JAVA_KEYWORDS,
- 'cStyleComments': true
- }), ['java']);
- registerLangHandler(sourceDecorator({
- 'keywords': SH_KEYWORDS,
- 'hashComments': true,
- 'multiLineStrings': true
- }), ['bsh', 'csh', 'sh']);
- registerLangHandler(sourceDecorator({
- 'keywords': PYTHON_KEYWORDS,
- 'hashComments': true,
- 'multiLineStrings': true,
- 'tripleQuotedStrings': true
- }), ['cv', 'py']);
- registerLangHandler(sourceDecorator({
- 'keywords': PERL_KEYWORDS,
- 'hashComments': true,
- 'multiLineStrings': true,
- 'regexLiterals': true
- }), ['perl', 'pl', 'pm']);
- registerLangHandler(sourceDecorator({
- 'keywords': RUBY_KEYWORDS,
- 'hashComments': true,
- 'multiLineStrings': true,
- 'regexLiterals': true
- }), ['rb']);
- registerLangHandler(sourceDecorator({
- 'keywords': JSCRIPT_KEYWORDS,
- 'cStyleComments': true,
- 'regexLiterals': true
- }), ['js']);
- registerLangHandler(sourceDecorator({
- 'keywords': COFFEE_KEYWORDS,
- 'hashComments': 3, // ### style block comments
- 'cStyleComments': true,
- 'multilineStrings': true,
- 'tripleQuotedStrings': true,
- 'regexLiterals': true
- }), ['coffee']);
- registerLangHandler(createSimpleLexer([], [[PR_STRING, /^[\s\S]+/]]), ['regex']);
-
- function applyDecorator(job) {
- var opt_langExtension = job.langExtension;
-
- try {
- // Extract tags, and convert the source code to plain text.
- var sourceAndSpans = extractSourceSpans(job.sourceNode);
- /** Plain text. @type {string} */
- var source = sourceAndSpans.sourceCode;
- job.sourceCode = source;
- job.spans = sourceAndSpans.spans;
- job.basePos = 0;
-
- // Apply the appropriate language handler
- langHandlerForExtension(opt_langExtension, source)(job);
-
- // Integrate the decorations and tags back into the source code,
- // modifying the sourceNode in place.
- recombineTagsAndDecorations(job);
- } catch (e) {
- if ('console' in window) {
- console['log'](e && e['stack'] ? e['stack'] : e);
- }
- }
- }
-
- /**
- * @param sourceCodeHtml {string} The HTML to pretty print.
- * @param opt_langExtension {string} The language name to use.
- * Typically, a filename extension like 'cpp' or 'java'.
- * @param opt_numberLines {number|boolean} True to number lines,
- * or the 1-indexed number of the first line in sourceCodeHtml.
- */
- function prettyPrintOne(sourceCodeHtml, opt_langExtension, opt_numberLines) {
- var container = document.createElement('PRE');
- // This could cause images to load and onload listeners to fire.
- // E.g. <img onerror="alert(1337)" src="nosuchimage.png">.
- // We assume that the inner HTML is from a trusted source.
- container.innerHTML = sourceCodeHtml;
- if (opt_numberLines) {
- numberLines(container, opt_numberLines);
- }
-
- var job = {
- langExtension: opt_langExtension,
- numberLines: opt_numberLines,
- sourceNode: container
- };
- applyDecorator(job);
- return container.innerHTML;
- }
-
- function prettyPrint(opt_whenDone) {
- function byTagName(tn) { return document.getElementsByTagName(tn); }
- // fetch a list of nodes to rewrite
- var codeSegments = [byTagName('pre'), byTagName('code'), byTagName('xmp')];
- var elements = [];
- for (var i = 0; i < codeSegments.length; ++i) {
- for (var j = 0, n = codeSegments[i].length; j < n; ++j) {
- elements.push(codeSegments[i][j]);
- }
- }
- codeSegments = null;
-
- var clock = Date;
- if (!clock['now']) {
- clock = { 'now': function () { return +(new Date); } };
- }
-
- // The loop is broken into a series of continuations to make sure that we
- // don't make the browser unresponsive when rewriting a large page.
- var k = 0;
- var prettyPrintingJob;
-
- var langExtensionRe = /\blang(?:uage)?-([\w.]+)(?!\S)/;
- var prettyPrintRe = /\bprettyprint\b/;
-
- function doWork() {
- var endTime = (window['PR_SHOULD_USE_CONTINUATION'] ?
- clock['now']() + 250 /* ms */ :
- Infinity);
- for (; k < elements.length && clock['now']() < endTime; k++) {
- var cs = elements[k];
- var className = cs.className;
- if (className.indexOf('prettyprint') >= 0) {
- // If the classes includes a language extensions, use it.
- // Language extensions can be specified like
- // <pre class="prettyprint lang-cpp">
- // the language extension "cpp" is used to find a language handler as
- // passed to PR.registerLangHandler.
- // HTML5 recommends that a language be specified using "language-"
- // as the prefix instead. Google Code Prettify supports both.
- // http://dev.w3.org/html5/spec-author-view/the-code-element.html
- var langExtension = className.match(langExtensionRe);
- // Support <pre class="prettyprint"><code class="language-c">
- var wrapper;
- if (!langExtension && (wrapper = childContentWrapper(cs))
- && "CODE" === wrapper.tagName) {
- langExtension = wrapper.className.match(langExtensionRe);
- }
-
- if (langExtension) {
- langExtension = langExtension[1];
- }
-
- // make sure this is not nested in an already prettified element
- var nested = false;
- for (var p = cs.parentNode; p; p = p.parentNode) {
- if ((p.tagName === 'pre' || p.tagName === 'code' ||
- p.tagName === 'xmp') &&
- p.className && p.className.indexOf('prettyprint') >= 0) {
- nested = true;
- break;
- }
- }
- if (!nested) {
- // Look for a class like linenums or linenums:<n> where <n> is the
- // 1-indexed number of the first line.
- var lineNums = cs.className.match(/\blinenums\b(?::(\d+))?/);
- lineNums = lineNums
- ? lineNums[1] && lineNums[1].length ? +lineNums[1] : true
- : false;
- if (lineNums) { numberLines(cs, lineNums); }
-
- // do the pretty printing
- prettyPrintingJob = {
- langExtension: langExtension,
- sourceNode: cs,
- numberLines: lineNums
- };
- applyDecorator(prettyPrintingJob);
- }
- }
- }
- if (k < elements.length) {
- // finish up in a continuation
- setTimeout(doWork, 250);
- } else if (opt_whenDone) {
- opt_whenDone();
- }
- }
-
- doWork();
- }
-
- /**
- * Find all the {@code <pre>} and {@code <code>} tags in the DOM with
- * {@code class=prettyprint} and prettify them.
- *
- * @param {Function?} opt_whenDone if specified, called when the last entry
- * has been finished.
- */
- window['prettyPrintOne'] = prettyPrintOne;
- /**
- * Pretty print a chunk of code.
- *
- * @param {string} sourceCodeHtml code as html
- * @return {string} code as html, but prettier
- */
- window['prettyPrint'] = prettyPrint;
- /**
- * Contains functions for creating and registering new language handlers.
- * @type {Object}
- */
- window['PR'] = {
- 'createSimpleLexer': createSimpleLexer,
- 'registerLangHandler': registerLangHandler,
- 'sourceDecorator': sourceDecorator,
- 'PR_ATTRIB_NAME': PR_ATTRIB_NAME,
- 'PR_ATTRIB_VALUE': PR_ATTRIB_VALUE,
- 'PR_COMMENT': PR_COMMENT,
- 'PR_DECLARATION': PR_DECLARATION,
- 'PR_KEYWORD': PR_KEYWORD,
- 'PR_LITERAL': PR_LITERAL,
- 'PR_NOCODE': PR_NOCODE,
- 'PR_PLAIN': PR_PLAIN,
- 'PR_PUNCTUATION': PR_PUNCTUATION,
- 'PR_SOURCE': PR_SOURCE,
- 'PR_STRING': PR_STRING,
- 'PR_TAG': PR_TAG,
- 'PR_TYPE': PR_TYPE
- };
-})();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/prettify.min.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/prettify.min.js b/src/site/resources/js/prettify.min.js
deleted file mode 100644
index 6623601..0000000
--- a/src/site/resources/js/prettify.min.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2006 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
-(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
-[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
-f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
-(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
-{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
-t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
-"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
-l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
-q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
-q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
-"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
-a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
-for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
-m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
-a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
-j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
-"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
-H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
-J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
-I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
-["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
-/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
-["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
-hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
-!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
-250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
-PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/site.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/site.js b/src/site/resources/js/site.js
deleted file mode 100644
index c0f231b..0000000
--- a/src/site/resources/js/site.js
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-/* Executed on page load. */
-$(document).ready(function() {
-
- //
- // This is a hack to enable google-code-prettify to work with maven.
- //
- // The problem is that maven, when building the site, replaces:
- // <pre class="prettyprint">...</pre>
- // with:
- // <div class="prettyprint"><pre>...</pre></div>
- //
- // Effectively, it removes the class parameter from the <pre> element, which
- // is required for google-code-prettify to work.
- //
- // This hack restores the class of all <pre> elements which are the child of
- // a <div class="prettyprint">.
- //
- $('pre').each(function() {
- var parent = $(this).parent();
-
- if (parent.hasClass('prettyprint')) {
- parent.removeClass('prettyprint');
- $(this).addClass('prettyprint');
- }
-
- if (parent.hasClass('linenums')) {
- parent.removeClass('linenums');
- $(this).addClass('linenums');
- }
- })
-
- // Hack to add default visuals to tables
- $('table').each(function() {
- if ($(this).hasClass('bodyTable')) {
-
- // Remove border="1" which is added by maven
- this.border = 0;
-
- // Add bootstrap table styling
- $(this).addClass('table table-striped table-bordered');
- }
- });
-
- // Render tabs
- $('.auto-tabs').each(function(groupid) {
-
- // Find tab bar
- $(this).find('ul').each(function() {
-
- // Add styling
- $(this).addClass('nav nav-tabs');
-
- // Go tab bar items
- $(this).find('li').each(function(itemid) {
-
- // Set first tab as active
- if (itemid == 0) {
- $(this).addClass('active');
- }
-
- // Replace text with a link to tab contents
- var name = $(this).html();
- var link = $('<a>')
- .attr('href', '#' + 'tab-' + groupid + '-' + itemid)
- .attr('data-toggle', 'tab')
- .html(name);
- $(this).html(link);
- });
- });
-
- // Find tab contents
- $(this).find('.tab-content .tab-pane').each(function(itemid) {
-
- // Set first tab as active
- if (itemid == 0) {
- $(this).addClass('active');
- }
-
- // Set the tab id
- $(this).attr('id', 'tab-' + groupid + '-' + itemid);
- });
- });
-
- // Make external links open in new tab
- $('a.external').attr('target', '_blank');
-
- // Trigger prettyprint
- prettyPrint();
-});
[32/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_invalid_filter_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_filter_class.xml b/tests/resources/configs/appenders/config_invalid_filter_class.xml
index 80c9736..cc9b958 100644
--- a/tests/resources/configs/appenders/config_invalid_filter_class.xml
+++ b/tests/resources/configs/appenders/config_invalid_filter_class.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <filter class="stdClass" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <filter class="stdClass" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_filter_parameters.xml b/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
index d17183d..af23f3e 100644
--- a/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
+++ b/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <filter class="StringMatchFilter">
- <param name="fooParameter" value="bar" />
- </filter>
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <filter class="StringMatchFilter">
+ <param name="fooParameter" value="bar" />
+ </filter>
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_invalid_layout_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_layout_class.xml b/tests/resources/configs/appenders/config_invalid_layout_class.xml
index 308243f..4713f72 100644
--- a/tests/resources/configs/appenders/config_invalid_layout_class.xml
+++ b/tests/resources/configs/appenders/config_invalid_layout_class.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="stdClass" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="stdClass" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_no_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_no_class.xml b/tests/resources/configs/appenders/config_no_class.xml
index 1e581f3..d0804b0 100644
--- a/tests/resources/configs/appenders/config_no_class.xml
+++ b/tests/resources/configs/appenders/config_no_class.xml
@@ -1,26 +1,26 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
-
- <appender name="foo" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+
+ <appender name="foo" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_no_layout_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_no_layout_class.xml b/tests/resources/configs/appenders/config_no_layout_class.xml
index 035226b..bf2df80 100644
--- a/tests/resources/configs/appenders/config_no_layout_class.xml
+++ b/tests/resources/configs/appenders/config_no_layout_class.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_not_existing_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_not_existing_class.xml b/tests/resources/configs/appenders/config_not_existing_class.xml
index ec5aae0..6a9a80d 100644
--- a/tests/resources/configs/appenders/config_not_existing_class.xml
+++ b/tests/resources/configs/appenders/config_not_existing_class.xml
@@ -1,25 +1,25 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="foo" class="unknownClass"/>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="foo" class="unknownClass"/>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_not_existing_filter_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_not_existing_filter_class.xml b/tests/resources/configs/appenders/config_not_existing_filter_class.xml
index 1d4e1ea..8be90e6 100644
--- a/tests/resources/configs/appenders/config_not_existing_filter_class.xml
+++ b/tests/resources/configs/appenders/config_not_existing_filter_class.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <filter class="Foo" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <filter class="Foo" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_not_existing_layout_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_not_existing_layout_class.xml b/tests/resources/configs/appenders/config_not_existing_layout_class.xml
index 5fc72a5..dcee56d 100644
--- a/tests/resources/configs/appenders/config_not_existing_layout_class.xml
+++ b/tests/resources/configs/appenders/config_not_existing_layout_class.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="Foo" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="Foo" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/config.yml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/config.yml b/tests/resources/configs/config.yml
index 07b86fb..03803a9 100644
--- a/tests/resources/configs/config.yml
+++ b/tests/resources/configs/config.yml
@@ -1,14 +1,14 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/config1.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/config1.xml b/tests/resources/configs/config1.xml
index 6553c44..bb326a6 100644
--- a/tests/resources/configs/config1.xml
+++ b/tests/resources/configs/config1.xml
@@ -1,54 +1,54 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="EchoAppender">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LevelRangeFilter">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- <filter class="DenyAllFilter" />
- </appender>
- <appender name="file" class="DailyFileAppender" threshold="warn">
- <param name="datePattern" value="Ymd" />
- <param name="file" value="target/examples/daily_%s.log" />
- <layout class="PatternLayout">
- <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
- </layout>
- </appender>
- <logger name="foo.bar.baz" additivity="false">
- <level value="trace" />
- <appender_ref ref="default" />
- </logger>
- <logger name="foo.bar" additivity="true">
- <level value="debug" />
- <appender_ref ref="file" />
- </logger>
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- <appender_ref ref="file" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="LoggerLayoutTTCC"/>
+ <filter class="LevelRangeFilter">
+ <param name="levelMin" value="ERROR" />
+ <param name="levelMax" value="FATAL" />
+ <param name="acceptOnMatch" value="false" />
+ </filter>
+ <filter class="DenyAllFilter" />
+ </appender>
+ <appender name="file" class="DailyFileAppender" threshold="warn">
+ <param name="datePattern" value="Ymd" />
+ <param name="file" value="target/examples/daily_%s.log" />
+ <layout class="PatternLayout">
+ <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
+ </layout>
+ </appender>
+ <logger name="foo.bar.baz" additivity="false">
+ <level value="trace" />
+ <appender_ref ref="default" />
+ </logger>
+ <logger name="foo.bar" additivity="true">
+ <level value="debug" />
+ <appender_ref ref="file" />
+ </logger>
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ <appender_ref ref="file" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/loggers/config_invalid_additivity.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/loggers/config_invalid_additivity.xml b/tests/resources/configs/loggers/config_invalid_additivity.xml
index 13fe2cc..e6128bd 100644
--- a/tests/resources/configs/loggers/config_invalid_additivity.xml
+++ b/tests/resources/configs/loggers/config_invalid_additivity.xml
@@ -1,30 +1,30 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="default" class="EchoAppender">
- <layout class="SimpleLayout"/>
- </appender>
- <logger name="myLogger" additivity="4711">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+ <logger name="myLogger" additivity="4711">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/loggers/config_not_existing_appenders.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/loggers/config_not_existing_appenders.xml b/tests/resources/configs/loggers/config_not_existing_appenders.xml
index 5e5ea1e..3f19039 100644
--- a/tests/resources/configs/loggers/config_not_existing_appenders.xml
+++ b/tests/resources/configs/loggers/config_not_existing_appenders.xml
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <logger name="myLogger">
- <level value="warn" />
- <appender_ref ref="unknownAppender" />
- </logger>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <logger name="myLogger">
+ <level value="warn" />
+ <appender_ref ref="unknownAppender" />
+ </logger>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/renderers/config_default_renderer.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_default_renderer.xml b/tests/resources/configs/renderers/config_default_renderer.xml
index 5c22323..9bdb545 100644
--- a/tests/resources/configs/renderers/config_default_renderer.xml
+++ b/tests/resources/configs/renderers/config_default_renderer.xml
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender" />
-
- <defaultRenderer renderingClass="FruitRenderer3" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender" />
+
+ <defaultRenderer renderingClass="FruitRenderer3" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/renderers/config_invalid_rendering_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_invalid_rendering_class.xml b/tests/resources/configs/renderers/config_invalid_rendering_class.xml
index 51886fe..f722d56 100644
--- a/tests/resources/configs/renderers/config_invalid_rendering_class.xml
+++ b/tests/resources/configs/renderers/config_invalid_rendering_class.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="SimpleLayout"/>
- </appender>
-
- <renderer renderedClass="stdClass" renderingClass="stdClass" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer renderedClass="stdClass" renderingClass="stdClass" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/renderers/config_no_rendered_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_no_rendered_class.xml b/tests/resources/configs/renderers/config_no_rendered_class.xml
index 836815e..209a2ef 100644
--- a/tests/resources/configs/renderers/config_no_rendered_class.xml
+++ b/tests/resources/configs/renderers/config_no_rendered_class.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="SimpleLayout"/>
- </appender>
-
- <renderer renderingClass="DefaultRenderer" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer renderingClass="DefaultRenderer" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/renderers/config_no_rendering_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_no_rendering_class.xml b/tests/resources/configs/renderers/config_no_rendering_class.xml
index 77b14c4..e649b87 100644
--- a/tests/resources/configs/renderers/config_no_rendering_class.xml
+++ b/tests/resources/configs/renderers/config_no_rendering_class.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="SimpleLayout"/>
- </appender>
-
- <renderer />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_not_existing_rendering_class.xml b/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
index 467bd25..0a5502b 100644
--- a/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
+++ b/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="ConsoleAppender">
- <layout class="SimpleLayout"/>
- </appender>
-
- <renderer renderedClass="stdClass" renderingClass="DoesNotExistRenderer" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer renderedClass="stdClass" renderingClass="DoesNotExistRenderer" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/AppenderPoolTest.php
----------------------------------------------------------------------
diff --git a/tests/src/AppenderPoolTest.php b/tests/src/AppenderPoolTest.php
index 86ba9d9..9ad8170 100644
--- a/tests/src/AppenderPoolTest.php
+++ b/tests/src/AppenderPoolTest.php
@@ -29,56 +29,58 @@ use Mockery as m;
/**
* @group filters
*/
-class AppenderPoolTest extends \PHPUnit_Framework_TestCase {
-
- public function setUp() {
- AppenderPool::clear();
- }
-
- public function tearDown() {
- AppenderPool::clear();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Cannot add unnamed appender to pool.
- */
- public function testAppenderHasNoName() {
-
- $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
- ->shouldReceive('getName')->andReturn('')
- ->shouldReceive('close')
- ->mock();
-
- AppenderPool::add($mockAppender);
- }
-
- public function testAppenderIsAdded() {
-
- $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
- ->shouldReceive('getName')->andReturn('foo')
- ->shouldReceive('close')
- ->mock();
-
- AppenderPool::add($mockAppender);
-
- $expected = 1;
- $actual = count(AppenderPool::getAppenders());
- $this->assertEquals($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Appender [foo] already exists in pool. Overwriting existing appender.
- */
- public function testDuplicateAppenderName() {
-
- $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
- ->shouldReceive('getName')->andReturn('foo')
- ->shouldReceive('close')
- ->mock();
-
- AppenderPool::add($mockAppender);
- AppenderPool::add($mockAppender);
- }
+class AppenderPoolTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ AppenderPool::clear();
+ }
+
+ public function tearDown()
+ {
+ AppenderPool::clear();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Cannot add unnamed appender to pool.
+ */
+ public function testAppenderHasNoName()
+ {
+ $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
+ ->shouldReceive('getName')->andReturn('')
+ ->shouldReceive('close')
+ ->mock();
+
+ AppenderPool::add($mockAppender);
+ }
+
+ public function testAppenderIsAdded()
+ {
+ $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
+ ->shouldReceive('getName')->andReturn('foo')
+ ->shouldReceive('close')
+ ->mock();
+
+ AppenderPool::add($mockAppender);
+
+ $expected = 1;
+ $actual = count(AppenderPool::getAppenders());
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Appender [foo] already exists in pool. Overwriting existing appender.
+ */
+ public function testDuplicateAppenderName()
+ {
+ $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
+ ->shouldReceive('getName')->andReturn('foo')
+ ->shouldReceive('close')
+ ->mock();
+
+ AppenderPool::add($mockAppender);
+ AppenderPool::add($mockAppender);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/AppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/AppenderTest.php b/tests/src/AppenderTest.php
index d1fe009..1e60a2a 100644
--- a/tests/src/AppenderTest.php
+++ b/tests/src/AppenderTest.php
@@ -34,148 +34,155 @@ use Apache\Log4php\LoggingEvent;
/**
* @group appenders
*/
-class AppenderTest extends \PHPUnit_Framework_TestCase {
-
- public function testThreshold() {
- $appender = new EchoAppender("LoggerAppenderTest");
-
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
-
- $warn = Level::getLevelWarn();
- $appender->setThreshold($warn);
- $appender->activateOptions();
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelFatal(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "FATAL - testmessage" . PHP_EOL;
- self::assertEquals($e, $v);
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "ERROR - testmessage" . PHP_EOL;
- self::assertEquals($e, $v);
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "WARN - testmessage" . PHP_EOL;
- self::assertEquals($e, $v);
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelInfo(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "";
- self::assertEquals($e, $v);
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "";
- self::assertEquals($e, $v);
+class AppenderTest extends \PHPUnit_Framework_TestCase
+{
+ public function testThreshold()
+ {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+
+ $warn = Level::getLevelWarn();
+ $appender->setThreshold($warn);
+ $appender->activateOptions();
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelFatal(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "FATAL - testmessage" . PHP_EOL;
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "ERROR - testmessage" . PHP_EOL;
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "WARN - testmessage" . PHP_EOL;
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelInfo(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "";
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "";
+ self::assertEquals($e, $v);
}
- public function testGetThreshold() {
- $appender = new EchoAppender("LoggerAppenderTest");
+ public function testGetThreshold()
+ {
+ $appender = new EchoAppender("LoggerAppenderTest");
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
- $warn = Level::getLevelWarn();
- $appender->setThreshold($warn);
+ $warn = Level::getLevelWarn();
+ $appender->setThreshold($warn);
- $a = $appender->getThreshold();
- self::assertEquals($warn, $a);
+ $a = $appender->getThreshold();
+ self::assertEquals($warn, $a);
}
- public function testSetStringThreshold() {
- $appender = new EchoAppender("LoggerAppenderTest");
-
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
-
- $warn = Level::getLevelWarn();
- $appender->setThreshold('WARN');
- $a = $appender->getThreshold();
- self::assertEquals($warn, $a);
-
- $e = Level::getLevelFatal();
- $appender->setThreshold('FATAL');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
-
- $e = Level::getLevelError();
- $appender->setThreshold('ERROR');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
-
- $e = Level::getLevelDebug();
- $appender->setThreshold('DEBUG');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
-
- $e = Level::getLevelInfo();
- $appender->setThreshold('INFO');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
+ public function testSetStringThreshold()
+ {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+
+ $warn = Level::getLevelWarn();
+ $appender->setThreshold('WARN');
+ $a = $appender->getThreshold();
+ self::assertEquals($warn, $a);
+
+ $e = Level::getLevelFatal();
+ $appender->setThreshold('FATAL');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+
+ $e = Level::getLevelError();
+ $appender->setThreshold('ERROR');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+
+ $e = Level::getLevelDebug();
+ $appender->setThreshold('DEBUG');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+
+ $e = Level::getLevelInfo();
+ $appender->setThreshold('INFO');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
}
- public function testSetFilter() {
- $appender = new EchoAppender("LoggerAppenderTest");
+ public function testSetFilter()
+ {
+ $appender = new EchoAppender("LoggerAppenderTest");
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
- $filter = new DenyAllFilter();
- $appender->addFilter($filter);
+ $filter = new DenyAllFilter();
+ $appender->addFilter($filter);
- $filter2 = new LevelMatchFilter();
- $appender->addFilter($filter2);
+ $filter2 = new LevelMatchFilter();
+ $appender->addFilter($filter2);
- $first = $appender->getFilter();
- self::assertEquals($first, $filter);
+ $first = $appender->getFilter();
+ self::assertEquals($first, $filter);
- $next = $first->getNext();
- self::assertEquals($next, $filter2);
+ $next = $first->getNext();
+ self::assertEquals($next, $filter2);
- $appender->clearFilters();
- $nullfilter = $appender->getFilter();
- self::assertNull($nullfilter);
+ $appender->clearFilters();
+ $nullfilter = $appender->getFilter();
+ self::assertNull($nullfilter);
}
- public function testInstanciateWithLayout() {
- $appender = new EchoAppender("LoggerAppenderTest");
+ public function testInstanciateWithLayout()
+ {
+ $appender = new EchoAppender("LoggerAppenderTest");
- $expected = "Apache\\Log4php\\Layouts\\SimpleLayout";
- $actual = $appender->getLayout();
- $this->assertInstanceof($expected, $actual);
+ $expected = "Apache\\Log4php\\Layouts\\SimpleLayout";
+ $actual = $appender->getLayout();
+ $this->assertInstanceof($expected, $actual);
}
- public function testOverwriteLayout() {
- $layout = new SimpleLayout();
- $appender = new EchoAppender("LoggerAppenderTest");
- $appender->setLayout($layout);
+ public function testOverwriteLayout()
+ {
+ $layout = new SimpleLayout();
+ $appender = new EchoAppender("LoggerAppenderTest");
+ $appender->setLayout($layout);
- $actual = $appender->getLayout();
- $this->assertEquals($layout, $actual);
+ $actual = $appender->getLayout();
+ $this->assertEquals($layout, $actual);
}
- public function testRequiresNoLayout() {
- $appender = new NullAppender("LoggerAppenderTest");
+ public function testRequiresNoLayout()
+ {
+ $appender = new NullAppender("LoggerAppenderTest");
- $actual = $appender->getLayout();
- $this->assertNull($actual);
+ $actual = $appender->getLayout();
+ $this->assertNull($actual);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/ConsoleAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/ConsoleAppenderTest.php b/tests/src/Appenders/ConsoleAppenderTest.php
index a99a407..39c75b0 100644
--- a/tests/src/Appenders/ConsoleAppenderTest.php
+++ b/tests/src/Appenders/ConsoleAppenderTest.php
@@ -28,64 +28,68 @@ use Apache\Log4php\Appenders\ConsoleAppender;
/**
* @group appenders
*/
-class ConsoleAppenderTest extends \PHPUnit_Framework_TestCase {
+class ConsoleAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ private $config = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'ConsoleAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ // Intentionally blank so output doesn't clutter phpunit output
+ 'conversionPattern' => ''
+ )
+ ),
+ )
+ )
+ );
- private $config = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'ConsoleAppender',
- 'layout' => array(
- 'class' => 'PatternLayout',
- 'params' => array(
- // Intentionally blank so output doesn't clutter phpunit output
- 'conversionPattern' => ''
- )
- ),
- )
- )
- );
-
- public function testRequiresLayout() {
- $appender = new ConsoleAppender();
- self::assertTrue($appender->requiresLayout());
- }
+ public function testRequiresLayout()
+ {
+ $appender = new ConsoleAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
- public function testAppendDefault() {
- Logger::configure($this->config);
- $log = Logger::getRootLogger();
+ public function testAppendDefault()
+ {
+ Logger::configure($this->config);
+ $log = Logger::getRootLogger();
- $expected = ConsoleAppender::STDOUT;
- $actual = $log->getAppender('default')->getTarget();
- $this->assertSame($expected, $actual);
+ $expected = ConsoleAppender::STDOUT;
+ $actual = $log->getAppender('default')->getTarget();
+ $this->assertSame($expected, $actual);
- $log->info("hello");
+ $log->info("hello");
}
- public function testAppendStdout() {
- $this->config['appenders']['default']['params']['target'] = 'stdout';
+ public function testAppendStdout()
+ {
+ $this->config['appenders']['default']['params']['target'] = 'stdout';
- Logger::configure($this->config);
- $log = Logger::getRootLogger();
+ Logger::configure($this->config);
+ $log = Logger::getRootLogger();
- $expected = ConsoleAppender::STDOUT;
- $actual = $log->getAppender('default')->getTarget();
- $this->assertSame($expected, $actual);
+ $expected = ConsoleAppender::STDOUT;
+ $actual = $log->getAppender('default')->getTarget();
+ $this->assertSame($expected, $actual);
- $log->info("hello");
+ $log->info("hello");
}
- public function testAppendStderr() {
- $this->config['appenders']['default']['params']['target'] = 'stderr';
- Logger::configure($this->config);
- $log = Logger::getRootLogger();
- $expected = ConsoleAppender::STDERR;
+ public function testAppendStderr()
+ {
+ $this->config['appenders']['default']['params']['target'] = 'stderr';
+ Logger::configure($this->config);
+ $log = Logger::getRootLogger();
+ $expected = ConsoleAppender::STDERR;
- $actual = $log->getAppender('default')->getTarget();
- $this->assertSame($expected, $actual);
+ $actual = $log->getAppender('default')->getTarget();
+ $this->assertSame($expected, $actual);
- $log->info("hello");
+ $log->info("hello");
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/DailyFileAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/DailyFileAppenderTest.php b/tests/src/Appenders/DailyFileAppenderTest.php
index e5f3acf..a9ad0cf 100644
--- a/tests/src/Appenders/DailyFileAppenderTest.php
+++ b/tests/src/Appenders/DailyFileAppenderTest.php
@@ -30,165 +30,175 @@ use Apache\Log4php\Tests\TestHelper;
/**
* @group appenders
*/
-class DailyFileAppenderTest extends \PHPUnit_Framework_TestCase {
-
- protected function setUp() {
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Ymd'));
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Y'));
- }
-
- public function testRequiresLayout() {
- $appender = new DailyFileAppender();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testDefaultLayout() {
- $appender = new DailyFileAppender();
- $actual = $appender->getLayout();
- self::assertInstanceOf('Apache\\Log4php\\Layouts\\SimpleLayout', $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'file' not set.
- */
- public function testRequiredParamWarning1() {
- $appender = new DailyFileAppender();
- $appender->activateOptions();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'datePattern' not set.
- */
- public function testRequiredParamWarning2() {
- $appender = new DailyFileAppender();
- $appender->setFile('file.log');
- $appender->setDatePattern('');
- $appender->activateOptions();
- }
-
- public function testGetDatePattern() {
- $appender = new DailyFileAppender();
-
- // Default pattern
- $actual = $appender->getDatePattern();
- self::assertEquals('Ymd', $actual);
-
- // Custom pattern
- $appender->setDatePattern('xyz');
- $actual = $appender->getDatePattern();
- self::assertEquals('xyz', $actual);
- }
-
- /**
- * For greater code coverage!
- * Override the warning so remaining code is reached.
- */
- public function testRequiredParamWarning3() {
- $appender = new DailyFileAppender();
- $appender->setFile('file.log');
- $appender->setDatePattern('');
- @$appender->activateOptions();
- }
-
- public function testLazyFileOpen() {
- $event = TestHelper::getWarnEvent("my message");
- $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
- $pattern = 'Y-m-d';
-
- $date = date($pattern, $event->getTimeStamp());
- $path = PHPUNIT_TEMP_DIR . "/lazy-file.$date.log";
-
- if (file_exists($path)) {
- unlink($path);
- }
-
- $appender = new DailyFileAppender();
- $appender->setFile($file);
- $appender->setDatePattern('Y-m-d');
- $appender->activateOptions();
-
- // File should not exist before first append
- self::assertFileNotExists($path);
- $appender->append($event);
- self::assertFileExists($path);
- }
-
- public function testRollover()
- {
- $message = uniqid();
- $level = Level::getLevelDebug();
-
- $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
- $pattern = 'Y-m-d';
-
- // Get some timestamps for events - different date for each
- $ts1 = mktime(10, 0, 0, 7, 3, 1980);
- $ts2 = mktime(10, 0, 0, 7, 4, 1980);
- $ts3 = mktime(10, 0, 0, 7, 5, 1980);
-
- $e1 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts1);
- $e2 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts2);
- $e3 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts3);
-
- // Expected paths
- $path1 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-03.log';
- $path2 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-04.log';
- $path3 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-05.log';
-
- @unlink($path1);
- @unlink($path2);
- @unlink($path3);
-
- $appender = new DailyFileAppender();
- $appender->setFile($file);
- $appender->setDatePattern('Y-m-d');
- $appender->activateOptions();
-
- $appender->append($e1);
- $appender->append($e2);
- $appender->append($e3);
-
- $actual1 = file_get_contents($path1);
- $actual2 = file_get_contents($path2);
- $actual3 = file_get_contents($path3);
-
- $expected1 = "DEBUG - $message" . PHP_EOL;
- $expected2 = "DEBUG - $message" . PHP_EOL;
- $expected3 = "DEBUG - $message" . PHP_EOL;
-
- self::assertSame($expected1, $actual1);
- self::assertSame($expected2, $actual2);
- self::assertSame($expected3, $actual3);
- }
-
- public function testSimpleLogging() {
- $event = TestHelper::getWarnEvent("my message");
-
- $appender = new DailyFileAppender();
- $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Ymd"));
- $expected = "WARN - my message".PHP_EOL;
- self::assertEquals($expected, $actual);
- }
-
- public function testChangedDateFormat() {
- $event = TestHelper::getWarnEvent("my message");
-
- $appender = new DailyFileAppender();
- $appender->setDatePattern('Y');
- $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Y"));
- $expected = "WARN - my message".PHP_EOL;
- self::assertEquals($expected, $actual);
- }
+class DailyFileAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ protected function setUp()
+ {
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Ymd'));
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Y'));
+ }
+
+ public function testRequiresLayout()
+ {
+ $appender = new DailyFileAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testDefaultLayout()
+ {
+ $appender = new DailyFileAppender();
+ $actual = $appender->getLayout();
+ self::assertInstanceOf('Apache\\Log4php\\Layouts\\SimpleLayout', $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'file' not set.
+ */
+ public function testRequiredParamWarning1()
+ {
+ $appender = new DailyFileAppender();
+ $appender->activateOptions();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'datePattern' not set.
+ */
+ public function testRequiredParamWarning2()
+ {
+ $appender = new DailyFileAppender();
+ $appender->setFile('file.log');
+ $appender->setDatePattern('');
+ $appender->activateOptions();
+ }
+
+ public function testGetDatePattern()
+ {
+ $appender = new DailyFileAppender();
+
+ // Default pattern
+ $actual = $appender->getDatePattern();
+ self::assertEquals('Ymd', $actual);
+
+ // Custom pattern
+ $appender->setDatePattern('xyz');
+ $actual = $appender->getDatePattern();
+ self::assertEquals('xyz', $actual);
+ }
+
+ /**
+ * For greater code coverage!
+ * Override the warning so remaining code is reached.
+ */
+ public function testRequiredParamWarning3()
+ {
+ $appender = new DailyFileAppender();
+ $appender->setFile('file.log');
+ $appender->setDatePattern('');
+ @$appender->activateOptions();
+ }
+
+ public function testLazyFileOpen()
+ {
+ $event = TestHelper::getWarnEvent("my message");
+ $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
+ $pattern = 'Y-m-d';
+
+ $date = date($pattern, $event->getTimeStamp());
+ $path = PHPUNIT_TEMP_DIR . "/lazy-file.$date.log";
+
+ if (file_exists($path)) {
+ unlink($path);
+ }
+
+ $appender = new DailyFileAppender();
+ $appender->setFile($file);
+ $appender->setDatePattern('Y-m-d');
+ $appender->activateOptions();
+
+ // File should not exist before first append
+ self::assertFileNotExists($path);
+ $appender->append($event);
+ self::assertFileExists($path);
+ }
+
+ public function testRollover()
+ {
+ $message = uniqid();
+ $level = Level::getLevelDebug();
+
+ $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
+ $pattern = 'Y-m-d';
+
+ // Get some timestamps for events - different date for each
+ $ts1 = mktime(10, 0, 0, 7, 3, 1980);
+ $ts2 = mktime(10, 0, 0, 7, 4, 1980);
+ $ts3 = mktime(10, 0, 0, 7, 5, 1980);
+
+ $e1 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts1);
+ $e2 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts2);
+ $e3 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts3);
+
+ // Expected paths
+ $path1 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-03.log';
+ $path2 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-04.log';
+ $path3 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-05.log';
+
+ @unlink($path1);
+ @unlink($path2);
+ @unlink($path3);
+
+ $appender = new DailyFileAppender();
+ $appender->setFile($file);
+ $appender->setDatePattern('Y-m-d');
+ $appender->activateOptions();
+
+ $appender->append($e1);
+ $appender->append($e2);
+ $appender->append($e3);
+
+ $actual1 = file_get_contents($path1);
+ $actual2 = file_get_contents($path2);
+ $actual3 = file_get_contents($path3);
+
+ $expected1 = "DEBUG - $message" . PHP_EOL;
+ $expected2 = "DEBUG - $message" . PHP_EOL;
+ $expected3 = "DEBUG - $message" . PHP_EOL;
+
+ self::assertSame($expected1, $actual1);
+ self::assertSame($expected2, $actual2);
+ self::assertSame($expected3, $actual3);
+ }
+
+ public function testSimpleLogging()
+ {
+ $event = TestHelper::getWarnEvent("my message");
+
+ $appender = new DailyFileAppender();
+ $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Ymd"));
+ $expected = "WARN - my message".PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testChangedDateFormat()
+ {
+ $event = TestHelper::getWarnEvent("my message");
+
+ $appender = new DailyFileAppender();
+ $appender->setDatePattern('Y');
+ $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Y"));
+ $expected = "WARN - my message".PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/EchoAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/EchoAppenderTest.php b/tests/src/Appenders/EchoAppenderTest.php
index 57f2c12..a2daf1f 100644
--- a/tests/src/Appenders/EchoAppenderTest.php
+++ b/tests/src/Appenders/EchoAppenderTest.php
@@ -31,140 +31,144 @@ use Apache\Log4php\LoggingEvent;
/**
* @group appenders
*/
-class EchoAppenderTest extends \PHPUnit_Framework_TestCase {
-
- private $config1 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- ),
- )
- )
- );
-
- private $config2 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- ),
- 'params' => array(
- 'htmlLineBreaks' => true
- )
- )
- )
- );
-
- private $config3 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- ),
- 'params' => array(
- 'htmlLineBreaks' => 'foo'
- )
- )
- )
- );
-
- public function testAppend() {
- Logger::configure($this->config1);
- $log = Logger::getRootLogger();
-
- $hlb = $log->getAppender('default')->getHtmlLineBreaks();
- $this->assertSame(false, $hlb);
-
- ob_start();
- $log->info("This is a test");
- $log->debug("And this too");
- $actual = ob_get_clean();
- $expected = "INFO - This is a test" . PHP_EOL . "DEBUG - And this too". PHP_EOL;
-
- $this->assertSame($expected, $actual);
- }
-
- public function testHtmlLineBreaks() {
- Logger::configure($this->config2);
- $log = Logger::getRootLogger();
-
- $hlb = $log->getAppender('default')->getHtmlLineBreaks();
- $this->assertSame(true, $hlb);
-
- ob_start();
- $log->info("This is a test" . PHP_EOL . "With more than one line");
- $log->debug("And this too");
- $actual = ob_get_clean();
- $expected = "INFO - This is a test<br />" . PHP_EOL . "With more than one line<br />" . PHP_EOL . "DEBUG - And this too<br />" . PHP_EOL;
-
- $this->assertSame($expected, $actual);
- }
+class EchoAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ private $config1 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ )
+ )
+ );
+
+ private $config2 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array(
+ 'htmlLineBreaks' => true
+ )
+ )
+ )
+ );
+
+ private $config3 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array(
+ 'htmlLineBreaks' => 'foo'
+ )
+ )
+ )
+ );
+
+ public function testAppend()
+ {
+ Logger::configure($this->config1);
+ $log = Logger::getRootLogger();
+
+ $hlb = $log->getAppender('default')->getHtmlLineBreaks();
+ $this->assertSame(false, $hlb);
+
+ ob_start();
+ $log->info("This is a test");
+ $log->debug("And this too");
+ $actual = ob_get_clean();
+ $expected = "INFO - This is a test" . PHP_EOL . "DEBUG - And this too". PHP_EOL;
+
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testHtmlLineBreaks()
+ {
+ Logger::configure($this->config2);
+ $log = Logger::getRootLogger();
+
+ $hlb = $log->getAppender('default')->getHtmlLineBreaks();
+ $this->assertSame(true, $hlb);
+
+ ob_start();
+ $log->info("This is a test" . PHP_EOL . "With more than one line");
+ $log->debug("And this too");
+ $actual = ob_get_clean();
+ $expected = "INFO - This is a test<br />" . PHP_EOL . "With more than one line<br />" . PHP_EOL . "DEBUG - And this too<br />" . PHP_EOL;
+
+ $this->assertSame($expected, $actual);
+ }
// public function testHtmlLineBreaksInvalidOption() {
// Logger::configure($this->config3);
// }
-
- public function testEcho() {
- $appender = new EchoAppender("myname ");
-
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
- $appender->activateOptions();
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
-
- $expected = "ERROR - testmessage" . PHP_EOL;
- ob_start();
- $appender->append($event);
- $actual = ob_get_clean();
-
- self::assertEquals($expected, $actual);
- }
-
- public function testRequiresLayout() {
- $appender = new EchoAppender();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testEchoHtml() {
- $appender = new EchoAppender("myname ");
- $appender->setHtmlLineBreaks(true);
-
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
- $appender->activateOptions();
-
- // Single line message
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
-
- $expected = "ERROR - testmessage<br />" . PHP_EOL;
- ob_start();
- $appender->append($event);
- $actual = ob_get_clean();
- self::assertEquals($expected, $actual);
-
- // Multi-line message
- $msg = "This message\nis in several lines\r\nto test various line breaks.";
- $expected = "ERROR - This message<br />\nis in several lines<br />\r\nto test various line breaks.<br />" . PHP_EOL;
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), $msg);
- ob_start();
- $appender->append($event);
- $actual = ob_get_clean();
- self::assertEquals($expected, $actual);
- }
+ public function testEcho()
+ {
+ $appender = new EchoAppender("myname ");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->activateOptions();
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $expected = "ERROR - testmessage" . PHP_EOL;
+ ob_start();
+ $appender->append($event);
+ $actual = ob_get_clean();
+
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testRequiresLayout()
+ {
+ $appender = new EchoAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testEchoHtml()
+ {
+ $appender = new EchoAppender("myname ");
+ $appender->setHtmlLineBreaks(true);
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->activateOptions();
+
+ // Single line message
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $expected = "ERROR - testmessage<br />" . PHP_EOL;
+ ob_start();
+ $appender->append($event);
+ $actual = ob_get_clean();
+ self::assertEquals($expected, $actual);
+
+ // Multi-line message
+ $msg = "This message\nis in several lines\r\nto test various line breaks.";
+ $expected = "ERROR - This message<br />\nis in several lines<br />\r\nto test various line breaks.<br />" . PHP_EOL;
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), $msg);
+ ob_start();
+ $appender->append($event);
+ $actual = ob_get_clean();
+ self::assertEquals($expected, $actual);
+ }
}
[38/43] git commit: Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
Fixed code formatting to conform to PSR-2
Used the PHP Coding Standards Fixer by Sensio Labs
(http://cs.sensiolabs.org/).
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/35dfd5d3
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/35dfd5d3
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/35dfd5d3
Branch: refs/heads/v3
Commit: 35dfd5d3a0b292ae3ae0872436a1e3989212cb12
Parents: 79ed2d0
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 14:23:41 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 14:23:41 2013 +0100
----------------------------------------------------------------------
src/AppenderPool.php | 121 +-
src/Appenders/AbstractAppender.php | 536 ++++----
src/Appenders/ConsoleAppender.php | 118 +-
src/Appenders/DailyFileAppender.php | 181 +--
src/Appenders/EchoAppender.php | 95 +-
src/Appenders/FileAppender.php | 393 +++---
src/Appenders/MailAppender.php | 195 +--
src/Appenders/MailEventAppender.php | 289 ++---
src/Appenders/MongoDBAppender.php | 656 +++++-----
src/Appenders/NullAppender.php | 27 +-
src/Appenders/PdoAppender.php | 499 ++++----
src/Appenders/PhpAppender.php | 25 +-
src/Appenders/RollingFileAppender.php | 538 ++++----
src/Appenders/SocketAppender.php | 181 +--
src/Appenders/SyslogAppender.php | 480 ++++----
src/Autoloader.php | 44 +-
src/Configurable.php | 166 +--
src/Configuration/ConfiguratorInterface.php | 24 +-
src/Configuration/DefaultConfigurator.php | 944 +++++++-------
src/Configuration/adapters/AdapterInterface.php | 4 +-
src/Configuration/adapters/IniAdapter.php | 535 ++++----
src/Configuration/adapters/PhpAdapter.php | 48 +-
src/Configuration/adapters/XmlAdapter.php | 509 ++++----
src/Filters/AbstractFilter.php | 128 +-
src/Filters/DenyAllFilter.php | 25 +-
src/Filters/LevelMatchFilter.php | 97 +-
src/Filters/LevelRangeFilter.php | 132 +-
src/Filters/StringMatchFilter.php | 72 +-
src/Helpers/FormattingInfo.php | 44 +-
src/Helpers/OptionConverter.php | 403 +++---
src/Helpers/PatternParser.php | 430 +++----
src/Helpers/Utils.php | 191 +--
src/Hierarchy.php | 374 +++---
src/Layouts/AbstractLayout.php | 91 +-
src/Layouts/HtmlLayout.php | 340 ++---
src/Layouts/PatternLayout.php | 276 +++--
src/Layouts/SerializedLayout.php | 40 +-
src/Layouts/SimpleLayout.php | 33 +-
src/Layouts/XmlLayout.php | 317 ++---
src/Level.php | 468 +++----
src/LocationInfo.php | 132 +-
src/Logger.php | 1159 +++++++++---------
src/LoggerException.php | 3 +-
src/LoggingEvent.php | 703 ++++++-----
src/MDC.php | 99 +-
src/NDC.php | 206 ++--
src/Pattern/AbstractConverter.php | 198 +--
src/Pattern/ClassConverter.php | 54 +-
src/Pattern/CookieConverter.php | 7 +-
src/Pattern/DateConverter.php | 93 +-
src/Pattern/EnvironmentConverter.php | 5 +-
src/Pattern/FileConverter.php | 11 +-
src/Pattern/LevelConverter.php | 11 +-
src/Pattern/LineConverter.php | 11 +-
src/Pattern/LiteralConverter.php | 20 +-
src/Pattern/LocationConverter.php | 19 +-
src/Pattern/LoggerConverter.php | 54 +-
src/Pattern/MdcConverter.php | 41 +-
src/Pattern/MessageConverter.php | 11 +-
src/Pattern/MethodConverter.php | 11 +-
src/Pattern/NdcConverter.php | 11 +-
src/Pattern/NewLineConverter.php | 11 +-
src/Pattern/ProcessConverter.php | 11 +-
src/Pattern/RelativeConverter.php | 12 +-
src/Pattern/RequestConverter.php | 9 +-
src/Pattern/ServerConverter.php | 7 +-
src/Pattern/SessionConverter.php | 7 +-
src/Pattern/SessionIdConverter.php | 10 +-
src/Pattern/SuperglobalConverter.php | 111 +-
src/Pattern/ThrowableConverter.php | 21 +-
src/ReflectionUtils.php | 241 ++--
src/Renderers/DefaultRenderer.php | 13 +-
src/Renderers/ExceptionRenderer.php | 16 +-
src/Renderers/RendererInterface.php | 15 +-
src/Renderers/RendererMap.php | 339 ++---
src/RootLogger.php | 80 +-
src/ThrowableInformation.php | 69 +-
tests/bootstrap.php | 2 +-
.../configs/adapters/php/config_empty.php | 50 +-
.../adapters/php/config_invalid_syntax.php | 78 +-
.../adapters/php/config_not_an_array.php | 52 +-
.../configs/adapters/php/config_valid.php | 78 +-
.../adapters/xml/config_duplicate_logger.xml | 78 +-
.../adapters/xml/config_duplicate_renderer.xml | 60 +-
.../adapters/xml/config_invalid_syntax.xml | 78 +-
.../configs/adapters/xml/config_valid.xml | 108 +-
.../adapters/xml/config_valid_underscore.xml | 114 +-
.../appenders/config_invalid_appender_class.xml | 50 +-
.../appenders/config_invalid_filter_class.xml | 54 +-
.../config_invalid_filter_parameters.xml | 58 +-
.../appenders/config_invalid_layout_class.xml | 54 +-
.../configs/appenders/config_no_class.xml | 52 +-
.../appenders/config_no_layout_class.xml | 54 +-
.../appenders/config_not_existing_class.xml | 50 +-
.../config_not_existing_filter_class.xml | 54 +-
.../config_not_existing_layout_class.xml | 54 +-
tests/resources/configs/config.yml | 28 +-
tests/resources/configs/config1.xml | 108 +-
.../loggers/config_invalid_additivity.xml | 60 +-
.../loggers/config_not_existing_appenders.xml | 46 +-
.../renderers/config_default_renderer.xml | 54 +-
.../config_invalid_rendering_class.xml | 58 +-
.../renderers/config_no_rendered_class.xml | 58 +-
.../renderers/config_no_rendering_class.xml | 58 +-
.../config_not_existing_rendering_class.xml | 58 +-
tests/src/AppenderPoolTest.php | 106 +-
tests/src/AppenderTest.php | 245 ++--
tests/src/Appenders/ConsoleAppenderTest.php | 96 +-
tests/src/Appenders/DailyFileAppenderTest.php | 332 ++---
tests/src/Appenders/EchoAppenderTest.php | 264 ++--
tests/src/Appenders/FileAppenderTest.php | 220 ++--
tests/src/Appenders/MailAppenderTest.php | 50 +-
tests/src/Appenders/MailEventAppenderTest.php | 94 +-
tests/src/Appenders/MongoDBAppenderTest.php | 362 +++---
tests/src/Appenders/NullAppenderTest.php | 31 +-
tests/src/Appenders/PDOAppenderTest.php | 275 +++--
tests/src/Appenders/PhpAppenderTest.php | 117 +-
tests/src/Appenders/RollingFileAppenderTest.php | 268 ++--
tests/src/Appenders/SocketAppenderTest.php | 248 ++--
tests/src/Appenders/SyslogAppenderTest.php | 432 +++----
tests/src/Appenders/socketServer.php | 75 +-
tests/src/ConfiguratorTest.php | 799 ++++++------
tests/src/Configurators/INIAdapterTest.php | 290 ++---
tests/src/Configurators/PHPAdapterTest.php | 129 +-
tests/src/Configurators/XMLAdapterTest.php | 295 ++---
tests/src/ExceptionTest.php | 26 +-
tests/src/FilterTest.php | 37 +-
tests/src/Filters/FilterDenyAllTest.php | 70 +-
tests/src/Filters/FilterLevelMatchTest.php | 308 ++---
tests/src/Filters/FilterLevelRangeTest.php | 62 +-
tests/src/Filters/FilterStringMatchTest.php | 172 +--
tests/src/Helpers/OptionConverterTest.php | 85 +-
tests/src/Helpers/PatternParserTest.php | 10 +-
tests/src/Helpers/UtilsTest.php | 86 +-
tests/src/HierarchyTest.php | 149 +--
tests/src/Layouts/HtmlLayoutTest.php | 66 +-
tests/src/Layouts/PatternLayoutTest.php | 48 +-
tests/src/Layouts/SerializedLayoutTest.php | 142 +--
tests/src/Layouts/SimpleLayoutTest.php | 19 +-
tests/src/Layouts/XmlLayoutTest.php | 175 +--
tests/src/LevelTest.php | 91 +-
tests/src/LoggerTest.php | 400 +++---
tests/src/LoggingEventTest.php | 201 +--
tests/src/MDCTest.php | 156 +--
tests/src/NDCTest.php | 124 +-
tests/src/Pattern/PatternConverterTest.php | 738 +++++------
tests/src/ReflectionUtilsTest.php | 85 +-
tests/src/Renderers/RendererMapTest.php | 406 +++---
tests/src/RootLoggerTest.php | 68 +-
tests/src/TestHelper.php | 265 ++--
tests/src/ThrowableInformationTest.php | 55 +-
151 files changed, 12561 insertions(+), 11817 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/AppenderPool.php
----------------------------------------------------------------------
diff --git a/src/AppenderPool.php b/src/AppenderPool.php
index ca57179..92f9455 100644
--- a/src/AppenderPool.php
+++ b/src/AppenderPool.php
@@ -28,70 +28,77 @@ use Apache\Log4php\Appenders\AbstractAppender;
* appender can be linked to multiple loggers. This makes sure duplicate
* appenders are not created.
*/
-class AppenderPool {
+class AppenderPool
+{
+ /** Holds appenders indexed by their name */
+ public static $appenders = array();
- /** Holds appenders indexed by their name */
- public static $appenders = array();
+ /**
+ * Adds an appender to the pool.
+ * The appender must be named for this operation.
+ * @param Appender $appender
+ */
+ public static function add(AbstractAppender $appender)
+ {
+ $name = $appender->getName();
- /**
- * Adds an appender to the pool.
- * The appender must be named for this operation.
- * @param Appender $appender
- */
- public static function add(AbstractAppender $appender) {
- $name = $appender->getName();
+ if (empty($name)) {
+ trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING);
- if(empty($name)) {
- trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING);
- return;
- }
+ return;
+ }
- if (isset(self::$appenders[$name])) {
- trigger_error("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
- }
+ if (isset(self::$appenders[$name])) {
+ trigger_error("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
+ }
- self::$appenders[$name] = $appender;
- }
+ self::$appenders[$name] = $appender;
+ }
- /**
- * Retrieves an appender from the pool by name.
- * @param string $name Name of the appender to retrieve.
- * @return Appender The named appender or NULL if no such appender
- * exists in the pool.
- */
- public static function get($name) {
- return isset(self::$appenders[$name]) ? self::$appenders[$name] : null;
- }
+ /**
+ * Retrieves an appender from the pool by name.
+ * @param string $name Name of the appender to retrieve.
+ * @return Appender The named appender or NULL if no such appender
+ * exists in the pool.
+ */
+ public static function get($name)
+ {
+ return isset(self::$appenders[$name]) ? self::$appenders[$name] : null;
+ }
- /**
- * Removes an appender from the pool by name.
- * @param string $name Name of the appender to remove.
- */
- public static function delete($name) {
- unset(self::$appenders[$name]);
- }
+ /**
+ * Removes an appender from the pool by name.
+ * @param string $name Name of the appender to remove.
+ */
+ public static function delete($name)
+ {
+ unset(self::$appenders[$name]);
+ }
- /**
- * Returns all appenders from the pool.
- * @return array Array of Appender objects.
- */
- public static function getAppenders() {
- return self::$appenders;
- }
+ /**
+ * Returns all appenders from the pool.
+ * @return array Array of Appender objects.
+ */
+ public static function getAppenders()
+ {
+ return self::$appenders;
+ }
- /**
- * Checks whether an appender exists in the pool.
- * @param string $name Name of the appender to look for.
- * @return boolean TRUE if the appender with the given name exists.
- */
- public static function exists($name) {
- return isset(self::$appenders[$name]);
- }
+ /**
+ * Checks whether an appender exists in the pool.
+ * @param string $name Name of the appender to look for.
+ * @return boolean TRUE if the appender with the given name exists.
+ */
+ public static function exists($name)
+ {
+ return isset(self::$appenders[$name]);
+ }
- /**
- * Clears all appenders from the pool.
- */
- public static function clear() {
- self::$appenders = array();
- }
-}
\ No newline at end of file
+ /**
+ * Clears all appenders from the pool.
+ */
+ public static function clear()
+ {
+ self::$appenders = array();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/AbstractAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/AbstractAppender.php b/src/Appenders/AbstractAppender.php
index 9ac29e1..52ffe07 100644
--- a/src/Appenders/AbstractAppender.php
+++ b/src/Appenders/AbstractAppender.php
@@ -26,263 +26,283 @@ use Apache\Log4php\LoggingEvent;
/**
* Abstract class that defines output logs strategies.
*/
-abstract class AbstractAppender extends Configurable {
-
- /**
- * Set to true when the appender is closed. A closed appender will not
- * accept any logging requests.
- * @var boolean
- */
- protected $closed = false;
-
- /**
- * The first filter in the filter chain.
- * @var AbstractFilter
- */
- protected $filter;
-
- /**
- * The appender's layout. Can be null if the appender does not use
- * a layout.
- * @var Layout
- */
- protected $layout;
-
- /**
- * Appender name. Used by other components to identify this appender.
- * @var string
- */
- protected $name;
-
- /**
- * Appender threshold level. Events whose level is below the threshold
- * will not be logged.
- * @var Level
- */
- protected $threshold;
-
- /**
- * Set to true if the appender requires a layout.
- *
- * True by default, appenders which do not use a layout should override
- * this property to false.
- *
- * @var boolean
- */
- protected $requiresLayout = true;
-
- /**
- * Default constructor.
- * @param string $name Appender name
- */
- public function __construct($name = '') {
- $this->name = $name;
-
- if ($this->requiresLayout) {
- $this->layout = $this->getDefaultLayout();
- }
- }
-
- public function __destruct() {
- $this->close();
- }
-
- /**
- * Returns the default layout for this appender. Can be overriden by
- * derived appenders.
- *
- * @return Layout
- */
- public function getDefaultLayout() {
- return new SimpleLayout();
- }
-
- /**
- * Adds a filter to the end of the filter chain.
- * @param AbstractFilter $filter add a new AbstractFilter
- */
- public function addFilter($filter) {
- if($this->filter === null) {
- $this->filter = $filter;
- } else {
- $this->filter->addNext($filter);
- }
- }
-
- /**
- * Clears the filter chain by removing all the filters in it.
- */
- public function clearFilters() {
- $this->filter = null;
- }
-
- /**
- * Returns the first filter in the filter chain.
- * The return value may be <i>null</i> if no is filter is set.
- * @return AbstractFilter
- */
- public function getFilter() {
- return $this->filter;
- }
-
- /**
- * Returns the first filter in the filter chain.
- * The return value may be <i>null</i> if no is filter is set.
- * @return AbstractFilter
- */
- public function getFirstFilter() {
- return $this->filter;
- }
-
- /**
- * Performs threshold checks and invokes filters before delegating logging
- * to the subclass' specific <i>append()</i> method.
- * @see Appender::append()
- * @param LoggingEvent $event
- */
- public function doAppend(LoggingEvent $event) {
- if($this->closed) {
- return;
- }
-
- if(!$this->isAsSevereAsThreshold($event->getLevel())) {
- return;
- }
-
- $filter = $this->getFirstFilter();
- while($filter !== null) {
- switch ($filter->decide($event)) {
- case AbstractFilter::DENY: return;
- case AbstractFilter::ACCEPT: return $this->append($event);
- case AbstractFilter::NEUTRAL: $filter = $filter->getNext();
- }
- }
- $this->append($event);
- }
-
- /**
- * Sets the appender layout.
- * @param Layout $layout
- */
- public function setLayout($layout) {
- if($this->requiresLayout()) {
- $this->layout = $layout;
- }
- }
-
- /**
- * Returns the appender layout.
- * @return Layout
- */
- public function getLayout() {
- return $this->layout;
- }
-
- /**
- * Configurators call this method to determine if the appender
- * requires a layout.
- *
- * <p>If this method returns <i>true</i>, meaning that layout is required,
- * then the configurator will configure a layout using the configuration
- * information at its disposal. If this method returns <i>false</i>,
- * meaning that a layout is not required, then layout configuration will be
- * skipped even if there is available layout configuration
- * information at the disposal of the configurator.</p>
- *
- * <p>In the rather exceptional case, where the appender
- * implementation admits a layout but can also work without it, then
- * the appender should return <i>true</i>.</p>
- *
- * @return boolean
- */
- public function requiresLayout() {
- return $this->requiresLayout;
- }
-
- /**
- * Retruns the appender name.
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Sets the appender name.
- * @param string $name
- */
- public function setName($name) {
- $this->name = $name;
- }
-
- /**
- * Returns the appender's threshold level.
- * @return Level
- */
- public function getThreshold() {
- return $this->threshold;
- }
-
- /**
- * Sets the appender threshold.
- *
- * @param Level|string $threshold Either a {@link Level}
- * object or a string equivalent.
- * @see OptionConverter::toLevel()
- */
- public function setThreshold($threshold) {
- $this->setLevel('threshold', $threshold);
- }
-
- /**
- * Checks whether the message level is below the appender's threshold.
- *
- * If there is no threshold set, then the return value is always <i>true</i>.
- *
- * @param Level $level
- * @return boolean Returns true if level is greater or equal than
- * threshold, or if the threshold is not set. Otherwise returns false.
- */
- public function isAsSevereAsThreshold($level) {
- if($this->threshold === null) {
- return true;
- }
- return $level->isGreaterOrEqual($this->getThreshold());
- }
-
- /**
- * Prepares the appender for logging.
- *
- * Derived appenders should override this method if option structure
- * requires it.
- */
- public function activateOptions() {
- $this->closed = false;
- }
-
- /**
- * Forwards the logging event to the destination.
- *
- * Derived appenders should implement this method to perform actual logging.
- *
- * @param LoggingEvent $event
- */
- abstract protected function append(LoggingEvent $event);
-
- /**
- * Releases any resources allocated by the appender.
- *
- * Derived appenders should override this method to perform proper closing
- * procedures.
- */
- public function close() {
- $this->closed = true;
- }
-
- /** Triggers a warning for this logger with the given message. */
- protected function warn($message) {
- $id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
- trigger_error("log4php: [$id]: $message", E_USER_WARNING);
- }
+abstract class AbstractAppender extends Configurable
+{
+ /**
+ * Set to true when the appender is closed. A closed appender will not
+ * accept any logging requests.
+ * @var boolean
+ */
+ protected $closed = false;
+
+ /**
+ * The first filter in the filter chain.
+ * @var AbstractFilter
+ */
+ protected $filter;
+
+ /**
+ * The appender's layout. Can be null if the appender does not use
+ * a layout.
+ * @var Layout
+ */
+ protected $layout;
+
+ /**
+ * Appender name. Used by other components to identify this appender.
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * Appender threshold level. Events whose level is below the threshold
+ * will not be logged.
+ * @var Level
+ */
+ protected $threshold;
+
+ /**
+ * Set to true if the appender requires a layout.
+ *
+ * True by default, appenders which do not use a layout should override
+ * this property to false.
+ *
+ * @var boolean
+ */
+ protected $requiresLayout = true;
+
+ /**
+ * Default constructor.
+ * @param string $name Appender name
+ */
+ public function __construct($name = '')
+ {
+ $this->name = $name;
+
+ if ($this->requiresLayout) {
+ $this->layout = $this->getDefaultLayout();
+ }
+ }
+
+ public function __destruct()
+ {
+ $this->close();
+ }
+
+ /**
+ * Returns the default layout for this appender. Can be overriden by
+ * derived appenders.
+ *
+ * @return Layout
+ */
+ public function getDefaultLayout()
+ {
+ return new SimpleLayout();
+ }
+
+ /**
+ * Adds a filter to the end of the filter chain.
+ * @param AbstractFilter $filter add a new AbstractFilter
+ */
+ public function addFilter($filter)
+ {
+ if ($this->filter === null) {
+ $this->filter = $filter;
+ } else {
+ $this->filter->addNext($filter);
+ }
+ }
+
+ /**
+ * Clears the filter chain by removing all the filters in it.
+ */
+ public function clearFilters()
+ {
+ $this->filter = null;
+ }
+
+ /**
+ * Returns the first filter in the filter chain.
+ * The return value may be <i>null</i> if no is filter is set.
+ * @return AbstractFilter
+ */
+ public function getFilter()
+ {
+ return $this->filter;
+ }
+
+ /**
+ * Returns the first filter in the filter chain.
+ * The return value may be <i>null</i> if no is filter is set.
+ * @return AbstractFilter
+ */
+ public function getFirstFilter()
+ {
+ return $this->filter;
+ }
+
+ /**
+ * Performs threshold checks and invokes filters before delegating logging
+ * to the subclass' specific <i>append()</i> method.
+ * @see Appender::append()
+ * @param LoggingEvent $event
+ */
+ public function doAppend(LoggingEvent $event)
+ {
+ if ($this->closed) {
+ return;
+ }
+
+ if (!$this->isAsSevereAsThreshold($event->getLevel())) {
+ return;
+ }
+
+ $filter = $this->getFirstFilter();
+ while ($filter !== null) {
+ switch ($filter->decide($event)) {
+ case AbstractFilter::DENY: return;
+ case AbstractFilter::ACCEPT: return $this->append($event);
+ case AbstractFilter::NEUTRAL: $filter = $filter->getNext();
+ }
+ }
+ $this->append($event);
+ }
+
+ /**
+ * Sets the appender layout.
+ * @param Layout $layout
+ */
+ public function setLayout($layout)
+ {
+ if ($this->requiresLayout()) {
+ $this->layout = $layout;
+ }
+ }
+
+ /**
+ * Returns the appender layout.
+ * @return Layout
+ */
+ public function getLayout()
+ {
+ return $this->layout;
+ }
+
+ /**
+ * Configurators call this method to determine if the appender
+ * requires a layout.
+ *
+ * <p>If this method returns <i>true</i>, meaning that layout is required,
+ * then the configurator will configure a layout using the configuration
+ * information at its disposal. If this method returns <i>false</i>,
+ * meaning that a layout is not required, then layout configuration will be
+ * skipped even if there is available layout configuration
+ * information at the disposal of the configurator.</p>
+ *
+ * <p>In the rather exceptional case, where the appender
+ * implementation admits a layout but can also work without it, then
+ * the appender should return <i>true</i>.</p>
+ *
+ * @return boolean
+ */
+ public function requiresLayout()
+ {
+ return $this->requiresLayout;
+ }
+
+ /**
+ * Retruns the appender name.
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets the appender name.
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Returns the appender's threshold level.
+ * @return Level
+ */
+ public function getThreshold()
+ {
+ return $this->threshold;
+ }
+
+ /**
+ * Sets the appender threshold.
+ *
+ * @param Level|string $threshold Either a {@link Level}
+ * object or a string equivalent.
+ * @see OptionConverter::toLevel()
+ */
+ public function setThreshold($threshold)
+ {
+ $this->setLevel('threshold', $threshold);
+ }
+
+ /**
+ * Checks whether the message level is below the appender's threshold.
+ *
+ * If there is no threshold set, then the return value is always <i>true</i>.
+ *
+ * @param Level $level
+ * @return boolean Returns true if level is greater or equal than
+ * threshold, or if the threshold is not set. Otherwise returns false.
+ */
+ public function isAsSevereAsThreshold($level)
+ {
+ if ($this->threshold === null) {
+ return true;
+ }
+
+ return $level->isGreaterOrEqual($this->getThreshold());
+ }
+
+ /**
+ * Prepares the appender for logging.
+ *
+ * Derived appenders should override this method if option structure
+ * requires it.
+ */
+ public function activateOptions()
+ {
+ $this->closed = false;
+ }
+
+ /**
+ * Forwards the logging event to the destination.
+ *
+ * Derived appenders should implement this method to perform actual logging.
+ *
+ * @param LoggingEvent $event
+ */
+ abstract protected function append(LoggingEvent $event);
+
+ /**
+ * Releases any resources allocated by the appender.
+ *
+ * Derived appenders should override this method to perform proper closing
+ * procedures.
+ */
+ public function close()
+ {
+ $this->closed = true;
+ }
+
+ /** Triggers a warning for this logger with the given message. */
+ protected function warn($message)
+ {
+ $id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
+ trigger_error("log4php: [$id]: $message", E_USER_WARNING);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/ConsoleAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/ConsoleAppender.php b/src/Appenders/ConsoleAppender.php
index def5230..d32fd9e 100644
--- a/src/Appenders/ConsoleAppender.php
+++ b/src/Appenders/ConsoleAppender.php
@@ -35,69 +35,73 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/console.html Appender documentation
*/
- class ConsoleAppender extends AbstractAppender {
+ class ConsoleAppender extends AbstractAppender
+ {
+ /** The standard otuput stream. */
+ const STDOUT = 'php://stdout';
- /** The standard otuput stream. */
- const STDOUT = 'php://stdout';
+ /** The standard error stream.*/
+ const STDERR = 'php://stderr';
- /** The standard error stream.*/
- const STDERR = 'php://stderr';
+ /** The 'target' parameter. */
+ protected $target = self::STDOUT;
- /** The 'target' parameter. */
- protected $target = self::STDOUT;
+ /**
+ * Stream resource for the target stream.
+ * @var resource
+ */
+ protected $fp = null;
- /**
- * Stream resource for the target stream.
- * @var resource
- */
- protected $fp = null;
+ public function activateOptions()
+ {
+ $this->fp = fopen($this->target, 'w');
+ if (is_resource($this->fp) && $this->layout !== null) {
+ fwrite($this->fp, $this->layout->getHeader());
+ }
+ $this->closed = (bool) is_resource($this->fp) === false;
+ }
- public function activateOptions() {
- $this->fp = fopen($this->target, 'w');
- if(is_resource($this->fp) && $this->layout !== null) {
- fwrite($this->fp, $this->layout->getHeader());
- }
- $this->closed = (bool)is_resource($this->fp) === false;
- }
+ public function close()
+ {
+ if ($this->closed != true) {
+ if (is_resource($this->fp) && $this->layout !== null) {
+ fwrite($this->fp, $this->layout->getFooter());
+ fclose($this->fp);
+ }
+ $this->closed = true;
+ }
+ }
+ public function append(LoggingEvent $event)
+ {
+ if (is_resource($this->fp) && $this->layout !== null) {
+ fwrite($this->fp, $this->layout->format($event));
+ }
+ }
- public function close() {
- if($this->closed != true) {
- if (is_resource($this->fp) && $this->layout !== null) {
- fwrite($this->fp, $this->layout->getFooter());
- fclose($this->fp);
- }
- $this->closed = true;
- }
- }
+ /**
+ * Sets the 'target' parameter.
+ * @param string $target
+ */
+ public function setTarget($target)
+ {
+ $value = trim($target);
+ if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
+ $this->target = self::STDOUT;
+ } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
+ $this->target = self::STDERR;
+ } else {
+ $target = var_export($target);
+ $this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
+ }
+ }
- public function append(LoggingEvent $event) {
- if (is_resource($this->fp) && $this->layout !== null) {
- fwrite($this->fp, $this->layout->format($event));
- }
- }
-
- /**
- * Sets the 'target' parameter.
- * @param string $target
- */
- public function setTarget($target) {
- $value = trim($target);
- if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
- $this->target = self::STDOUT;
- } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
- $this->target = self::STDERR;
- } else {
- $target = var_export($target);
- $this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
- }
- }
-
- /**
- * Returns the value of the 'target' parameter.
- * @return string
- */
- public function getTarget() {
- return $this->target;
- }
+ /**
+ * Returns the value of the 'target' parameter.
+ * @return string
+ */
+ public function getTarget()
+ {
+ return $this->target;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/DailyFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/DailyFileAppender.php b/src/Appenders/DailyFileAppender.php
index 7ca1cc7..3464246 100644
--- a/src/Appenders/DailyFileAppender.php
+++ b/src/Appenders/DailyFileAppender.php
@@ -40,91 +40,98 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/daily-file.html Appender documentation
*/
-class DailyFileAppender extends FileAppender {
-
- /**
- * The 'datePattern' parameter.
- * Determines how date will be formatted in file name.
- * @var string
- */
- protected $datePattern = "Ymd";
-
- /**
- * Current date which was used when opening a file.
- * Used to determine if a rollover is needed when the date changes.
- * @var string
- */
- protected $currentDate;
-
- /** Additional validation for the date pattern. */
- public function activateOptions() {
- parent::activateOptions();
-
- if (empty($this->datePattern)) {
- $this->warn("Required parameter 'datePattern' not set. Closing appender.");
- $this->closed = true;
- return;
- }
- }
-
- /**
- * 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(LoggingEvent $event) {
- $eventDate = $this->getDate($event->getTimestamp());
-
- // Initial setting of current date
- if (!isset($this->currentDate)) {
- $this->currentDate = $eventDate;
- }
-
- // Check if rollover is needed
- 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;
- }
-
- parent::append($event);
- }
-
- /** Renders the date using the configured <var>datePattern<var>. */
- protected function getDate($timestamp = null) {
- return date($this->datePattern, $timestamp);
- }
-
- /**
- * Determines target file. Replaces %s in file path with a date.
- */
- protected function getTargetFile() {
- return str_replace('%s', $this->currentDate, $this->file);
- }
-
- /**
- * Sets the 'datePattern' parameter.
- * @param string $datePattern
- */
- public function setDatePattern($datePattern) {
- $this->setString('datePattern', $datePattern);
- }
-
- /**
- * Returns the 'datePattern' parameter.
- * @return string
- */
- public function getDatePattern() {
- return $this->datePattern;
- }
+class DailyFileAppender extends FileAppender
+{
+ /**
+ * The 'datePattern' parameter.
+ * Determines how date will be formatted in file name.
+ * @var string
+ */
+ protected $datePattern = "Ymd";
+
+ /**
+ * Current date which was used when opening a file.
+ * Used to determine if a rollover is needed when the date changes.
+ * @var string
+ */
+ protected $currentDate;
+
+ /** Additional validation for the date pattern. */
+ public function activateOptions()
+ {
+ parent::activateOptions();
+
+ if (empty($this->datePattern)) {
+ $this->warn("Required parameter 'datePattern' not set. Closing appender.");
+ $this->closed = true;
+
+ return;
+ }
+ }
+
+ /**
+ * 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(LoggingEvent $event)
+ {
+ $eventDate = $this->getDate($event->getTimestamp());
+
+ // Initial setting of current date
+ if (!isset($this->currentDate)) {
+ $this->currentDate = $eventDate;
+ }
+
+ // Check if rollover is needed
+ 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;
+ }
+
+ parent::append($event);
+ }
+
+ /** Renders the date using the configured <var>datePattern<var>. */
+ protected function getDate($timestamp = null)
+ {
+ return date($this->datePattern, $timestamp);
+ }
+
+ /**
+ * Determines target file. Replaces %s in file path with a date.
+ */
+ protected function getTargetFile()
+ {
+ return str_replace('%s', $this->currentDate, $this->file);
+ }
+
+ /**
+ * Sets the 'datePattern' parameter.
+ * @param string $datePattern
+ */
+ public function setDatePattern($datePattern)
+ {
+ $this->setString('datePattern', $datePattern);
+ }
+
+ /**
+ * Returns the 'datePattern' parameter.
+ * @return string
+ */
+ public function getDatePattern()
+ {
+ return $this->datePattern;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/EchoAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/EchoAppender.php b/src/Appenders/EchoAppender.php
index 1b47ff9..58d21b4 100644
--- a/src/Appenders/EchoAppender.php
+++ b/src/Appenders/EchoAppender.php
@@ -34,56 +34,59 @@ use Apache\Log4php\LoggingEvent;
*/
class EchoAppender extends AbstractAppender
{
- /**
- * Used to mark first append. Set to false after first append.
- * @var boolean
- */
- protected $firstAppend = true;
+ /**
+ * Used to mark first append. Set to false after first append.
+ * @var boolean
+ */
+ protected $firstAppend = true;
- /**
- * If set to true, a <br /> element will be inserted before each line
- * break in the logged message. Default value is false. @var boolean
- */
- protected $htmlLineBreaks = false;
+ /**
+ * If set to true, a <br /> element will be inserted before each line
+ * break in the logged message. Default value is false. @var boolean
+ */
+ protected $htmlLineBreaks = false;
- public function close() {
- if($this->closed != true) {
- if(!$this->firstAppend) {
- echo $this->layout->getFooter();
- }
- }
- $this->closed = true;
- }
+ public function close()
+ {
+ if ($this->closed != true) {
+ if (!$this->firstAppend) {
+ echo $this->layout->getFooter();
+ }
+ }
+ $this->closed = true;
+ }
- public function append(LoggingEvent $event) {
- if($this->layout !== null) {
- if($this->firstAppend) {
- echo $this->layout->getHeader();
- $this->firstAppend = false;
- }
- $text = $this->layout->format($event);
+ public function append(LoggingEvent $event)
+ {
+ if ($this->layout !== null) {
+ if ($this->firstAppend) {
+ echo $this->layout->getHeader();
+ $this->firstAppend = false;
+ }
+ $text = $this->layout->format($event);
- if ($this->htmlLineBreaks) {
- $text = nl2br($text);
- }
- echo $text;
- }
- }
+ if ($this->htmlLineBreaks) {
+ $text = nl2br($text);
+ }
+ echo $text;
+ }
+ }
- /**
- * Sets the 'htmlLineBreaks' parameter.
- * @param boolean $value
- */
- public function setHtmlLineBreaks($value) {
- $this->setBoolean('htmlLineBreaks', $value);
- }
+ /**
+ * Sets the 'htmlLineBreaks' parameter.
+ * @param boolean $value
+ */
+ public function setHtmlLineBreaks($value)
+ {
+ $this->setBoolean('htmlLineBreaks', $value);
+ }
- /**
- * Returns the 'htmlLineBreaks' parameter.
- * @returns boolean
- */
- public function getHtmlLineBreaks() {
- return $this->htmlLineBreaks;
- }
+ /**
+ * Returns the 'htmlLineBreaks' parameter.
+ * @returns boolean
+ */
+ public function getHtmlLineBreaks()
+ {
+ return $this->htmlLineBreaks;
+ }
}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/FileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/FileAppender.php b/src/Appenders/FileAppender.php
index 5f0cfd4..4d67f2d 100644
--- a/src/Appenders/FileAppender.php
+++ b/src/Appenders/FileAppender.php
@@ -34,192 +34,209 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/file.html Appender documentation
*/
-class FileAppender extends AbstractAppender {
-
- /**
- * If set to true, the file is locked before appending. This allows
- * concurrent access. However, appending without locking is faster so
- * it should be used where appropriate.
- *
- * TODO: make this a configurable parameter
- *
- * @var boolean
- */
- protected $locking = true;
-
- /**
- * If set to true, appends to file. Otherwise overwrites it.
- * @var boolean
- */
- protected $append = true;
-
- /**
- * Path to the target file.
- * @var string
- */
- protected $file;
-
- /**
- * The file resource.
- * @var resource
- */
- protected $fp;
-
- /**
- * Helper function which can be easily overriden by daily file appender.
- */
- protected function getTargetFile() {
- return $this->file;
- }
-
- /**
- * Acquires the target file resource, creates the destination folder if
- * necessary. Writes layout header to file.
- *
- * @return boolean FALSE if opening failed
- */
- protected function openFile() {
- $file = $this->getTargetFile();
-
- // Create the target folder if needed
- if(!is_file($file)) {
- $dir = dirname($file);
-
- if(!is_dir($dir)) {
- $success = mkdir($dir, 0777, true);
- if ($success === false) {
- $this->warn("Failed creating target directory [$dir]. Closing appender.");
- $this->closed = true;
- return false;
- }
- }
- }
-
- $mode = $this->append ? 'a' : 'w';
- $this->fp = fopen($file, $mode);
- if ($this->fp === false) {
- $this->warn("Failed opening target file. Closing appender.");
- $this->fp = null;
- $this->closed = true;
- return false;
- }
-
- // Required when appending with concurrent access
- if($this->append) {
- fseek($this->fp, 0, SEEK_END);
- }
-
- // Write the header
- $this->write($this->layout->getHeader());
- }
-
- /**
- * Writes a string to the target file. Opens file if not already open.
- * @param string $string Data to write.
- */
- protected function write($string) {
- // Lazy file open
- if(!isset($this->fp)) {
- if ($this->openFile() === false) {
- return; // Do not write if file open failed.
- }
- }
-
- if ($this->locking) {
- $this->writeWithLocking($string);
- } else {
- $this->writeWithoutLocking($string);
- }
- }
-
- protected function writeWithLocking($string) {
- if(flock($this->fp, LOCK_EX)) {
- if(fwrite($this->fp, $string) === false) {
- $this->warn("Failed writing to file. Closing appender.");
- $this->closed = true;
- }
- flock($this->fp, LOCK_UN);
- } else {
- $this->warn("Failed locking file for writing. Closing appender.");
- $this->closed = true;
- }
- }
-
- protected function writeWithoutLocking($string) {
- if(fwrite($this->fp, $string) === false) {
- $this->warn("Failed writing to file. Closing appender.");
- $this->closed = true;
- }
- }
-
- public function activateOptions() {
- if (empty($this->file)) {
- $this->warn("Required parameter 'file' not set. Closing appender.");
- $this->closed = true;
- return;
- }
- }
-
- public function close() {
- if (is_resource($this->fp)) {
- $this->write($this->layout->getFooter());
- fclose($this->fp);
- }
- $this->fp = null;
- $this->closed = true;
- }
-
- public function append(LoggingEvent $event) {
- $this->write($this->layout->format($event));
- }
-
- /**
- * Sets the 'file' parameter.
- * @param string $file
- */
- public function setFile($file) {
- $this->setString('file', $file);
- }
-
- /**
- * Returns the 'file' parameter.
- * @return string
- */
- public function getFile() {
- return $this->file;
- }
-
- /**
- * Returns the 'append' parameter.
- * @return boolean
- */
- public function getAppend() {
- return $this->append;
- }
-
- /**
- * Sets the 'append' parameter.
- * @param boolean $append
- */
- public function setAppend($append) {
- $this->setBoolean('append', $append);
- }
-
- /**
- * Sets the 'file' parmeter. Left for legacy reasons.
- * @param string $fileName
- * @deprecated Use setFile() instead.
- */
- public function setFileName($fileName) {
- $this->setFile($fileName);
- }
-
- /**
- * Returns the 'file' parmeter. Left for legacy reasons.
- * @return string
- * @deprecated Use getFile() instead.
- */
- public function getFileName() {
- return $this->getFile();
- }
+class FileAppender extends AbstractAppender
+{
+ /**
+ * If set to true, the file is locked before appending. This allows
+ * concurrent access. However, appending without locking is faster so
+ * it should be used where appropriate.
+ *
+ * TODO: make this a configurable parameter
+ *
+ * @var boolean
+ */
+ protected $locking = true;
+
+ /**
+ * If set to true, appends to file. Otherwise overwrites it.
+ * @var boolean
+ */
+ protected $append = true;
+
+ /**
+ * Path to the target file.
+ * @var string
+ */
+ protected $file;
+
+ /**
+ * The file resource.
+ * @var resource
+ */
+ protected $fp;
+
+ /**
+ * Helper function which can be easily overriden by daily file appender.
+ */
+ protected function getTargetFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * Acquires the target file resource, creates the destination folder if
+ * necessary. Writes layout header to file.
+ *
+ * @return boolean FALSE if opening failed
+ */
+ protected function openFile()
+ {
+ $file = $this->getTargetFile();
+
+ // Create the target folder if needed
+ if (!is_file($file)) {
+ $dir = dirname($file);
+
+ if (!is_dir($dir)) {
+ $success = mkdir($dir, 0777, true);
+ if ($success === false) {
+ $this->warn("Failed creating target directory [$dir]. Closing appender.");
+ $this->closed = true;
+
+ return false;
+ }
+ }
+ }
+
+ $mode = $this->append ? 'a' : 'w';
+ $this->fp = fopen($file, $mode);
+ if ($this->fp === false) {
+ $this->warn("Failed opening target file. Closing appender.");
+ $this->fp = null;
+ $this->closed = true;
+
+ return false;
+ }
+
+ // Required when appending with concurrent access
+ if ($this->append) {
+ fseek($this->fp, 0, SEEK_END);
+ }
+
+ // Write the header
+ $this->write($this->layout->getHeader());
+ }
+
+ /**
+ * Writes a string to the target file. Opens file if not already open.
+ * @param string $string Data to write.
+ */
+ protected function write($string)
+ {
+ // Lazy file open
+ if (!isset($this->fp)) {
+ if ($this->openFile() === false) {
+ return; // Do not write if file open failed.
+ }
+ }
+
+ if ($this->locking) {
+ $this->writeWithLocking($string);
+ } else {
+ $this->writeWithoutLocking($string);
+ }
+ }
+
+ protected function writeWithLocking($string)
+ {
+ if (flock($this->fp, LOCK_EX)) {
+ if (fwrite($this->fp, $string) === false) {
+ $this->warn("Failed writing to file. Closing appender.");
+ $this->closed = true;
+ }
+ flock($this->fp, LOCK_UN);
+ } else {
+ $this->warn("Failed locking file for writing. Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ protected function writeWithoutLocking($string)
+ {
+ if (fwrite($this->fp, $string) === false) {
+ $this->warn("Failed writing to file. Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ public function activateOptions()
+ {
+ if (empty($this->file)) {
+ $this->warn("Required parameter 'file' not set. Closing appender.");
+ $this->closed = true;
+
+ return;
+ }
+ }
+
+ public function close()
+ {
+ if (is_resource($this->fp)) {
+ $this->write($this->layout->getFooter());
+ fclose($this->fp);
+ }
+ $this->fp = null;
+ $this->closed = true;
+ }
+
+ public function append(LoggingEvent $event)
+ {
+ $this->write($this->layout->format($event));
+ }
+
+ /**
+ * Sets the 'file' parameter.
+ * @param string $file
+ */
+ public function setFile($file)
+ {
+ $this->setString('file', $file);
+ }
+
+ /**
+ * Returns the 'file' parameter.
+ * @return string
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * Returns the 'append' parameter.
+ * @return boolean
+ */
+ public function getAppend()
+ {
+ return $this->append;
+ }
+
+ /**
+ * Sets the 'append' parameter.
+ * @param boolean $append
+ */
+ public function setAppend($append)
+ {
+ $this->setBoolean('append', $append);
+ }
+
+ /**
+ * Sets the 'file' parmeter. Left for legacy reasons.
+ * @param string $fileName
+ * @deprecated Use setFile() instead.
+ */
+ public function setFileName($fileName)
+ {
+ $this->setFile($fileName);
+ }
+
+ /**
+ * Returns the 'file' parmeter. Left for legacy reasons.
+ * @return string
+ * @deprecated Use getFile() instead.
+ */
+ public function getFileName()
+ {
+ return $this->getFile();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/MailAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MailAppender.php b/src/Appenders/MailAppender.php
index 796167e..d34dce1 100644
--- a/src/Appenders/MailAppender.php
+++ b/src/Appenders/MailAppender.php
@@ -40,97 +40,106 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/mail.html Appender documentation
*/
-class MailAppender extends AbstractAppender {
-
- /**
- * Email address to put in From field of the email.
- * @var string
- */
- protected $from = null;
-
- /**
- * The subject of the email.
- * @var string
- */
- protected $subject = 'Log4php Report';
-
- /**
- * One or more comma separated email addresses to which to send the email.
- * @var string
- */
- protected $to = null;
-
- /**
- * Indiciates whether this appender should run in dry mode.
- * @deprecated
- * @var boolean
- */
- protected $dry = false;
-
- /**
- * Buffer which holds the email contents before it is sent.
- * @var string
- */
- protected $body = '';
-
- public function append(LoggingEvent $event) {
- if($this->layout !== null) {
- $this->body .= $this->layout->format($event);
- }
- }
-
- public function close() {
- if($this->closed != true) {
- $from = $this->from;
- $to = $this->to;
-
- if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
- $subject = $this->subject;
- if(!$this->dry) {
- mail(
- $to, $subject,
- $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
- "From: {$from}\r\n");
- } else {
- echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
- }
- }
- $this->closed = true;
- }
- }
-
- /** Sets the 'subject' parameter. */
- public function setSubject($subject) {
- $this->setString('subject', $subject);
- }
-
- /** Returns the 'subject' parameter. */
- public function getSubject() {
- return $this->subject;
- }
-
- /** Sets the 'to' parameter. */
- public function setTo($to) {
- $this->setString('to', $to);
- }
-
- /** Returns the 'to' parameter. */
- public function getTo() {
- return $this->to;
- }
-
- /** Sets the 'from' parameter. */
- public function setFrom($from) {
- $this->setString('from', $from);
- }
-
- /** Returns the 'from' parameter. */
- public function getFrom() {
- return $this->from;
- }
-
- /** Enables or disables dry mode. */
- public function setDry($dry) {
- $this->setBoolean('dry', $dry);
- }
+class MailAppender extends AbstractAppender
+{
+ /**
+ * Email address to put in From field of the email.
+ * @var string
+ */
+ protected $from = null;
+
+ /**
+ * The subject of the email.
+ * @var string
+ */
+ protected $subject = 'Log4php Report';
+
+ /**
+ * One or more comma separated email addresses to which to send the email.
+ * @var string
+ */
+ protected $to = null;
+
+ /**
+ * Indiciates whether this appender should run in dry mode.
+ * @deprecated
+ * @var boolean
+ */
+ protected $dry = false;
+
+ /**
+ * Buffer which holds the email contents before it is sent.
+ * @var string
+ */
+ protected $body = '';
+
+ public function append(LoggingEvent $event)
+ {
+ if ($this->layout !== null) {
+ $this->body .= $this->layout->format($event);
+ }
+ }
+
+ public function close()
+ {
+ if ($this->closed != true) {
+ $from = $this->from;
+ $to = $this->to;
+
+ if (!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
+ $subject = $this->subject;
+ if (!$this->dry) {
+ mail(
+ $to, $subject,
+ $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
+ "From: {$from}\r\n");
+ } else {
+ echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
+ }
+ }
+ $this->closed = true;
+ }
+ }
+
+ /** Sets the 'subject' parameter. */
+ public function setSubject($subject)
+ {
+ $this->setString('subject', $subject);
+ }
+
+ /** Returns the 'subject' parameter. */
+ public function getSubject()
+ {
+ return $this->subject;
+ }
+
+ /** Sets the 'to' parameter. */
+ public function setTo($to)
+ {
+ $this->setString('to', $to);
+ }
+
+ /** Returns the 'to' parameter. */
+ public function getTo()
+ {
+ return $this->to;
+ }
+
+ /** Sets the 'from' parameter. */
+ public function setFrom($from)
+ {
+ $this->setString('from', $from);
+ }
+
+ /** Returns the 'from' parameter. */
+ public function getFrom()
+ {
+ return $this->from;
+ }
+
+ /** Enables or disables dry mode. */
+ public function setDry($dry)
+ {
+ $this->setBoolean('dry', $dry);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/MailEventAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MailEventAppender.php b/src/Appenders/MailEventAppender.php
index c49ba12..6a0ff70 100644
--- a/src/Appenders/MailEventAppender.php
+++ b/src/Appenders/MailEventAppender.php
@@ -40,141 +40,156 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/mail-event.html Appender documentation
*/
-class MailEventAppender extends AbstractAppender {
-
- /**
- * Email address to put in From field of the email.
- * @var string
- */
- protected $from;
-
- /**
- * Mail server port (widnows only).
- * @var integer
- */
- protected $port = 25;
-
- /**
- * Mail server hostname (windows only).
- * @var string
- */
- protected $smtpHost;
-
- /**
- * The subject of the email.
- * @var string
- */
- protected $subject = 'Log4php Report';
-
- /**
- * One or more comma separated email addresses to which to send the email.
- * @var string
- */
- protected $to = null;
-
- /**
- * Indiciates whether this appender should run in dry mode.
- * @deprecated
- * @var boolean
- */
- protected $dry = false;
-
- public function activateOptions() {
- if (empty($this->to)) {
- $this->warn("Required parameter 'to' not set. Closing appender.");
- $this->close = true;
- return;
- }
-
- $sendmail_from = ini_get('sendmail_from');
- if (empty($this->from) and empty($sendmail_from)) {
- $this->warn("Required parameter 'from' not set. Closing appender.");
- $this->close = true;
- return;
- }
-
- $this->closed = false;
- }
-
- public function append(LoggingEvent $event) {
- $smtpHost = $this->smtpHost;
- $prevSmtpHost = ini_get('SMTP');
- if(!empty($smtpHost)) {
- ini_set('SMTP', $smtpHost);
- }
-
- $smtpPort = $this->port;
- $prevSmtpPort= ini_get('smtp_port');
- if($smtpPort > 0 and $smtpPort < 65535) {
- ini_set('smtp_port', $smtpPort);
- }
-
- // On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
-
- $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
-
- if(!$this->dry) {
- $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
- } else {
- echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
- }
-
- ini_set('SMTP', $prevSmtpHost);
- ini_set('smtp_port', $prevSmtpPort);
- }
-
- /** Sets the 'from' parameter. */
- public function setFrom($from) {
- $this->setString('from', $from);
- }
-
- /** Returns the 'from' parameter. */
- public function getFrom() {
- return $this->from;
- }
-
- /** Sets the 'port' parameter. */
- public function setPort($port) {
- $this->setPositiveInteger('port', $port);
- }
-
- /** Returns the 'port' parameter. */
- public function getPort() {
- return $this->port;
- }
-
- /** Sets the 'smtpHost' parameter. */
- public function setSmtpHost($smtpHost) {
- $this->setString('smtpHost', $smtpHost);
- }
-
- /** Returns the 'smtpHost' parameter. */
- public function getSmtpHost() {
- return $this->smtpHost;
- }
-
- /** Sets the 'subject' parameter. */
- public function setSubject($subject) {
- $this->setString('subject', $subject);
- }
-
- /** Returns the 'subject' parameter. */
- public function getSubject() {
- return $this->subject;
- }
-
- /** Sets the 'to' parameter. */
- public function setTo($to) {
- $this->setString('to', $to);
- }
-
- /** Returns the 'to' parameter. */
- public function getTo() {
- return $this->to;
- }
-
- /** Enables or disables dry mode. */
- public function setDry($dry) {
- $this->setBoolean('dry', $dry);
- }
+class MailEventAppender extends AbstractAppender
+{
+ /**
+ * Email address to put in From field of the email.
+ * @var string
+ */
+ protected $from;
+
+ /**
+ * Mail server port (widnows only).
+ * @var integer
+ */
+ protected $port = 25;
+
+ /**
+ * Mail server hostname (windows only).
+ * @var string
+ */
+ protected $smtpHost;
+
+ /**
+ * The subject of the email.
+ * @var string
+ */
+ protected $subject = 'Log4php Report';
+
+ /**
+ * One or more comma separated email addresses to which to send the email.
+ * @var string
+ */
+ protected $to = null;
+
+ /**
+ * Indiciates whether this appender should run in dry mode.
+ * @deprecated
+ * @var boolean
+ */
+ protected $dry = false;
+
+ public function activateOptions()
+ {
+ if (empty($this->to)) {
+ $this->warn("Required parameter 'to' not set. Closing appender.");
+ $this->close = true;
+
+ return;
+ }
+
+ $sendmail_from = ini_get('sendmail_from');
+ if (empty($this->from) and empty($sendmail_from)) {
+ $this->warn("Required parameter 'from' not set. Closing appender.");
+ $this->close = true;
+
+ return;
+ }
+
+ $this->closed = false;
+ }
+
+ public function append(LoggingEvent $event)
+ {
+ $smtpHost = $this->smtpHost;
+ $prevSmtpHost = ini_get('SMTP');
+ if (!empty($smtpHost)) {
+ ini_set('SMTP', $smtpHost);
+ }
+
+ $smtpPort = $this->port;
+ $prevSmtpPort= ini_get('smtp_port');
+ if ($smtpPort > 0 and $smtpPort < 65535) {
+ ini_set('smtp_port', $smtpPort);
+ }
+
+ // On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
+
+ $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
+
+ if (!$this->dry) {
+ $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
+ } else {
+ echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
+ }
+
+ ini_set('SMTP', $prevSmtpHost);
+ ini_set('smtp_port', $prevSmtpPort);
+ }
+
+ /** Sets the 'from' parameter. */
+ public function setFrom($from)
+ {
+ $this->setString('from', $from);
+ }
+
+ /** Returns the 'from' parameter. */
+ public function getFrom()
+ {
+ return $this->from;
+ }
+
+ /** Sets the 'port' parameter. */
+ public function setPort($port)
+ {
+ $this->setPositiveInteger('port', $port);
+ }
+
+ /** Returns the 'port' parameter. */
+ public function getPort()
+ {
+ return $this->port;
+ }
+
+ /** Sets the 'smtpHost' parameter. */
+ public function setSmtpHost($smtpHost)
+ {
+ $this->setString('smtpHost', $smtpHost);
+ }
+
+ /** Returns the 'smtpHost' parameter. */
+ public function getSmtpHost()
+ {
+ return $this->smtpHost;
+ }
+
+ /** Sets the 'subject' parameter. */
+ public function setSubject($subject)
+ {
+ $this->setString('subject', $subject);
+ }
+
+ /** Returns the 'subject' parameter. */
+ public function getSubject()
+ {
+ return $this->subject;
+ }
+
+ /** Sets the 'to' parameter. */
+ public function setTo($to)
+ {
+ $this->setString('to', $to);
+ }
+
+ /** Returns the 'to' parameter. */
+ public function getTo()
+ {
+ return $this->to;
+ }
+
+ /** Enables or disables dry mode. */
+ public function setDry($dry)
+ {
+ $this->setBoolean('dry', $dry);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/MongoDBAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MongoDBAppender.php b/src/Appenders/MongoDBAppender.php
index 38d7dca..0ff180b 100644
--- a/src/Appenders/MongoDBAppender.php
+++ b/src/Appenders/MongoDBAppender.php
@@ -46,321 +46,343 @@ use MongoDate;
* @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
* @link http://www.mongodb.org/ MongoDB website.
*/
-class MongoDBAppender extends AbstractAppender {
-
- // ******************************************
- // ** Constants **
- // ******************************************
-
- /** Default prefix for the {@link $host}. */
- const DEFAULT_MONGO_URL_PREFIX = 'mongodb://';
-
- /** Default value for {@link $host}, without a prefix. */
- const DEFAULT_MONGO_HOST = 'localhost';
-
- /** Default value for {@link $port} */
- const DEFAULT_MONGO_PORT = 27017;
-
- /** Default value for {@link $databaseName} */
- const DEFAULT_DB_NAME = 'log4php_mongodb';
-
- /** Default value for {@link $collectionName} */
- const DEFAULT_COLLECTION_NAME = 'logs';
-
- /** Default value for {@link $timeout} */
- const DEFAULT_TIMEOUT_VALUE = 3000;
-
- // ******************************************
- // ** Configurable parameters **
- // ******************************************
-
- /** Server on which mongodb instance is located. */
- protected $host;
-
- /** Port on which the instance is bound. */
- protected $port;
-
- /** Name of the database to which to log. */
- protected $databaseName;
-
- /** Name of the collection within the given database. */
- protected $collectionName;
-
- /** Username used to connect to the database. */
- protected $userName;
-
- /** Password used to connect to the database. */
- protected $password;
-
- /** Timeout value used when connecting to the database (in milliseconds). */
- protected $timeout;
-
- // ******************************************
- // ** Member variables **
- // ******************************************
-
- /**
- * Connection to the MongoDB instance.
- * @var Mongo
- */
- protected $connection;
-
- /**
- * The collection to which log is written.
- * @var MongoCollection
- */
- protected $collection;
-
- public function __construct($name = '') {
- parent::__construct($name);
- $this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
- $this->port = self::DEFAULT_MONGO_PORT;
- $this->databaseName = self::DEFAULT_DB_NAME;
- $this->collectionName = self::DEFAULT_COLLECTION_NAME;
- $this->timeout = self::DEFAULT_TIMEOUT_VALUE;
- $this->requiresLayout = false;
- }
-
- /**
- * Setup db connection.
- * Based on defined options, this method connects to the database and
- * creates a {@link $collection}.
- */
- public function activateOptions() {
- try {
- $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
- $db = $this->connection->selectDB($this->databaseName);
- if ($this->userName !== null && $this->password !== null) {
- $authResult = $db->authenticate($this->userName, $this->password);
- if ($authResult['ok'] == floatval(0)) {
- throw new Exception($authResult['errmsg'], $authResult['ok']);
- }
- }
- $this->collection = $db->selectCollection($this->collectionName);
- } catch (\MongoConnectionException $ex) {
- $this->closed = true;
- $this->warn(sprintf('Failed to connect to mongo deamon: %s', $ex->getMessage()));
- } catch (\InvalidArgumentException $ex) {
- $this->closed = true;
- $this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
- } catch (\Exception $ex) {
- $this->closed = true;
- $this->warn('Invalid credentials for mongo database authentication');
- }
- }
-
- /**
- * Appends a new event to the mongo database.
- *
- * @param LoggingEvent $event
- */
- public function append(LoggingEvent $event) {
- try {
- if ($this->collection != null) {
- $this->collection->insert($this->format($event));
- }
- } catch (\MongoCursorException $ex) {
- $this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
- }
- }
-
- /**
- * Converts the logging event into an array which can be logged to mongodb.
- *
- * @param LoggingEvent $event
- * @return array The array representation of the logging event.
- */
- protected function format(LoggingEvent $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;
- }
-
- /**
- * Converts an Exception into an array which can be logged to mongodb.
- *
- * Supports innner exceptions (PHP >= 5.3)
- *
- * @param Exception $ex
- * @return array
- */
- protected function formatThrowable(Exception $ex) {
- $array = array(
- 'message' => $ex->getMessage(),
- 'code' => $ex->getCode(),
- 'stackTrace' => $ex->getTraceAsString(),
- );
-
- if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
- $array['innerException'] = $this->formatThrowable($ex->getPrevious());
- }
-
- return $array;
- }
-
- /**
- * Closes the connection to the logging database
- */
- public function close() {
- if($this->closed != true) {
- $this->collection = null;
- if ($this->connection !== null) {
- $this->connection->close();
- $this->connection = null;
- }
- $this->closed = true;
- }
- }
-
- /**
- * Sets the value of {@link $host} parameter.
- * @param string $host
- */
- public function setHost($host) {
- if (!preg_match('/^mongodb\:\/\//', $host)) {
- $host = self::DEFAULT_MONGO_URL_PREFIX . $host;
- }
- $this->host = $host;
- }
-
- /**
- * Returns the value of {@link $host} parameter.
- * @return string
- */
- public function getHost() {
- return $this->host;
- }
-
- /**
- * Sets the value of {@link $port} parameter.
- * @param int $port
- */
- public function setPort($port) {
- $this->setPositiveInteger('port', $port);
- }
-
- /**
- * Returns the value of {@link $port} parameter.
- * @return int
- */
- public function getPort() {
- return $this->port;
- }
-
- /**
- * Sets the value of {@link $databaseName} parameter.
- * @param string $databaseName
- */
- public function setDatabaseName($databaseName) {
- $this->setString('databaseName', $databaseName);
- }
-
- /**
- * Returns the value of {@link $databaseName} parameter.
- * @return string
- */
- public function getDatabaseName() {
- return $this->databaseName;
- }
-
- /**
- * Sets the value of {@link $collectionName} parameter.
- * @param string $collectionName
- */
- public function setCollectionName($collectionName) {
- $this->setString('collectionName', $collectionName);
- }
-
- /**
- * Returns the value of {@link $collectionName} parameter.
- * @return string
- */
- public function getCollectionName() {
- return $this->collectionName;
- }
-
- /**
- * Sets the value of {@link $userName} parameter.
- * @param string $userName
- */
- public function setUserName($userName) {
- $this->setString('userName', $userName, true);
- }
-
- /**
- * Returns the value of {@link $userName} parameter.
- * @return string
- */
- public function getUserName() {
- return $this->userName;
- }
-
- /**
- * Sets the value of {@link $password} parameter.
- * @param string $password
- */
- public function setPassword($password) {
- $this->setString('password', $password, true);
- }
-
- /**
- * Returns the value of {@link $password} parameter.
- * @return string
- */
- public function getPassword() {
- return $this->password;
- }
-
- /**
- * Sets the value of {@link $timeout} parameter.
- * @param int $timeout
- */
- public function setTimeout($timeout) {
- $this->setPositiveInteger('timeout', $timeout);
- }
-
- /**
- * Returns the value of {@link $timeout} parameter.
- * @return int
- */
- public function getTimeout() {
- return $this->timeout;
- }
- /**
- * Returns the mongodb connection.
- * @return Mongo
- */
- public function getConnection() {
- return $this->connection;
- }
-
- /**
- * Returns the active mongodb collection.
- * @return MongoCollection
- */
- public function getCollection() {
- return $this->collection;
- }
+class MongoDBAppender extends AbstractAppender
+{
+ // ******************************************
+ // ** Constants **
+ // ******************************************
+
+ /** Default prefix for the {@link $host}. */
+ const DEFAULT_MONGO_URL_PREFIX = 'mongodb://';
+
+ /** Default value for {@link $host}, without a prefix. */
+ const DEFAULT_MONGO_HOST = 'localhost';
+
+ /** Default value for {@link $port} */
+ const DEFAULT_MONGO_PORT = 27017;
+
+ /** Default value for {@link $databaseName} */
+ const DEFAULT_DB_NAME = 'log4php_mongodb';
+
+ /** Default value for {@link $collectionName} */
+ const DEFAULT_COLLECTION_NAME = 'logs';
+
+ /** Default value for {@link $timeout} */
+ const DEFAULT_TIMEOUT_VALUE = 3000;
+
+ // ******************************************
+ // ** Configurable parameters **
+ // ******************************************
+
+ /** Server on which mongodb instance is located. */
+ protected $host;
+
+ /** Port on which the instance is bound. */
+ protected $port;
+
+ /** Name of the database to which to log. */
+ protected $databaseName;
+
+ /** Name of the collection within the given database. */
+ protected $collectionName;
+
+ /** Username used to connect to the database. */
+ protected $userName;
+
+ /** Password used to connect to the database. */
+ protected $password;
+
+ /** Timeout value used when connecting to the database (in milliseconds). */
+ protected $timeout;
+
+ // ******************************************
+ // ** Member variables **
+ // ******************************************
+
+ /**
+ * Connection to the MongoDB instance.
+ * @var Mongo
+ */
+ protected $connection;
+
+ /**
+ * The collection to which log is written.
+ * @var MongoCollection
+ */
+ protected $collection;
+
+ public function __construct($name = '')
+ {
+ parent::__construct($name);
+ $this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
+ $this->port = self::DEFAULT_MONGO_PORT;
+ $this->databaseName = self::DEFAULT_DB_NAME;
+ $this->collectionName = self::DEFAULT_COLLECTION_NAME;
+ $this->timeout = self::DEFAULT_TIMEOUT_VALUE;
+ $this->requiresLayout = false;
+ }
+
+ /**
+ * Setup db connection.
+ * Based on defined options, this method connects to the database and
+ * creates a {@link $collection}.
+ */
+ public function activateOptions()
+ {
+ try {
+ $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
+ $db = $this->connection->selectDB($this->databaseName);
+ if ($this->userName !== null && $this->password !== null) {
+ $authResult = $db->authenticate($this->userName, $this->password);
+ if ($authResult['ok'] == floatval(0)) {
+ throw new Exception($authResult['errmsg'], $authResult['ok']);
+ }
+ }
+ $this->collection = $db->selectCollection($this->collectionName);
+ } catch (\MongoConnectionException $ex) {
+ $this->closed = true;
+ $this->warn(sprintf('Failed to connect to mongo deamon: %s', $ex->getMessage()));
+ } catch (\InvalidArgumentException $ex) {
+ $this->closed = true;
+ $this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
+ } catch (\Exception $ex) {
+ $this->closed = true;
+ $this->warn('Invalid credentials for mongo database authentication');
+ }
+ }
+
+ /**
+ * Appends a new event to the mongo database.
+ *
+ * @param LoggingEvent $event
+ */
+ public function append(LoggingEvent $event)
+ {
+ try {
+ if ($this->collection != null) {
+ $this->collection->insert($this->format($event));
+ }
+ } catch (\MongoCursorException $ex) {
+ $this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
+ }
+ }
+
+ /**
+ * Converts the logging event into an array which can be logged to mongodb.
+ *
+ * @param LoggingEvent $event
+ * @return array The array representation of the logging event.
+ */
+ protected function format(LoggingEvent $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;
+ }
+
+ /**
+ * Converts an Exception into an array which can be logged to mongodb.
+ *
+ * Supports innner exceptions (PHP >= 5.3)
+ *
+ * @param Exception $ex
+ * @return array
+ */
+ protected function formatThrowable(Exception $ex)
+ {
+ $array = array(
+ 'message' => $ex->getMessage(),
+ 'code' => $ex->getCode(),
+ 'stackTrace' => $ex->getTraceAsString(),
+ );
+
+ if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
+ $array['innerException'] = $this->formatThrowable($ex->getPrevious());
+ }
+
+ return $array;
+ }
+
+ /**
+ * Closes the connection to the logging database
+ */
+ public function close()
+ {
+ if ($this->closed != true) {
+ $this->collection = null;
+ if ($this->connection !== null) {
+ $this->connection->close();
+ $this->connection = null;
+ }
+ $this->closed = true;
+ }
+ }
+
+ /**
+ * Sets the value of {@link $host} parameter.
+ * @param string $host
+ */
+ public function setHost($host)
+ {
+ if (!preg_match('/^mongodb\:\/\//', $host)) {
+ $host = self::DEFAULT_MONGO_URL_PREFIX . $host;
+ }
+ $this->host = $host;
+ }
+
+ /**
+ * Returns the value of {@link $host} parameter.
+ * @return string
+ */
+ public function getHost()
+ {
+ return $this->host;
+ }
+
+ /**
+ * Sets the value of {@link $port} parameter.
+ * @param int $port
+ */
+ public function setPort($port)
+ {
+ $this->setPositiveInteger('port', $port);
+ }
+
+ /**
+ * Returns the value of {@link $port} parameter.
+ * @return int
+ */
+ public function getPort()
+ {
+ return $this->port;
+ }
+
+ /**
+ * Sets the value of {@link $databaseName} parameter.
+ * @param string $databaseName
+ */
+ public function setDatabaseName($databaseName)
+ {
+ $this->setString('databaseName', $databaseName);
+ }
+
+ /**
+ * Returns the value of {@link $databaseName} parameter.
+ * @return string
+ */
+ public function getDatabaseName()
+ {
+ return $this->databaseName;
+ }
+
+ /**
+ * Sets the value of {@link $collectionName} parameter.
+ * @param string $collectionName
+ */
+ public function setCollectionName($collectionName)
+ {
+ $this->setString('collectionName', $collectionName);
+ }
+
+ /**
+ * Returns the value of {@link $collectionName} parameter.
+ * @return string
+ */
+ public function getCollectionName()
+ {
+ return $this->collectionName;
+ }
+
+ /**
+ * Sets the value of {@link $userName} parameter.
+ * @param string $userName
+ */
+ public function setUserName($userName)
+ {
+ $this->setString('userName', $userName, true);
+ }
+
+ /**
+ * Returns the value of {@link $userName} parameter.
+ * @return string
+ */
+ public function getUserName()
+ {
+ return $this->userName;
+ }
+
+ /**
+ * Sets the value of {@link $password} parameter.
+ * @param string $password
+ */
+ public function setPassword($password)
+ {
+ $this->setString('password', $password, true);
+ }
+
+ /**
+ * Returns the value of {@link $password} parameter.
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * Sets the value of {@link $timeout} parameter.
+ * @param int $timeout
+ */
+ public function setTimeout($timeout)
+ {
+ $this->setPositiveInteger('timeout', $timeout);
+ }
+
+ /**
+ * Returns the value of {@link $timeout} parameter.
+ * @return int
+ */
+ public function getTimeout()
+ {
+ return $this->timeout;
+ }
+ /**
+ * Returns the mongodb connection.
+ * @return Mongo
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * Returns the active mongodb collection.
+ * @return MongoCollection
+ */
+ public function getCollection()
+ {
+ return $this->collection;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/NullAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/NullAppender.php b/src/Appenders/NullAppender.php
index e599013..dd41040 100644
--- a/src/Appenders/NullAppender.php
+++ b/src/Appenders/NullAppender.php
@@ -27,18 +27,19 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/null.html Appender documentation
*/
-class NullAppender extends AbstractAppender {
+class NullAppender extends AbstractAppender
+{
+ /**
+ * This appender does not require a layout.
+ */
+ protected $requiresLayout = false;
- /**
- * This appender does not require a layout.
- */
- protected $requiresLayout = false;
-
- /**
- * Do nothing.
- *
- * @param LoggingEvent $event
- */
- public function append(LoggingEvent $event) {
- }
+ /**
+ * Do nothing.
+ *
+ * @param LoggingEvent $event
+ */
+ public function append(LoggingEvent $event)
+ {
+ }
}
[26/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/PhpAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/PhpAppender.php b/src/Appenders/PhpAppender.php
new file mode 100644
index 0000000..287c56a
--- /dev/null
+++ b/src/Appenders/PhpAppender.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\Level;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * PhpAppender logs events by creating a PHP user-level message using
+ * the PHP's trigger_error()function.
+ *
+ * This appender has no configurable parameters.
+ *
+ * Levels are mapped as follows:
+ *
+ * - <b>level < WARN</b> mapped to E_USER_NOTICE
+ * - <b>WARN <= level < ERROR</b> mapped to E_USER_WARNING
+ * - <b>level >= ERROR</b> mapped to E_USER_ERROR
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation
+ */
+class PhpAppender extends AbstractAppender {
+
+ public function append(LoggingEvent $event) {
+ $level = $event->getLevel();
+ if($level->isGreaterOrEqual(Level::getLevelError())) {
+ trigger_error($this->layout->format($event), E_USER_ERROR);
+ } else if ($level->isGreaterOrEqual(Level::getLevelWarn())) {
+ trigger_error($this->layout->format($event), E_USER_WARNING);
+ } else {
+ trigger_error($this->layout->format($event), E_USER_NOTICE);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/RollingFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/RollingFileAppender.php b/src/Appenders/RollingFileAppender.php
new file mode 100644
index 0000000..8d54a4a
--- /dev/null
+++ b/src/Appenders/RollingFileAppender.php
@@ -0,0 +1,303 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * RollingFileAppender writes logging events to a specified file. The
+ * file is rolled over after a specified size has been reached.
+ *
+ * This appender uses a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **file** - Path to the target file.
+ * - **append** - If set to true, the appender will append to the file,
+ * otherwise the file contents will be overwritten.
+ * - **maxBackupIndex** - Maximum number of backup files to keep. Default is 1.
+ * - **maxFileSize** - Maximum allowed file size (in bytes) before rolling
+ * over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.
+ * Default is 10M.
+ * - **compress** - If set to true, rolled-over files will be compressed.
+ * Requires the zlib extension.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/rolling-file.html Appender documentation
+ */
+class RollingFileAppender extends FileAppender {
+
+ /** Compressing backup files is done in chunks, this determines how large. */
+ const COMPRESS_CHUNK_SIZE = 102400; // 100KB
+
+ /**
+ * The maximum size (in bytes) that the output file is allowed to reach
+ * before being rolled over to backup files.
+ *
+ * The default maximum file size is 10MB (10485760 bytes). Maximum value
+ * for this option may depend on the file system.
+ *
+ * @var integer
+ */
+ protected $maxFileSize = 10485760;
+
+ /**
+ * Set the maximum number of backup files to keep around.
+ *
+ * Determines how many backup files are kept before the oldest is erased.
+ * This option takes a positive integer value. If set to zero, then there
+ * will be no backup files and the log file will be truncated when it
+ * reaches <var>maxFileSize</var>.
+ *
+ * There is one backup file by default.
+ *
+ * @var integer
+ */
+ protected $maxBackupIndex = 1;
+
+ /**
+ * The <var>compress</var> parameter determindes the compression with zlib.
+ * If set to true, the rollover files are compressed and saved with the .gz extension.
+ * @var boolean
+ */
+ protected $compress = false;
+
+ /**
+ * Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
+ * supports conditional clearing of statistics.
+ * @var boolean
+ * @see http://php.net/manual/en/function.clearstatcache.php
+ */
+ private $clearConditional = false;
+
+ /**
+ * Get the maximum size that the output file is allowed to reach
+ * before being rolled over to backup files.
+ * @return integer
+ */
+ public function getMaximumFileSize() {
+ return $this->maxFileSize;
+ }
+
+ public function __construct($name = '') {
+ parent::__construct($name);
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+ $this->clearConditional = true;
+ }
+ }
+
+ /**
+ * Implements the usual roll over behaviour.
+ *
+ * If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
+ * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
+ *
+ * If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
+ *
+ * Rollover must be called while the file is locked so that it is safe for concurrent access.
+ *
+ * @throws LoggerException If any part of the rollover procedure fails.
+ */
+ private function rollOver() {
+ // If maxBackups <= 0, then there is no file renaming to be done.
+ if($this->maxBackupIndex > 0) {
+ // Delete the oldest file, to keep Windows happy.
+ $file = $this->file . '.' . $this->maxBackupIndex;
+
+ if (file_exists($file) && !unlink($file)) {
+ throw new LoggerException("Unable to delete oldest backup file from [$file].");
+ }
+
+ // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
+ $this->renameArchievedLogs($this->file);
+
+ // Backup the active file
+ $this->moveToBackup($this->file);
+ }
+
+ // Truncate the active file
+ ftruncate($this->fp, 0);
+ rewind($this->fp);
+ }
+
+ private function moveToBackup($source) {
+ if ($this->compress) {
+ $target = $source . '.1.gz';
+ $this->compressFile($source, $target);
+ } else {
+ $target = $source . '.1';
+ copy($source, $target);
+ }
+ }
+
+ private function compressFile($source, $target) {
+ $target = 'compress.zlib://' . $target;
+
+ $fin = fopen($source, 'rb');
+ if ($fin === false) {
+ throw new LoggerException("Unable to open file for reading: [$source].");
+ }
+
+ $fout = fopen($target, 'wb');
+ if ($fout === false) {
+ throw new LoggerException("Unable to open file for writing: [$target].");
+ }
+
+ while (!feof($fin)) {
+ $chunk = fread($fin, self::COMPRESS_CHUNK_SIZE);
+ if (false === fwrite($fout, $chunk)) {
+ throw new LoggerException("Failed writing to compressed file.");
+ }
+ }
+
+ fclose($fin);
+ fclose($fout);
+ }
+
+ private function renameArchievedLogs($fileName) {
+ for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
+
+ $source = $fileName . "." . $i;
+ if ($this->compress) {
+ $source .= '.gz';
+ }
+
+ if(file_exists($source)) {
+ $target = $fileName . '.' . ($i + 1);
+ if ($this->compress) {
+ $target .= '.gz';
+ }
+
+ rename($source, $target);
+ }
+ }
+ }
+
+ /**
+ * Writes a string to the target file. Opens file if not already open.
+ * @param string $string Data to write.
+ */
+ protected function write($string) {
+ // Lazy file open
+ if(!isset($this->fp)) {
+ if ($this->openFile() === false) {
+ return; // Do not write if file open failed.
+ }
+ }
+
+ // Lock the file while writing and possible rolling over
+ if(flock($this->fp, LOCK_EX)) {
+
+ // Write to locked file
+ if(fwrite($this->fp, $string) === false) {
+ $this->warn("Failed writing to file. Closing appender.");
+ $this->closed = true;
+ }
+
+ // Stats cache must be cleared, otherwise filesize() returns cached results
+ // If supported (PHP 5.3+), clear only the state cache for the target file
+ if ($this->clearConditional) {
+ clearstatcache(true, $this->file);
+ } else {
+ clearstatcache();
+ }
+
+ // Rollover if needed
+ if (filesize($this->file) > $this->maxFileSize) {
+ try {
+ $this->rollOver();
+ } catch (LoggerException $ex) {
+ $this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ flock($this->fp, LOCK_UN);
+ } else {
+ $this->warn("Failed locking file for writing. Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ public function activateOptions() {
+ parent::activateOptions();
+
+ if ($this->compress && !extension_loaded('zlib')) {
+ $this->warn("The 'zlib' extension is required for file compression. Disabling compression.");
+ $this->compression = false;
+ }
+ }
+
+ /**
+ * Set the 'maxBackupIndex' parameter.
+ * @param integer $maxBackupIndex
+ */
+ public function setMaxBackupIndex($maxBackupIndex) {
+ $this->setPositiveInteger('maxBackupIndex', $maxBackupIndex);
+ }
+
+ /**
+ * Returns the 'maxBackupIndex' parameter.
+ * @return integer
+ */
+ public function getMaxBackupIndex() {
+ return $this->maxBackupIndex;
+ }
+
+ /**
+ * Set the 'maxFileSize' parameter.
+ * @param mixed $maxFileSize
+ */
+ public function setMaxFileSize($maxFileSize) {
+ $this->setFileSize('maxFileSize', $maxFileSize);
+ }
+
+ /**
+ * Returns the 'maxFileSize' parameter.
+ * @return integer
+ */
+ public function getMaxFileSize() {
+ return $this->maxFileSize;
+ }
+
+ /**
+ * Set the 'maxFileSize' parameter (kept for backward compatibility).
+ * @param mixed $maxFileSize
+ * @deprecated Use setMaxFileSize() instead.
+ */
+ public function setMaximumFileSize($maxFileSize) {
+ $this->warn("The 'maximumFileSize' parameter is deprecated. Use 'maxFileSize' instead.");
+ return $this->setMaxFileSize($maxFileSize);
+ }
+
+ /**
+ * Sets the 'compress' parameter.
+ * @param boolean $compress
+ */
+ public function setCompress($compress) {
+ $this->setBoolean('compress', $compress);
+ }
+
+ /**
+ * Returns the 'compress' parameter.
+ * @param boolean
+ */
+ public function getCompress() {
+ return $this->compress;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/SocketAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/SocketAppender.php b/src/Appenders/SocketAppender.php
new file mode 100644
index 0000000..024c91f
--- /dev/null
+++ b/src/Appenders/SocketAppender.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\Layouts\SerializedLayout;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * SocketAppender appends to a network socket.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **remoteHost** - Target remote host.
+ * - **port** - Target port (optional, defaults to 4446).
+ * - **timeout** - Connection timeout in seconds (optional, defaults to
+ * 'default_socket_timeout' from php.ini)
+ *
+ * The socket will by default be opened in blocking mode.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/socket.html Appender documentation
+ */
+class SocketAppender extends AbstractAppender {
+
+ /**
+ * Target host.
+ * @see http://php.net/manual/en/function.fsockopen.php
+ */
+ protected $remoteHost;
+
+ /** Target port */
+ protected $port = 4446;
+
+ /** Connection timeout in ms. */
+ protected $timeout;
+
+ // ******************************************
+ // *** Appender methods ***
+ // ******************************************
+
+ /** Override the default layout to use serialized. */
+ public function getDefaultLayout() {
+ return new SerializedLayout();
+ }
+
+ public function activateOptions() {
+ if (empty($this->remoteHost)) {
+ $this->warn("Required parameter [remoteHost] not set. Closing appender.");
+ $this->closed = true;
+ return;
+ }
+
+ if (empty($this->timeout)) {
+ $this->timeout = ini_get("default_socket_timeout");
+ }
+
+ $this->closed = false;
+ }
+
+ public function append(LoggingEvent $event) {
+ $socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
+ if ($socket === false) {
+ $this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
+ $this->closed = true;
+ return;
+ }
+
+ if (false === fwrite($socket, $this->layout->format($event))) {
+ $this->warn("Error writing to socket. Closing appender.");
+ $this->closed = true;
+ }
+ fclose($socket);
+ }
+
+ // ******************************************
+ // *** Accessor methods ***
+ // ******************************************
+
+ /** Sets the target host. */
+ public function setRemoteHost($hostname) {
+ $this->setString('remoteHost', $hostname);
+ }
+
+ /** Sets the target port */
+ public function setPort($port) {
+ $this->setPositiveInteger('port', $port);
+ }
+
+ /** Sets the timeout. */
+ public function setTimeout($timeout) {
+ $this->setPositiveInteger('timeout', $timeout);
+ }
+
+ /** Returns the target host. */
+ public function getRemoteHost() {
+ return $this->getRemoteHost();
+ }
+
+ /** Returns the target port. */
+ public function getPort() {
+ return $this->port;
+ }
+
+ /** Returns the timeout */
+ public function getTimeout() {
+ return $this->timeout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/SyslogAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/SyslogAppender.php b/src/Appenders/SyslogAppender.php
new file mode 100644
index 0000000..ae7351b
--- /dev/null
+++ b/src/Appenders/SyslogAppender.php
@@ -0,0 +1,304 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\Level;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Log events to a system log using the PHP syslog() function.
+ *
+ * This appenders requires a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **ident** - The ident of the syslog message.
+ * - **priority** - The priority for the syslog message (used when overriding
+ * priority).
+ * - **facility** - The facility for the syslog message
+ * - **overridePriority** - If set to true, the message priority will always
+ * use the value defined in {@link $priority}, otherwise the priority will
+ * be determined by the message's log level.
+ * - **option** - The option value for the syslog message.
+ *
+ * Recognised syslog options are:
+ *
+ * - CONS - if there is an error while sending data to the system logger, write directly to the system console
+ * - NDELAY - open the connection to the logger immediately
+ * - ODELAY - delay opening the connection until the first message is logged (default)
+ * - PERROR - print log message also to standard error
+ * - PID - include PID with each message
+ *
+ * Multiple options can be set by delimiting them with a pipe character,
+ * e.g.: "CONS|PID|PERROR".
+ *
+ * Recognised syslog priorities are:
+ *
+ * - EMERG
+ * - ALERT
+ * - CRIT
+ * - ERR
+ * - WARNING
+ * - NOTICE
+ * - INFO
+ * - DEBUG
+ *
+ * Levels are mapped as follows:
+ *
+ * - <b>FATAL</b> to LOG_ALERT
+ * - <b>ERROR</b> to LOG_ERR
+ * - <b>WARN</b> to LOG_WARNING
+ * - <b>INFO</b> to LOG_INFO
+ * - <b>DEBUG</b> to LOG_DEBUG
+ * - <b>TRACE</b> to LOG_DEBUG
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/syslog.html Appender documentation
+ */
+class SyslogAppender extends AbstractAppender {
+
+ /**
+ * The ident string is added to each message. Typically the name of your application.
+ *
+ * @var string
+ */
+ protected $ident = "Apache log4php";
+
+ /**
+ * The syslog priority to use when overriding priority. This setting is
+ * required if {@link overridePriority} is set to true.
+ *
+ * @var string
+ */
+ protected $priority;
+
+ /**
+ * The option used when opening the syslog connection.
+ *
+ * @var string
+ */
+ protected $option = 'PID|CONS';
+
+ /**
+ * The facility value indicates the source of the message.
+ *
+ * @var string
+ */
+ protected $facility = 'USER';
+
+ /**
+ * If set to true, the message priority will always use the value defined
+ * in {@link $priority}, otherwise the priority will be determined by the
+ * message's log level.
+ *
+ * @var string
+ */
+ protected $overridePriority = false;
+
+ /**
+ * Holds the int value of the {@link $priority}.
+ * @var int
+ */
+ private $intPriority;
+
+ /**
+ * Holds the int value of the {@link $facility}.
+ * @var int
+ */
+ private $intFacility;
+
+ /**
+ * Holds the int value of the {@link $option}.
+ * @var int
+ */
+ private $intOption;
+
+ /**
+ * Sets the {@link $ident}.
+ *
+ * @param string $ident
+ */
+ public function setIdent($ident) {
+ $this->ident = $ident;
+ }
+
+ /**
+ * Sets the {@link $priority}.
+ *
+ * @param string $priority
+ */
+ public function setPriority($priority) {
+ $this->priority = $priority;
+ }
+
+ /**
+ * Sets the {@link $facility}.
+ *
+ * @param string $facility
+ */
+ public function setFacility($facility) {
+ $this->facility = $facility;
+ }
+
+ /**
+ * Sets the {@link $overridePriority}.
+ *
+ * @param string $overridePriority
+ */
+ public function setOverridePriority($overridePriority) {
+ $this->overridePriority = $overridePriority;
+ }
+
+ /**
+ * Sets the 'option' parameter.
+ *
+ * @param string $option
+ */
+ public function setOption($option) {
+ $this->option = $option;
+ }
+
+ /**
+ * Returns the 'ident' parameter.
+ *
+ * @return string $ident
+ */
+ public function getIdent() {
+ return $this->ident;
+ }
+
+ /**
+ * Returns the 'priority' parameter.
+ *
+ * @return string
+ */
+ public function getPriority() {
+ return $this->priority;
+ }
+
+ /**
+ * Returns the 'facility' parameter.
+ *
+ * @return string
+ */
+ public function getFacility() {
+ return $this->facility;
+ }
+
+ /**
+ * Returns the 'overridePriority' parameter.
+ *
+ * @return string
+ */
+ public function getOverridePriority() {
+ return $this->overridePriority;
+ }
+
+ /**
+ * Returns the 'option' parameter.
+ *
+ * @return string
+ */
+ public function getOption() {
+ return $this->option;
+ }
+
+
+ public function activateOptions() {
+ $this->intPriority = $this->parsePriority();
+ $this->intOption = $this->parseOption();
+ $this->intFacility = $this->parseFacility();
+
+ $this->closed = false;
+ }
+
+ public function close() {
+ if($this->closed != true) {
+ closelog();
+ $this->closed = true;
+ }
+ }
+
+ /**
+ * Appends the event to syslog.
+ *
+ * Log is opened and closed each time because if it is not closed, it
+ * can cause the Apache httpd server to log to whatever ident/facility
+ * was used in openlog().
+ *
+ * @see http://www.php.net/manual/en/function.syslog.php#97843
+ */
+ public function append(LoggingEvent $event) {
+ $priority = $this->getSyslogPriority($event->getLevel());
+ $message = $this->layout->format($event);
+
+ openlog($this->ident, $this->intOption, $this->intFacility);
+ syslog($priority, $message);
+ closelog();
+ }
+
+ /** Determines which syslog priority to use based on the given level. */
+ private function getSyslogPriority(Level $level) {
+ if($this->overridePriority) {
+ return $this->intPriority;
+ }
+ return $level->getSyslogEquivalent();
+ }
+
+ /** Parses a syslog option string and returns the correspodning int value. */
+ private function parseOption() {
+ $value = 0;
+ $options = explode('|', $this->option);
+
+ foreach($options as $option) {
+ if (!empty($option)) {
+ $constant = "LOG_" . trim($option);
+ if (defined($constant)) {
+ $value |= constant($constant);
+ } else {
+ trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING);
+ }
+ }
+ }
+ return $value;
+ }
+
+ /** Parses the facility string and returns the corresponding int value. */
+ private function parseFacility() {
+ if (!empty($this->facility)) {
+ $constant = "LOG_" . trim($this->facility);
+ if (defined($constant)) {
+ return constant($constant);
+ } else {
+ trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING);
+ }
+ }
+ }
+
+ /** Parses the priority string and returns the corresponding int value. */
+ private function parsePriority() {
+ if (!empty($this->priority)) {
+ $constant = "LOG_" . trim($this->priority);
+ if (defined($constant)) {
+ return constant($constant);
+ } else {
+ trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Autoloader.php
----------------------------------------------------------------------
diff --git a/src/Autoloader.php b/src/Autoloader.php
new file mode 100644
index 0000000..fe6b8d3
--- /dev/null
+++ b/src/Autoloader.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * PSR-4 compliant autoloader implementation.
+ */
+class Autoloader
+{
+ const BASE_NAMESPACE = 'Apache\\Log4php\\';
+
+ public function autoload($class)
+ {
+ // Base directory for the namespace prefix
+ $baseDir = __DIR__ . '/../src/';
+
+ // Skip classes which are not in base namespace
+ $len = strlen(self::BASE_NAMESPACE);
+ if (strncmp(self::BASE_NAMESPACE, $class, $len) !== 0) {
+ return;
+ }
+
+ // Locate the class in base dir, based on namespace
+ $classPath = str_replace('\\', '/', substr($class, $len));
+ $file = $baseDir . $classPath . '.php';
+
+ // If the file exists, require it
+ if (file_exists($file)) {
+ require $file;
+ }
+ }
+
+ public function register()
+ {
+ spl_autoload_register(array($this, 'autoload'));
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configurable.php
----------------------------------------------------------------------
diff --git a/src/Configurable.php b/src/Configurable.php
new file mode 100644
index 0000000..352aa23
--- /dev/null
+++ b/src/Configurable.php
@@ -0,0 +1,118 @@
+<?php
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Apache\Log4php;
+
+use Apache\Log4php\Helpers\OptionConverter;
+
+use Exception;
+
+/**
+ * A base class from which all classes which have configurable properties are
+ * extended. Provides a generic setter with integrated validation.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+abstract class Configurable {
+
+ /** Setter function for boolean type. */
+ protected function setBoolean($property, $value) {
+ try {
+ $this->$property = OptionConverter::toBooleanEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
+ }
+ }
+
+ /** Setter function for integer type. */
+ protected function setInteger($property, $value) {
+ try {
+ $this->$property = OptionConverter::toIntegerEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed.");
+ }
+ }
+
+ /** Setter function for Level values. */
+ protected function setLevel($property, $value) {
+ try {
+ $this->$property = OptionConverter::toLevelEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
+ }
+ }
+
+ /** Setter function for integer type. */
+ protected function setPositiveInteger($property, $value) {
+ try {
+ $this->$property = OptionConverter::toPositiveIntegerEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed.");
+ }
+ }
+
+ /** Setter for file size. */
+ protected function setFileSize($property, $value) {
+ try {
+ $this->$property = OptionConverter::toFileSizeEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
+ }
+ }
+
+ /** Setter function for numeric type. */
+ protected function setNumeric($property, $value) {
+ try {
+ $this->$property = OptionConverter::toNumericEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
+ }
+ }
+
+ /** Setter function for string type. */
+ protected function setString($property, $value, $nullable = false) {
+ if ($value === null) {
+ if($nullable) {
+ $this->$property= null;
+ } else {
+ $this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
+ }
+ } else {
+ try {
+ $value = OptionConverter::toStringEx($value);
+ $this->$property = OptionConverter::substConstants($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
+ }
+ }
+ }
+
+ /** Triggers a warning. */
+ protected function warn($message) {
+ $class = get_class($this);
+ trigger_error("log4php: $class: $message", E_USER_WARNING);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configuration/ConfiguratorInterface.php
----------------------------------------------------------------------
diff --git a/src/Configuration/ConfiguratorInterface.php b/src/Configuration/ConfiguratorInterface.php
new file mode 100644
index 0000000..a4a8e21
--- /dev/null
+++ b/src/Configuration/ConfiguratorInterface.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Configuration;
+
+use Apache\Log4php\Hierarchy;
+
+/**
+ * Interface for logger configurators.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+interface ConfiguratorInterface
+{
+ /**
+ * Configures log4php based on the given configuration.
+ *
+ * All configurators implementations must implement this interface.
+ *
+ * @param Hierarchy $hierarchy The hierarchy on which to perform
+ * the configuration.
+ * @param mixed $input Either path to the config file or the
+ * configuration as an array.
+ */
+ public function configure(Hierarchy $hierarchy, $input = null);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configuration/DefaultConfigurator.php
----------------------------------------------------------------------
diff --git a/src/Configuration/DefaultConfigurator.php b/src/Configuration/DefaultConfigurator.php
new file mode 100644
index 0000000..9e4e6bd
--- /dev/null
+++ b/src/Configuration/DefaultConfigurator.php
@@ -0,0 +1,512 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Configuration;
+
+use Apache\Log4php\Appenders\AbstractAppender;
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Helpers\OptionConverter;
+use Apache\Log4php\Hierarchy;
+use Apache\Log4php\Layouts\AbstractLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggerException;
+
+/**
+ * Default implementation of the logger configurator.
+ *
+ * Configures log4php based on a provided configuration file or array.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+class DefaultConfigurator implements ConfiguratorInterface
+{
+ /** XML configuration file format. */
+ const FORMAT_XML = 'xml';
+
+ /** PHP configuration file format. */
+ const FORMAT_PHP = 'php';
+
+ /** INI (properties) configuration file format. */
+ const FORMAT_INI = 'ini';
+
+ /** Defines which adapter should be used for parsing which format. */
+ private $adapters = array(
+ self::FORMAT_XML => 'XmlAdapter',
+ self::FORMAT_INI => 'IniAdapter',
+ self::FORMAT_PHP => 'PhpAdapter',
+ );
+
+ /** Default configuration; used if no configuration file is provided. */
+ private static $defaultConfiguration = array(
+ 'threshold' => 'ALL',
+ 'rootLogger' => array(
+ 'level' => 'DEBUG',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => '\\Apache\\Log4php\\Appenders\\EchoAppender'
+ ),
+ ),
+ );
+
+ /** Holds the appenders before they are linked to loggers. */
+ private $appenders = array();
+
+ /**
+ * Configures log4php based on the given configuration. The input can
+ * either be a path to the config file, or a PHP array holding the
+ * configuration.
+ *
+ * If no configuration is given, or if the given configuration cannot be
+ * parsed for whatever reason, a warning will be issued, and log4php
+ * will use the default configuration contained in
+ * {@link $defaultConfiguration}.
+ *
+ * @param Hierarchy $hierarchy The hierarchy on which to perform
+ * the configuration.
+ * @param string|array $input Either path to the config file or the
+ * configuration as an array. If not set, default configuration
+ * will be used.
+ */
+ public function configure(Hierarchy $hierarchy, $input = null) {
+ $config = $this->parse($input);
+ $this->doConfigure($hierarchy, $config);
+ }
+
+ /**
+ * Parses the given configuration and returns the parsed configuration
+ * as a PHP array. Does not perform any configuration.
+ *
+ * If no configuration is given, or if the given configuration cannot be
+ * parsed for whatever reason, a warning will be issued, and the default
+ * configuration will be returned ({@link $defaultConfiguration}).
+ *
+ * @param string|array $input Either path to the config file or the
+ * configuration as an array. If not set, default configuration
+ * will be used.
+ * @return array The parsed configuration.
+ */
+ public function parse($input) {
+ // No input - use default configuration
+ if (!isset($input)) {
+ $config = self::$defaultConfiguration;
+ }
+
+ // Array input - contains configuration within the array
+ else if (is_array($input)) {
+ $config = $input;
+ }
+
+ // String input - contains path to configuration file
+ else if (is_string($input)) {
+ try {
+ $config = $this->parseFile($input);
+ } catch (LoggerException $e) {
+ $this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
+ $config = self::$defaultConfiguration;
+ }
+ }
+
+ // Anything else is an error
+ else {
+ $this->warn("Invalid configuration param given. Reverting to default configuration.");
+ $config = self::$defaultConfiguration;
+ }
+
+ return $config;
+ }
+
+ /**
+ * Returns the default log4php configuration.
+ * @return array
+ */
+ public static function getDefaultConfiguration() {
+ return self::$defaultConfiguration;
+ }
+
+ /**
+ * Loads the configuration file from the given URL, determines which
+ * adapter to use, converts the configuration to a PHP array and
+ * returns it.
+ *
+ * @param string $url Path to the config file.
+ * @return The configuration from the config file, as a PHP array.
+ * @throws LoggerException If the configuration file cannot be loaded, or
+ * if the parsing fails.
+ */
+ private function parseFile($url) {
+
+ if (!file_exists($url)) {
+ throw new LoggerException("File not found at [$url].");
+ }
+
+ $type = $this->getConfigType($url);
+ $adapterClass = "Apache\\Log4php\\Configuration\\Adapters\\" . $this->adapters[$type];
+
+ $adapter = new $adapterClass();
+ return $adapter->convert($url);
+ }
+
+ /** Determines configuration file type based on the file extension. */
+ private function getConfigType($url) {
+ $info = pathinfo($url);
+ $ext = strtolower($info['extension']);
+
+ switch($ext) {
+ case 'xml':
+ return self::FORMAT_XML;
+
+ case 'ini':
+ case 'properties':
+ return self::FORMAT_INI;
+
+ case 'php':
+ return self::FORMAT_PHP;
+
+ default:
+ throw new LoggerException("Unsupported configuration file extension: $ext");
+ }
+ }
+
+ /**
+ * Constructs the logger hierarchy based on configuration.
+ *
+ * @param Hierarchy $hierarchy
+ * @param array $config
+ */
+ private function doConfigure(Hierarchy $hierarchy, $config) {
+ if (isset($config['threshold'])) {
+ $threshold = Level::toLevel($config['threshold']);
+ if (isset($threshold)) {
+ $hierarchy->setThreshold($threshold);
+ } else {
+ $this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
+ }
+ }
+
+ // Configure appenders and add them to the appender pool
+ if (isset($config['appenders']) && is_array($config['appenders'])) {
+ foreach($config['appenders'] as $name => $appenderConfig) {
+ $this->configureAppender($name, $appenderConfig);
+ }
+ }
+
+ // Configure root logger
+ if (isset($config['rootLogger'])) {
+ $this->configureRootLogger($hierarchy, $config['rootLogger']);
+ }
+
+ // Configure loggers
+ if (isset($config['loggers']) && is_array($config['loggers'])) {
+ foreach($config['loggers'] as $loggerName => $loggerConfig) {
+ $this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
+ }
+ }
+
+ // Configure renderers
+ if (isset($config['renderers']) && is_array($config['renderers'])) {
+ foreach($config['renderers'] as $rendererConfig) {
+ $this->configureRenderer($hierarchy, $rendererConfig);
+ }
+ }
+
+ if (isset($config['defaultRenderer'])) {
+ $this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
+ }
+ }
+
+ private function configureRenderer(Hierarchy $hierarchy, $config) {
+ if (empty($config['renderingClass'])) {
+ $this->warn("Rendering class not specified. Skipping renderer definition.");
+ return;
+ }
+
+ if (empty($config['renderedClass'])) {
+ $this->warn("Rendered class not specified. Skipping renderer definition.");
+ return;
+ }
+
+ // Error handling performed by RendererMap
+ $hierarchy->getRendererMap()->addRenderer($config['renderedClass'], $config['renderingClass']);
+ }
+
+ private function configureDefaultRenderer(Hierarchy $hierarchy, $class) {
+ if (empty($class)) {
+ $this->warn("Rendering class not specified. Skipping default renderer definition.");
+ return;
+ }
+
+ // Error handling performed by RendererMap
+ $hierarchy->getRendererMap()->setDefaultRenderer($class);
+ }
+
+ /**
+ * Configures an appender based on given config and saves it to
+ * {@link $appenders} array so it can be later linked to loggers.
+ * @param string $name Appender name.
+ * @param array $config Appender configuration options.
+ */
+ private function configureAppender($name, $config) {
+
+ // TODO: add this check to other places where it might be useful
+ if (!is_array($config)) {
+ $type = gettype($config);
+ $this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
+ return;
+ }
+
+ // Parse appender class
+ $class = $config['class'];
+ if (empty($class)) {
+ $this->warn("No class given for appender [$name]. Skipping appender definition.");
+ return;
+ }
+
+ // Instantiate the appender
+ if (class_exists($class)) {
+ $appender = new $class($name);
+ } else {
+ // Try the default namespace
+ $nsClass = "\\Apache\\Log4php\\Appenders\\$class";
+ if (class_exists($nsClass)) {
+ $appender = new $nsClass($name);
+ }
+ }
+
+ if (!isset($appender)) {
+ $this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
+ return;
+ }
+
+ if (!($appender instanceof AbstractAppender)) {
+ $this->warn("Invalid class [$class] given for appender [$name]. Not a valid Appender class. Skipping appender definition.");
+ return;
+ }
+
+ // Parse the appender threshold
+ if (isset($config['threshold'])) {
+ $threshold = Level::toLevel($config['threshold']);
+ if ($threshold instanceof Level) {
+ $appender->setThreshold($threshold);
+ } else {
+ $this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
+ }
+ }
+
+ // Parse the appender layout
+ if ($appender->requiresLayout() && isset($config['layout'])) {
+ $this->createAppenderLayout($appender, $config['layout']);
+ }
+
+ // Parse filters
+ if (isset($config['filters']) && is_array($config['filters'])) {
+ foreach($config['filters'] as $filterConfig) {
+ $this->createAppenderFilter($appender, $filterConfig);
+ }
+ }
+
+ // Set options if any
+ if (isset($config['params'])) {
+ $this->setOptions($appender, $config['params']);
+ }
+
+ // Activate and save for later linking to loggers
+ $appender->activateOptions();
+ $this->appenders[$name] = $appender;
+ }
+
+ /**
+ * Parses layout config, creates the layout and links it to the appender.
+ * @param AbstractAppender $appender
+ * @param array $config Layout configuration.
+ */
+ private function createAppenderLayout(AbstractAppender $appender, $config) {
+ $name = $appender->getName();
+ $class = $config['class'];
+ if (empty($class)) {
+ $this->warn("Layout class not specified for appender [$name]. Reverting to default layout.");
+ return;
+ }
+
+ if (class_exists($class)) {
+ $layout = new $class();
+ } else {
+ $nsClass = "Apache\\Log4php\\Layouts\\$class";
+ if (class_exists($nsClass)) {
+ $layout = new $nsClass();
+ }
+ }
+
+ if (!isset($layout)) {
+ $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
+ return;
+ }
+
+
+ if (!($layout instanceof AbstractLayout)) {
+ $this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout.");
+ return;
+ }
+
+ if (isset($config['params'])) {
+ $this->setOptions($layout, $config['params']);
+ }
+
+ $layout->activateOptions();
+ $appender->setLayout($layout);
+ }
+
+ /**
+ * Parses filter config, creates the filter and adds it to the appender's
+ * filter chain.
+ * @param Appender $appender
+ * @param array $config Filter configuration.
+ */
+ private function createAppenderFilter(AbstractAppender $appender, $config) {
+ $name = $appender->getName();
+ $class = $config['class'];
+
+ if (class_exists($class)) {
+ $filter = new $class();
+ } else {
+ $nsClass = "Apache\\Log4php\\Filters\\$class";
+ if (class_exists($nsClass)) {
+ $filter = new $nsClass();
+ }
+ }
+
+ if (!isset($filter)) {
+ $this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
+ return;
+ }
+
+ if (!($filter instanceof AbstractFilter)) {
+ $this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
+ return;
+ }
+
+ if (isset($config['params'])) {
+ $this->setOptions($filter, $config['params']);
+ }
+
+ $filter->activateOptions();
+ $appender->addFilter($filter);
+ }
+
+ /**
+ * Configures the root logger
+ * @see configureLogger()
+ */
+ private function configureRootLogger(Hierarchy $hierarchy, $config) {
+ $logger = $hierarchy->getRootLogger();
+ $this->configureLogger($logger, $config);
+ }
+
+ /**
+ * Configures a logger which is not root.
+ * @see configureLogger()
+ */
+ private function configureOtherLogger(Hierarchy $hierarchy, $name, $config) {
+ // Get logger from hierarchy (this creates it if it doesn't already exist)
+ $logger = $hierarchy->getLogger($name);
+ $this->configureLogger($logger, $config);
+ }
+
+ /**
+ * Configures a logger.
+ *
+ * @param Logger $logger The logger to configure
+ * @param array $config Logger configuration options.
+ */
+ private function configureLogger(Logger $logger, $config) {
+ $loggerName = $logger->getName();
+
+ // Set logger level
+ if (isset($config['level'])) {
+ $level = Level::toLevel($config['level']);
+ if (isset($level)) {
+ $logger->setLevel($level);
+ } else {
+ $this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
+ }
+ }
+
+ // Link appenders to logger
+ if (isset($config['appenders'])) {
+ foreach($config['appenders'] as $appenderName) {
+ if (isset($this->appenders[$appenderName])) {
+ $logger->addAppender($this->appenders[$appenderName]);
+ } else {
+ $this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
+ }
+ }
+ }
+
+ // Set logger additivity
+ if (isset($config['additivity'])) {
+ try {
+ $additivity = OptionConverter::toBooleanEx($config['additivity'], null);
+ $logger->setAdditivity($additivity);
+ } catch (LoggerException $ex) {
+ $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
+ }
+ }
+ }
+
+ /**
+ * Helper method which applies given options to an object which has setters
+ * for these options (such as appenders, layouts, etc.).
+ *
+ * For example, if options are:
+ * <code>
+ * array(
+ * 'file' => '/tmp/myfile.log',
+ * 'append' => true
+ * )
+ * </code>
+ *
+ * This method will call:
+ * <code>
+ * $object->setFile('/tmp/myfile.log')
+ * $object->setAppend(true)
+ * </code>
+ *
+ * If required setters do not exist, it will produce a warning.
+ *
+ * @param mixed $object The object to configure.
+ * @param unknown_type $options
+ */
+ private function setOptions($object, $options) {
+ foreach($options as $name => $value) {
+ $setter = "set$name";
+ if (method_exists($object, $setter)) {
+ $object->$setter($value);
+ } else {
+ $class = get_class($object);
+ $this->warn("Nonexistant option [$name] specified on [$class]. Skipping.");
+ }
+ }
+ }
+
+ /** Helper method to simplify error reporting. */
+ private function warn($message) {
+ trigger_error("log4php: $message", E_USER_WARNING);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configuration/adapters/AdapterInterface.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/AdapterInterface.php b/src/Configuration/adapters/AdapterInterface.php
new file mode 100644
index 0000000..f0fea69
--- /dev/null
+++ b/src/Configuration/adapters/AdapterInterface.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Configuration\Adapters;
+
+/**
+ * The interface for configurator adapters.
+ *
+ * Adapters convert configuration in several formats such as XML, ini and PHP
+ * file to a PHP array.
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+interface AdapterInterface
+{
+ /** Converts the configuration file to PHP format usable by the configurator. */
+ public function convert($input);
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configuration/adapters/IniAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/IniAdapter.php b/src/Configuration/adapters/IniAdapter.php
new file mode 100644
index 0000000..61c003b
--- /dev/null
+++ b/src/Configuration/adapters/IniAdapter.php
@@ -0,0 +1,294 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Configuration\Adapters;
+
+use Apache\Log4php\LoggerException;
+
+/**
+ * Converts ini configuration files to a PHP array.
+ *
+ * These used to be called "properties" files (inherited from log4j), and that
+ * file extension is still supported.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+class IniAdapter implements AdapterInterface {
+
+ /** Name to assign to the root logger. */
+ const ROOT_LOGGER_NAME = "root";
+
+ /** Prefix used for defining logger additivity. */
+ const ADDITIVITY_PREFIX = "log4php.additivity.";
+
+ /** Prefix used for defining logger threshold. */
+ const THRESHOLD_PREFIX = "log4php.threshold";
+
+ /** Prefix used for defining the root logger. */
+ const ROOT_LOGGER_PREFIX = "log4php.rootLogger";
+
+ /** Prefix used for defining a logger. */
+ const LOGGER_PREFIX = "log4php.logger.";
+
+ /** Prefix used for defining an appender. */
+ const APPENDER_PREFIX = "log4php.appender.";
+
+ /** Prefix used for defining a renderer. */
+ const RENDERER_PREFIX = "log4php.renderer.";
+
+ /** Holds the configuration. */
+ private $config = array();
+
+ /**
+ * Loads and parses the INI configuration file.
+ *
+ * @param string $url Path to the config file.
+ * @throws LoggerException
+ */
+ private function load($url) {
+ if (!file_exists($url)) {
+ throw new LoggerException("File [$url] does not exist.");
+ }
+
+ $properties = @parse_ini_file($url, true);
+ if ($properties === false) {
+ $error = error_get_last();
+ throw new LoggerException("Error parsing configuration file: {$error['message']}");
+ }
+
+ return $properties;
+ }
+
+ /**
+ * Converts the provided INI configuration file to a PHP array config.
+ *
+ * @param string $path Path to the config file.
+ * @throws LoggerException If the file cannot be loaded or parsed.
+ */
+ public function convert($path) {
+ // Load the configuration
+ $properties = $this->load($path);
+
+ // Parse threshold
+ if (isset($properties[self::THRESHOLD_PREFIX])) {
+ $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX];
+ }
+
+ // Parse root logger
+ if (isset($properties[self::ROOT_LOGGER_PREFIX])) {
+ $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME);
+ }
+
+ $appenders = array();
+
+ foreach($properties as $key => $value) {
+ // Parse loggers
+ if ($this->beginsWith($key, self::LOGGER_PREFIX)) {
+ $name = substr($key, strlen(self::LOGGER_PREFIX));
+ $this->parseLogger($value, $name);
+ }
+
+ // Parse additivity
+ if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) {
+ $name = substr($key, strlen(self::ADDITIVITY_PREFIX));
+ $this->config['loggers'][$name]['additivity'] = $value;
+ }
+
+ // Parse appenders
+ else if ($this->beginsWith($key, self::APPENDER_PREFIX)) {
+ $this->parseAppender($key, $value);
+ }
+
+ // Parse renderers
+ else if ($this->beginsWith($key, self::RENDERER_PREFIX)) {
+ $this->parseRenderer($key, $value);
+ }
+ }
+
+ return $this->config;
+ }
+
+
+ /**
+ * Parses a logger definition.
+ *
+ * Loggers are defined in the following manner:
+ * <pre>
+ * log4php.logger.<name> = [<level>], [<appender-ref>, <appender-ref>, ...]
+ * </pre>
+ *
+ * @param string $value The configuration value (level and appender-refs).
+ * @param string $name Logger name.
+ */
+ private function parseLogger($value, $name) {
+ // Value is divided by commas
+ $parts = explode(',', $value);
+ if (empty($value) || empty($parts)) {
+ return;
+ }
+
+ // The first value is the logger level
+ $level = array_shift($parts);
+
+ // The remaining values are appender references
+ $appenders = array();
+ while($appender = array_shift($parts)) {
+ $appender = trim($appender);
+ if (!empty($appender)) {
+ $appenders[] = trim($appender);
+ }
+ }
+
+ // Find the target configuration
+ if ($name == self::ROOT_LOGGER_NAME) {
+ $this->config['rootLogger']['level'] = trim($level);
+ $this->config['rootLogger']['appenders'] = $appenders;
+ } else {
+ $this->config['loggers'][$name]['level'] = trim($level);
+ $this->config['loggers'][$name]['appenders'] = $appenders;
+ }
+ }
+
+ /**
+ * Parses an configuration line pertaining to an appender.
+ *
+ * Parses the following patterns:
+ *
+ * Appender class:
+ * <pre>
+ * log4php.appender.<name> = <class>
+ * </pre>
+ *
+ * Appender parameter:
+ * <pre>
+ * log4php.appender.<name>.<param> = <value>
+ * </pre>
+ *
+ * Appender threshold:
+ * <pre>
+ * log4php.appender.<name>.threshold = <level>
+ * </pre>
+ *
+ * Appender layout:
+ * <pre>
+ * log4php.appender.<name>.layout = <layoutClass>
+ * </pre>
+ *
+ * Layout parameter:
+ * <pre>
+ * log4php.appender.<name>.layout.<param> = <value>
+ * </pre>
+ *
+ * For example, a full appender config might look like:
+ * <pre>
+ * log4php.appender.myAppender = ConsoleAppender
+ * log4php.appender.myAppender.threshold = info
+ * log4php.appender.myAppender.target = stdout
+ * log4php.appender.myAppender.layout = PatternLayout
+ * log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n"
+ * </pre>
+ *
+ * After parsing all these options, the following configuration can be
+ * found under $this->config['appenders']['myAppender']:
+ * <pre>
+ * array(
+ * 'class' => ConsoleAppender,
+ * 'threshold' => info,
+ * 'params' => array(
+ * 'target' => 'stdout'
+ * ),
+ * 'layout' => array(
+ * 'class' => 'ConsoleAppender',
+ * 'params' => array(
+ * 'conversionPattern' => '%d %c: %m%n'
+ * )
+ * )
+ * )
+ * </pre>
+ *
+ * @param string $key
+ * @param string $value
+ */
+ private function parseAppender($key, $value) {
+
+ // Remove the appender prefix from key
+ $subKey = substr($key, strlen(self::APPENDER_PREFIX));
+
+ // Divide the string by dots
+ $parts = explode('.', $subKey);
+ $count = count($parts);
+
+ // The first part is always the appender name
+ $name = trim($parts[0]);
+
+ // Only one part - this line defines the appender class
+ if ($count == 1) {
+ $this->config['appenders'][$name]['class'] = $value;
+ return;
+ }
+
+ // Two parts - either a parameter, a threshold or layout class
+ else if ($count == 2) {
+
+ if ($parts[1] == 'layout') {
+ $this->config['appenders'][$name]['layout']['class'] = $value;
+ return;
+ } else if ($parts[1] == 'threshold') {
+ $this->config['appenders'][$name]['threshold'] = $value;
+ return;
+ } else {
+ $this->config['appenders'][$name]['params'][$parts[1]] = $value;
+ return;
+ }
+ }
+
+ // Three parts - this can only be a layout parameter
+ else if ($count == 3) {
+ if ($parts[1] == 'layout') {
+ $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
+ return;
+ }
+ }
+
+ trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
+ }
+
+ /**
+ * Parses a renderer definition.
+ *
+ * Renderers are defined as:
+ * <pre>
+ * log4php.renderer.<renderedClass> = <renderingClass>
+ * </pre>
+ *
+ * @param string $key log4php.renderer.<renderedClass>
+ * @param string $value <renderingClass>
+ */
+ private function parseRenderer($key, $value) {
+ // Remove the appender prefix from key
+ $renderedClass = substr($key, strlen(self::APPENDER_PREFIX));
+ $renderingClass = $value;
+
+ $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
+ }
+
+ /** Helper method. Returns true if $str begins with $sub. */
+ private function beginsWith($str, $sub) {
+ return (strncmp($str, $sub, strlen($sub)) == 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configuration/adapters/PhpAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/PhpAdapter.php b/src/Configuration/adapters/PhpAdapter.php
new file mode 100644
index 0000000..71d245b
--- /dev/null
+++ b/src/Configuration/adapters/PhpAdapter.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Configuration\Adapters;
+
+use Apache\Log4php\LoggerException;
+
+/**
+ * Converts PHP configuration files to a PHP array.
+ *
+ * The file should only hold the PHP config array preceded by "return".
+ *
+ * Example PHP config file:
+ * <code>
+ * <?php
+ * return array(
+ * 'rootLogger' => array(
+ * 'level' => 'info',
+ * 'appenders' => array('default')
+ * ),
+ * 'appenders' => array(
+ * 'default' => array(
+ * 'class' => 'EchoAppender',
+ * 'layout' => array(
+ * 'class' => 'SimpleLayout'
+ * )
+ * )
+ * )
+ * )
+ * ?>
+ * </code>
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+class PhpAdapter implements AdapterInterface
+{
+ public function convert($url) {
+ if (!file_exists($url)) {
+ throw new LoggerException("File [$url] does not exist.");
+ }
+
+ // Load the config file
+ $data = @file_get_contents($url);
+ if ($data === false) {
+ $error = error_get_last();
+ throw new LoggerException("Error loading config file: {$error['message']}");
+ }
+
+ $config = @eval('?>' . $data);
+
+ if ($config === false) {
+ $error = error_get_last();
+ throw new LoggerException("Error parsing configuration: " . $error['message']);
+ }
+
+ if (empty($config)) {
+ throw new LoggerException("Invalid configuration: empty configuration array.");
+ }
+
+ if (!is_array($config)) {
+ throw new LoggerException("Invalid configuration: not an array.");
+ }
+
+ return $config;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Configuration/adapters/XmlAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/XmlAdapter.php b/src/Configuration/adapters/XmlAdapter.php
new file mode 100644
index 0000000..d7495b8
--- /dev/null
+++ b/src/Configuration/adapters/XmlAdapter.php
@@ -0,0 +1,277 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Configuration\Adapters;
+
+use Apache\Log4php\LoggerException;
+
+/**
+ * Converts XML configuration files to a PHP array.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @since 2.2
+ */
+class XmlAdapter implements AdapterInterface
+{
+ /** Path to the XML schema used for validation. */
+ const SCHEMA_PATH = '/../xml/log4php.xsd';
+
+ private $config = array(
+ 'appenders' => array(),
+ 'loggers' => array(),
+ 'renderers' => array(),
+ );
+
+ public function convert($url) {
+ $xml = $this->loadXML($url);
+
+ $this->parseConfiguration($xml);
+
+ // Parse the <root> node
+ if (isset($xml->root)) {
+ $this->parseRootLogger($xml->root);
+ }
+
+ // Process <logger> nodes
+ foreach($xml->logger as $logger) {
+ $this->parseLogger($logger);
+ }
+
+ // Process <appender> nodes
+ foreach($xml->appender as $appender) {
+ $this->parseAppender($appender);
+ }
+
+ // Process <renderer> nodes
+ foreach($xml->renderer as $rendererNode) {
+ $this->parseRenderer($rendererNode);
+ }
+
+ // Process <defaultRenderer> node
+ foreach($xml->defaultRenderer as $rendererNode) {
+ $this->parseDefaultRenderer($rendererNode);
+ }
+
+ return $this->config;
+ }
+
+ /**
+ * Loads and validates the XML.
+ * @param string $url Input XML.
+ */
+ private function loadXML($url) {
+ if (!file_exists($url)) {
+ throw new LoggerException("File [$url] does not exist.");
+ }
+
+ libxml_clear_errors();
+ $oldValue = libxml_use_internal_errors(true);
+
+ // Load XML
+ $xml = @simplexml_load_file($url);
+ if ($xml === false) {
+
+ $errorStr = "";
+ foreach(libxml_get_errors() as $error) {
+ $errorStr .= $error->message;
+ }
+
+ throw new LoggerException("Error loading configuration file: " . trim($errorStr));
+ }
+
+ libxml_clear_errors();
+ libxml_use_internal_errors($oldValue);
+
+ return $xml;
+ }
+
+ /**
+ * Parses the <configuration> node.
+ */
+ private function parseConfiguration(\SimpleXMLElement $xml) {
+ $attributes = $xml->attributes();
+ if (isset($attributes['threshold'])) {
+ $this->config['threshold'] = (string) $attributes['threshold'];
+ }
+ }
+
+ /** Parses an <appender> node. */
+ private function parseAppender(\SimpleXMLElement $node) {
+ $name = $this->getAttributeValue($node, 'name');
+ if (empty($name)) {
+ $this->warn("An <appender> node is missing the required 'name' attribute. Skipping appender definition.");
+ return;
+ }
+
+ $appender = array();
+ $appender['class'] = $this->getAttributeValue($node, 'class');
+
+ if (isset($node['threshold'])) {
+ $appender['threshold'] = $this->getAttributeValue($node, 'threshold');
+ }
+
+ if (isset($node->layout)) {
+ $appender['layout']= $this->parseLayout($node->layout, $name);
+ }
+
+ if (count($node->param) > 0) {
+ $appender['params'] = $this->parseParameters($node);
+ }
+
+ foreach($node->filter as $filterNode) {
+ $appender['filters'][] = $this->parseFilter($filterNode);
+ }
+
+ $this->config['appenders'][$name] = $appender;
+ }
+
+ /** Parses a <layout> node. */
+ private function parseLayout(\SimpleXMLElement $node, $appenderName) {
+ $layout = array();
+ $layout['class'] = $this->getAttributeValue($node, 'class');
+
+ if (count($node->param) > 0) {
+ $layout['params'] = $this->parseParameters($node);
+ }
+
+ return $layout;
+ }
+
+ /** Parses any <param> child nodes returning them in an array. */
+ private function parseParameters($paramsNode) {
+ $params = array();
+
+ foreach($paramsNode->param as $paramNode) {
+ if (empty($paramNode['name'])) {
+ $this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
+ continue;
+ }
+
+ $name = $this->getAttributeValue($paramNode, 'name');
+ $value = $this->getAttributeValue($paramNode, 'value');
+
+ $params[$name] = $value;
+ }
+
+ return $params;
+ }
+
+ /** Parses a <root> node. */
+ private function parseRootLogger(\SimpleXMLElement $node) {
+ $logger = array();
+
+ if (isset($node->level)) {
+ $logger['level'] = $this->getAttributeValue($node->level, 'value');
+ }
+
+ $logger['appenders'] = $this->parseAppenderReferences($node);
+
+ $this->config['rootLogger'] = $logger;
+ }
+
+ /** Parses a <logger> node. */
+ private function parseLogger(\SimpleXMLElement $node) {
+ $logger = array();
+
+ $name = $this->getAttributeValue($node, 'name');
+ if (empty($name)) {
+ $this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
+ return;
+ }
+
+ if (isset($node->level)) {
+ $logger['level'] = $this->getAttributeValue($node->level, 'value');
+ }
+
+ if (isset($node['additivity'])) {
+ $logger['additivity'] = $this->getAttributeValue($node, 'additivity');
+ }
+
+ $logger['appenders'] = $this->parseAppenderReferences($node);
+
+ // Check for duplicate loggers
+ if (isset($this->config['loggers'][$name])) {
+ $this->warn("Duplicate logger definition [$name]. Overwriting.");
+ }
+
+ $this->config['loggers'][$name] = $logger;
+ }
+
+ /**
+ * Parses a <logger> node for appender references and returns them in an array.
+ *
+ * Previous versions supported appender-ref, as well as appender_ref so both
+ * are parsed for backward compatibility.
+ */
+ private function parseAppenderReferences(\SimpleXMLElement $node) {
+ $refs = array();
+ foreach($node->appender_ref as $ref) {
+ $refs[] = $this->getAttributeValue($ref, 'ref');
+ }
+
+ foreach($node->{'appender-ref'} as $ref) {
+ $refs[] = $this->getAttributeValue($ref, 'ref');
+ }
+
+ return $refs;
+ }
+
+ /** Parses a <filter> node. */
+ private function parseFilter($filterNode) {
+ $filter = array();
+ $filter['class'] = $this->getAttributeValue($filterNode, 'class');
+
+ if (count($filterNode->param) > 0) {
+ $filter['params'] = $this->parseParameters($filterNode);
+ }
+
+ return $filter;
+ }
+
+ /** Parses a <renderer> node. */
+ private function parseRenderer(\SimpleXMLElement $node) {
+ $renderedClass = $this->getAttributeValue($node, 'renderedClass');
+ $renderingClass = $this->getAttributeValue($node, 'renderingClass');
+
+ $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
+ }
+
+ /** Parses a <defaultRenderer> node. */
+ private function parseDefaultRenderer(\SimpleXMLElement $node) {
+ $renderingClass = $this->getAttributeValue($node, 'renderingClass');
+
+ // Warn on duplicates
+ if(isset($this->config['defaultRenderer'])) {
+ $this->warn("Duplicate <defaultRenderer> node. Overwriting.");
+ }
+
+ $this->config['defaultRenderer'] = $renderingClass;
+ }
+
+ // ******************************************
+ // ** Helper methods **
+ // ******************************************
+
+ private function getAttributeValue(\SimpleXMLElement $node, $name) {
+ return isset($node[$name]) ? (string) $node[$name] : null;
+ }
+
+ private function warn($message) {
+ trigger_error("log4php: " . $message, E_USER_WARNING);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Filters/AbstractFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/AbstractFilter.php b/src/Filters/AbstractFilter.php
new file mode 100644
index 0000000..81663e3
--- /dev/null
+++ b/src/Filters/AbstractFilter.php
@@ -0,0 +1,126 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Filters;
+
+use Apache\Log4php\Configurable;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Users should extend this class to implement customized logging
+ * event filtering. Note that {@link LoggerCategory} and {@link Appender},
+ * the parent class of all standard
+ * appenders, have built-in filtering rules. It is suggested that you
+ * first use and understand the built-in rules before rushing to write
+ * your own custom filters.
+ *
+ * <p>This abstract class assumes and also imposes that filters be
+ * organized in a linear chain. The {@link #decide
+ * decide(LoggingEvent)} method of each filter is called sequentially,
+ * in the order of their addition to the chain.
+ *
+ * <p>The {@link decide()} method must return one
+ * of the integer constants {@link AbstractFilter::DENY},
+ * {@link AbstractFilter::NEUTRAL} or {@link AbstractFilter::ACCEPT}.
+ *
+ * <p>If the value {@link AbstractFilter::DENY} is returned, then the log event is
+ * dropped immediately without consulting with the remaining
+ * filters.
+ *
+ * <p>If the value {@link AbstractFilter::NEUTRAL} is returned, then the next filter
+ * in the chain is consulted. If there are no more filters in the
+ * chain, then the log event is logged. Thus, in the presence of no
+ * filters, the default behaviour is to log all logging events.
+ *
+ * <p>If the value {@link AbstractFilter::ACCEPT} is returned, then the log
+ * event is logged without consulting the remaining filters.
+ *
+ * <p>The philosophy of log4php filters is largely inspired from the
+ * Linux ipchains.
+ */
+abstract class AbstractFilter extends Configurable {
+
+ /**
+ * The log event must be logged immediately without consulting with
+ * the remaining filters, if any, in the chain.
+ */
+ const ACCEPT = 1;
+
+ /**
+ * This filter is neutral with respect to the log event. The
+ * remaining filters, if any, should be consulted for a final decision.
+ */
+ const NEUTRAL = 0;
+
+ /**
+ * The log event must be dropped immediately without consulting
+ * with the remaining filters, if any, in the chain.
+ */
+ const DENY = -1;
+
+ /**
+ * @var AbstractFilter Points to the next {@link AbstractFilter} in the filter chain.
+ */
+ protected $next;
+
+ /**
+ * Usually filters options become active when set. We provide a
+ * default do-nothing implementation for convenience.
+ */
+ public function activateOptions() {
+ }
+
+ /**
+ * Decide what to do.
+ * <p>If the decision is {@link AbstractFilter::DENY}, then the event will be
+ * dropped. If the decision is {@link AbstractFilter::NEUTRAL}, then the next
+ * filter, if any, will be invoked. If the decision is {@link AbstractFilter::ACCEPT} then
+ * the event will be logged without consulting with other filters in
+ * the chain.
+ *
+ * @param LoggingEvent $event The {@link LoggingEvent} to decide upon.
+ * @return integer {@link AbstractFilter::NEUTRAL} or {@link AbstractFilter::DENY}|{@link AbstractFilter::ACCEPT}
+ */
+ public function decide(LoggingEvent $event) {
+ return self::NEUTRAL;
+ }
+
+ /**
+ * Adds a new filter to the filter chain this filter is a part of.
+ * If this filter has already and follow up filter, the param filter
+ * is passed on until it is the last filter in chain.
+ *
+ * @param $filter - the filter to add to this chain
+ */
+ public function addNext($filter) {
+ if($this->next !== null) {
+ $this->next->addNext($filter);
+ } else {
+ $this->next = $filter;
+ }
+ }
+
+ /**
+ * Returns the next filter in this chain
+ * @return the next filter
+ */
+ public function getNext() {
+ return $this->next;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Filters/DenyAllFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/DenyAllFilter.php b/src/Filters/DenyAllFilter.php
new file mode 100644
index 0000000..1d34357
--- /dev/null
+++ b/src/Filters/DenyAllFilter.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Filters;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * This filter drops all logging events.
+ *
+ * You can add this filter to the end of a filter chain to
+ * switch from the default "accept all unless instructed otherwise"
+ * filtering behaviour to a "deny all unless instructed otherwise"
+ * behaviour.
+ *
+ * @since 0.3
+ */
+class DenyAllFilter extends AbstractFilter {
+
+ /**
+ * Always returns the integer constant {@link AbstractFilter::DENY}
+ * regardless of the {@link LoggingEvent} parameter.
+ *
+ * @param LoggingEvent $event The {@link LoggingEvent} to filter.
+ * @return AbstractFilter::DENY Always returns {@link AbstractFilter::DENY}
+ */
+ public function decide(LoggingEvent $event) {
+ return AbstractFilter::DENY;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Filters/LevelMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/LevelMatchFilter.php b/src/Filters/LevelMatchFilter.php
new file mode 100644
index 0000000..4573c4c
--- /dev/null
+++ b/src/Filters/LevelMatchFilter.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Filters;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * This is a very simple filter based on level matching.
+ *
+ * <p>The filter admits two options <b><var>LevelToMatch</var></b> and
+ * <b><var>AcceptOnMatch</var></b>. If there is an exact match between the value
+ * of the <b><var>LevelToMatch</var></b> option and the level of the
+ * {@link LoggingEvent}, then the {@link decide()} method returns
+ * {@link AbstractFilter::ACCEPT} in case the <b><var>AcceptOnMatch</var></b>
+ * option value is set to <i>true</i>, if it is <i>false</i> then
+ * {@link AbstractFilter::DENY} is returned. If there is no match,
+ * {@link AbstractFilter::NEUTRAL} is returned.</p>
+ *
+ * <p>
+ * An example for this filter:
+ *
+ * {@example ../../examples/php/filter_levelmatch.php 19}
+ *
+ * <p>
+ * The corresponding XML file:
+ *
+ * {@example ../../examples/resources/filter_levelmatch.xml 18}
+ * @since 0.6
+ */
+class LevelMatchFilter extends AbstractFilter {
+
+ /**
+ * Indicates if this event should be accepted or denied on match
+ * @var boolean
+ */
+ protected $acceptOnMatch = true;
+
+ /**
+ * The level, when to match
+ * @var Level
+ */
+ protected $levelToMatch;
+
+ /**
+ * @param boolean $acceptOnMatch
+ */
+ public function setAcceptOnMatch($acceptOnMatch) {
+ $this->setBoolean('acceptOnMatch', $acceptOnMatch);
+ }
+
+ /**
+ * @param string $l the level to match
+ */
+ public function setLevelToMatch($level) {
+ $this->setLevel('levelToMatch', $level);
+ }
+
+ /**
+ * Return the decision of this filter.
+ *
+ * Returns {@link AbstractFilter::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 AbstractFilter::ACCEPT} if the
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
+ * returned decision is {@link AbstractFilter::DENY} if the
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
+ *
+ * @param LoggingEvent $event
+ * @return integer
+ */
+ public function decide(LoggingEvent $event) {
+ if($this->levelToMatch === null) {
+ return AbstractFilter::NEUTRAL;
+ }
+
+ if($this->levelToMatch->equals($event->getLevel())) {
+ return $this->acceptOnMatch ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
+ } else {
+ return AbstractFilter::NEUTRAL;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Filters/LevelRangeFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/LevelRangeFilter.php b/src/Filters/LevelRangeFilter.php
new file mode 100644
index 0000000..d30f5ae
--- /dev/null
+++ b/src/Filters/LevelRangeFilter.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Filters;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * This is a very simple filter based on level matching, which can be
+ * used to reject messages with priorities outside a certain range.
+ *
+ * <p>The filter admits three options <b><var>LevelMin</var></b>, <b><var>LevelMax</var></b>
+ * and <b><var>AcceptOnMatch</var></b>.</p>
+ *
+ * <p>If the level of the {@link LoggingEvent} is not between Min and Max
+ * (inclusive), then {@link AbstractFilter::DENY} is returned.</p>
+ *
+ * <p>If the Logging event level is within the specified range, then if
+ * <b><var>AcceptOnMatch</var></b> is <i>true</i>,
+ * {@link AbstractFilter::ACCEPT} is returned, and if
+ * <b><var>AcceptOnMatch</var></b> is <i>false</i>,
+ * {@link AbstractFilter::NEUTRAL} is returned.</p>
+ *
+ * <p>If <b><var>LevelMin</var></b> is not defined, then there is no
+ * minimum acceptable level (i.e. a level is never rejected for
+ * being too "low"/unimportant). If <b><var>LevelMax</var></b> is not
+ * defined, then there is no maximum acceptable level (ie a
+ * level is never rejected for being too "high"/important).</p>
+ *
+ * <p>Refer to the {@link Appender::setThreshold()} method
+ * available to <b>all</b> appenders extending {@link Appender}
+ * for a more convenient way to filter out events by level.</p>
+ *
+ * <p>
+ * An example for this filter:
+ *
+ * {@example ../../examples/php/filter_levelrange.php 19}
+ *
+ * <p>
+ * The corresponding XML file:
+ *
+ * {@example ../../examples/resources/filter_levelrange.xml 18}
+ *
+ * @author Simon Kitching
+ * @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
+ * @since 0.6
+ */
+class LevelRangeFilter extends AbstractFilter {
+
+ /**
+ * @var boolean
+ */
+ protected $acceptOnMatch = true;
+
+ /**
+ * @var Level
+ */
+ protected $levelMin;
+
+ /**
+ * @var Level
+ */
+ protected $levelMax;
+
+ /**
+ * @param boolean $acceptOnMatch
+ */
+ public function setAcceptOnMatch($acceptOnMatch) {
+ $this->setBoolean('acceptOnMatch', $acceptOnMatch);
+ }
+
+ /**
+ * @param string $l the level min to match
+ */
+ public function setLevelMin($level) {
+ $this->setLevel('levelMin', $level);
+ }
+
+ /**
+ * @param string $l the level max to match
+ */
+ public function setLevelMax($level) {
+ $this->setLevel('levelMax', $level);
+ }
+
+ /**
+ * Return the decision of this filter.
+ *
+ * @param LoggingEvent $event
+ * @return integer
+ */
+ public function decide(LoggingEvent $event) {
+ $level = $event->getLevel();
+
+ if($this->levelMin !== null) {
+ if($level->isGreaterOrEqual($this->levelMin) == false) {
+ // level of event is less than minimum
+ return AbstractFilter::DENY;
+ }
+ }
+
+ if($this->levelMax !== null) {
+ if($level->toInt() > $this->levelMax->toInt()) {
+ // level of event is greater than maximum
+ // Alas, there is no Level.isGreater method. and using
+ // a combo of isGreaterOrEqual && !Equal seems worse than
+ // checking the int values of the level objects..
+ return AbstractFilter::DENY;
+ }
+ }
+
+ if($this->acceptOnMatch) {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return AbstractFilter::ACCEPT;
+ } else {
+ // event is ok for this filter; allow later filters to have a look..
+ return AbstractFilter::NEUTRAL;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Filters/StringMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/StringMatchFilter.php b/src/Filters/StringMatchFilter.php
new file mode 100644
index 0000000..152c9c9
--- /dev/null
+++ b/src/Filters/StringMatchFilter.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Filters;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * This is a very simple filter based on string matching.
+ *
+ * <p>The filter admits two options {@link $stringToMatch} and
+ * {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos}
+ * between the value of the {@link $stringToMatch} option and the message
+ * of the {@link LoggingEvent},
+ * then the {@link decide()} method returns {@link AbstractFilter::ACCEPT} if
+ * the <b>AcceptOnMatch</b> option value is true, if it is false then
+ * {@link AbstractFilter::DENY} is returned. If there is no match, {@link AbstractFilter::NEUTRAL}
+ * is returned.</p>
+ *
+ * <p>
+ * An example for this filter:
+ *
+ * {@example ../../examples/php/filter_stringmatch.php 19}
+ *
+ * <p>
+ * The corresponding XML file:
+ *
+ * {@example ../../examples/resources/filter_stringmatch.xml 18}
+ * @since 0.3
+ */
+class StringMatchFilter extends AbstractFilter {
+
+ /**
+ * @var boolean
+ */
+ protected $acceptOnMatch = true;
+
+ /**
+ * @var string
+ */
+ protected $stringToMatch;
+
+ /**
+ * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
+ */
+ public function setAcceptOnMatch($acceptOnMatch) {
+ $this->setBoolean('acceptOnMatch', $acceptOnMatch);
+ }
+
+ /**
+ * @param string $s the string to match
+ */
+ public function setStringToMatch($string) {
+ $this->setString('stringToMatch', $string);
+ }
+
+ /**
+ * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
+ */
+ public function decide(LoggingEvent $event) {
+ $msg = $event->getRenderedMessage();
+
+ if($msg === null or $this->stringToMatch === null) {
+ return AbstractFilter::NEUTRAL;
+ }
+
+ if(strpos($msg, $this->stringToMatch) !== false ) {
+ return ($this->acceptOnMatch) ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
+ }
+ return AbstractFilter::NEUTRAL;
+ }
+}
[15/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/css/site.css
----------------------------------------------------------------------
diff --git a/src/site/resources/css/site.css b/src/site/resources/css/site.css
deleted file mode 100644
index caac8a8..0000000
--- a/src/site/resources/css/site.css
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-div.clear { clear:both; visibility: hidden; }
-div.clear hr { display: none; }
-
-/* Tweaks to the bootstrap theme
---------------------------------- */
-li { line-height: 20px; }
-tt { font-family: Menlo, Monaco, "Courier New", monospace; font-size: 12px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; padding: 3px 4px; color: #d14; background-color: #f7f7f9; border: 1px solid #e1e1e8; }
-
-.layout-table { width: 100%; }
-.sidebar { width: 250px; vertical-align: top; }
-.content { padding-left: 20px; vertical-align: top; }
-
-.sidebar-nav { padding: 9px 0; }
-
-.navbar .nav { margin-left: 40px; }
-
-.nav-list { margin-bottom: 15px; }
-.nav-list li { line-height: 16px; }
-.nav-list li.nav-header { color: #333; }
-.nav-list li.nav-header i { margin-right: 5px; }
-
-.nav-list li a { background-repeat: no-repeat; background-position: 16px 9px; padding-left: 34px; }
-.nav-list li.collapsed > a { background-image: url(../images/collapsed.gif) }
-.nav-list li.expanded > a { background-image: url(../images/expanded.gif) }
-
-.nav-list li.expanded ul { list-style: none; margin-left: 0px; }
-.nav-list li.expanded li a { display: block; padding: 3px 15px 3px 45px; margin-left: -15px; margin-right: -15px; }
-.nav-list li.expanded li a:hover { text-decoration: none; background-color: #eeeeee; }
-.nav-list li.expanded li.active a { background-color: #08C; color: white }
-
-.nav.nav-tabs { margin-bottom: 8px; }
-
-.content .section { margin-top: 20px; }
-.content .section:first-child { margin-top: 0px; }
-.section h2 { margin-bottom: 10px; }
-.section h3 { margin-bottom: 10px; }
-.section h4 { margin-bottom: 10px; }
-
-.footer { background-color: whitesmoke; padding: 15px; margin-top: 15px; text-align: right; border-top: 1px solid #EEEEEE; }
-.footer p { font-size: 11px; margin: 0 }
-
-.table-not-wide { width: inherit;}
-.alert-heading { display: block; font-size: 14px; margin-bottom: 6px; font-weight: bold; }
-
-/* Pretty printing styles. Used with prettify.js.
----------------------------------------------------- */
-.com { color: #93a1a1; }
-.lit { color: #195f91; }
-.pun, .opn, .clo { color: #93a1a1; }
-.fun { color: #dc322f; }
-.str, .atv { color: #D14; }
-.kwd, .linenums .tag { color: #1e347b; }
-.typ, .atn, .dec, .var { color: teal; }
-.pln { color: #48484c; }
-.prettyprint { padding: 8px; background-color: #f7f7f9; border: 1px solid #e1e1e8; }
-.prettyprint.linenums {
- -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
- -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
- box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-}
-ol.linenums { margin: 0 0 0 33px; }
-ol.linenums li { padding-left: 12px; color: #bebec5; line-height: 18px; text-shadow: 0 1px 0 #fff; }
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/images/collapsed.gif
----------------------------------------------------------------------
diff --git a/src/site/resources/images/collapsed.gif b/src/site/resources/images/collapsed.gif
deleted file mode 100644
index f2509c9..0000000
Binary files a/src/site/resources/images/collapsed.gif and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/images/expanded.gif
----------------------------------------------------------------------
diff --git a/src/site/resources/images/expanded.gif b/src/site/resources/images/expanded.gif
deleted file mode 100644
index 02b7462..0000000
Binary files a/src/site/resources/images/expanded.gif and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/images/logos/ls-logo.jpg
----------------------------------------------------------------------
diff --git a/src/site/resources/images/logos/ls-logo.jpg b/src/site/resources/images/logos/ls-logo.jpg
deleted file mode 100644
index 35f2f47..0000000
Binary files a/src/site/resources/images/logos/ls-logo.jpg and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/images/logos/maven-feather.png
----------------------------------------------------------------------
diff --git a/src/site/resources/images/logos/maven-feather.png b/src/site/resources/images/logos/maven-feather.png
deleted file mode 100644
index b5ada83..0000000
Binary files a/src/site/resources/images/logos/maven-feather.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/img/glyphicons-halflings-white.png
----------------------------------------------------------------------
diff --git a/src/site/resources/img/glyphicons-halflings-white.png b/src/site/resources/img/glyphicons-halflings-white.png
deleted file mode 100644
index 3bf6484..0000000
Binary files a/src/site/resources/img/glyphicons-halflings-white.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/img/glyphicons-halflings.png
----------------------------------------------------------------------
diff --git a/src/site/resources/img/glyphicons-halflings.png b/src/site/resources/img/glyphicons-halflings.png
deleted file mode 100644
index a996999..0000000
Binary files a/src/site/resources/img/glyphicons-halflings.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/bootstrap.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/bootstrap.js b/src/site/resources/js/bootstrap.js
deleted file mode 100644
index 7f303eb..0000000
--- a/src/site/resources/js/bootstrap.js
+++ /dev/null
@@ -1,2027 +0,0 @@
-/* ===================================================
- * bootstrap-transition.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#transitions
- * ===================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================== */
-
-
-!function ($) {
-
- $(function () {
-
- "use strict"; // jshint ;_;
-
-
- /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
- * ======================================================= */
-
- $.support.transition = (function () {
-
- var transitionEnd = (function () {
-
- var el = document.createElement('bootstrap')
- , transEndEventNames = {
- 'WebkitTransition' : 'webkitTransitionEnd'
- , 'MozTransition' : 'transitionend'
- , 'OTransition' : 'oTransitionEnd otransitionend'
- , 'transition' : 'transitionend'
- }
- , name
-
- for (name in transEndEventNames){
- if (el.style[name] !== undefined) {
- return transEndEventNames[name]
- }
- }
-
- }())
-
- return transitionEnd && {
- end: transitionEnd
- }
-
- })()
-
- })
-
-}(window.jQuery);/* ==========================================================
- * bootstrap-alert.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#alerts
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* ALERT CLASS DEFINITION
- * ====================== */
-
- var dismiss = '[data-dismiss="alert"]'
- , Alert = function (el) {
- $(el).on('click', dismiss, this.close)
- }
-
- Alert.prototype.close = function (e) {
- var $this = $(this)
- , selector = $this.attr('data-target')
- , $parent
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- $parent = $(selector)
-
- e && e.preventDefault()
-
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
-
- $parent.trigger(e = $.Event('close'))
-
- if (e.isDefaultPrevented()) return
-
- $parent.removeClass('in')
-
- function removeElement() {
- $parent
- .trigger('closed')
- .remove()
- }
-
- $.support.transition && $parent.hasClass('fade') ?
- $parent.on($.support.transition.end, removeElement) :
- removeElement()
- }
-
-
- /* ALERT PLUGIN DEFINITION
- * ======================= */
-
- $.fn.alert = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('alert')
- if (!data) $this.data('alert', (data = new Alert(this)))
- if (typeof option == 'string') data[option].call($this)
- })
- }
-
- $.fn.alert.Constructor = Alert
-
-
- /* ALERT DATA-API
- * ============== */
-
- $(function () {
- $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
- })
-
-}(window.jQuery);/* ============================================================
- * bootstrap-button.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#buttons
- * ============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============================================================ */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* BUTTON PUBLIC CLASS DEFINITION
- * ============================== */
-
- var Button = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.button.defaults, options)
- }
-
- Button.prototype.setState = function (state) {
- var d = 'disabled'
- , $el = this.$element
- , data = $el.data()
- , val = $el.is('input') ? 'val' : 'html'
-
- state = state + 'Text'
- data.resetText || $el.data('resetText', $el[val]())
-
- $el[val](data[state] || this.options[state])
-
- // push to event loop to allow forms to submit
- setTimeout(function () {
- state == 'loadingText' ?
- $el.addClass(d).attr(d, d) :
- $el.removeClass(d).removeAttr(d)
- }, 0)
- }
-
- Button.prototype.toggle = function () {
- var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
-
- $parent && $parent
- .find('.active')
- .removeClass('active')
-
- this.$element.toggleClass('active')
- }
-
-
- /* BUTTON PLUGIN DEFINITION
- * ======================== */
-
- $.fn.button = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('button')
- , options = typeof option == 'object' && option
- if (!data) $this.data('button', (data = new Button(this, options)))
- if (option == 'toggle') data.toggle()
- else if (option) data.setState(option)
- })
- }
-
- $.fn.button.defaults = {
- loadingText: 'loading...'
- }
-
- $.fn.button.Constructor = Button
-
-
- /* BUTTON DATA-API
- * =============== */
-
- $(function () {
- $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
- var $btn = $(e.target)
- if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
- $btn.button('toggle')
- })
- })
-
-}(window.jQuery);/* ==========================================================
- * bootstrap-carousel.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#carousel
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* CAROUSEL CLASS DEFINITION
- * ========================= */
-
- var Carousel = function (element, options) {
- this.$element = $(element)
- this.options = options
- this.options.slide && this.slide(this.options.slide)
- this.options.pause == 'hover' && this.$element
- .on('mouseenter', $.proxy(this.pause, this))
- .on('mouseleave', $.proxy(this.cycle, this))
- }
-
- Carousel.prototype = {
-
- cycle: function (e) {
- if (!e) this.paused = false
- this.options.interval
- && !this.paused
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
- return this
- }
-
- , to: function (pos) {
- var $active = this.$element.find('.item.active')
- , children = $active.parent().children()
- , activePos = children.index($active)
- , that = this
-
- if (pos > (children.length - 1) || pos < 0) return
-
- if (this.sliding) {
- return this.$element.one('slid', function () {
- that.to(pos)
- })
- }
-
- if (activePos == pos) {
- return this.pause().cycle()
- }
-
- return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
- }
-
- , pause: function (e) {
- if (!e) this.paused = true
- if (this.$element.find('.next, .prev').length && $.support.transition.end) {
- this.$element.trigger($.support.transition.end)
- this.cycle()
- }
- clearInterval(this.interval)
- this.interval = null
- return this
- }
-
- , next: function () {
- if (this.sliding) return
- return this.slide('next')
- }
-
- , prev: function () {
- if (this.sliding) return
- return this.slide('prev')
- }
-
- , slide: function (type, next) {
- var $active = this.$element.find('.item.active')
- , $next = next || $active[type]()
- , isCycling = this.interval
- , direction = type == 'next' ? 'left' : 'right'
- , fallback = type == 'next' ? 'first' : 'last'
- , that = this
- , e = $.Event('slide', {
- relatedTarget: $next[0]
- })
-
- this.sliding = true
-
- isCycling && this.pause()
-
- $next = $next.length ? $next : this.$element.find('.item')[fallback]()
-
- if ($next.hasClass('active')) return
-
- if ($.support.transition && this.$element.hasClass('slide')) {
- this.$element.trigger(e)
- if (e.isDefaultPrevented()) return
- $next.addClass(type)
- $next[0].offsetWidth // force reflow
- $active.addClass(direction)
- $next.addClass(direction)
- this.$element.one($.support.transition.end, function () {
- $next.removeClass([type, direction].join(' ')).addClass('active')
- $active.removeClass(['active', direction].join(' '))
- that.sliding = false
- setTimeout(function () { that.$element.trigger('slid') }, 0)
- })
- } else {
- this.$element.trigger(e)
- if (e.isDefaultPrevented()) return
- $active.removeClass('active')
- $next.addClass('active')
- this.sliding = false
- this.$element.trigger('slid')
- }
-
- isCycling && this.cycle()
-
- return this
- }
-
- }
-
-
- /* CAROUSEL PLUGIN DEFINITION
- * ========================== */
-
- $.fn.carousel = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('carousel')
- , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
- , action = typeof option == 'string' ? option : options.slide
- if (!data) $this.data('carousel', (data = new Carousel(this, options)))
- if (typeof option == 'number') data.to(option)
- else if (action) data[action]()
- else if (options.interval) data.cycle()
- })
- }
-
- $.fn.carousel.defaults = {
- interval: 5000
- , pause: 'hover'
- }
-
- $.fn.carousel.Constructor = Carousel
-
-
- /* CAROUSEL DATA-API
- * ================= */
-
- $(function () {
- $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
- var $this = $(this), href
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
- $target.carousel(options)
- e.preventDefault()
- })
- })
-
-}(window.jQuery);/* =============================================================
- * bootstrap-collapse.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#collapse
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============================================================ */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* COLLAPSE PUBLIC CLASS DEFINITION
- * ================================ */
-
- var Collapse = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.collapse.defaults, options)
-
- if (this.options.parent) {
- this.$parent = $(this.options.parent)
- }
-
- this.options.toggle && this.toggle()
- }
-
- Collapse.prototype = {
-
- constructor: Collapse
-
- , dimension: function () {
- var hasWidth = this.$element.hasClass('width')
- return hasWidth ? 'width' : 'height'
- }
-
- , show: function () {
- var dimension
- , scroll
- , actives
- , hasData
-
- if (this.transitioning) return
-
- dimension = this.dimension()
- scroll = $.camelCase(['scroll', dimension].join('-'))
- actives = this.$parent && this.$parent.find('> .accordion-group > .in')
-
- if (actives && actives.length) {
- hasData = actives.data('collapse')
- if (hasData && hasData.transitioning) return
- actives.collapse('hide')
- hasData || actives.data('collapse', null)
- }
-
- this.$element[dimension](0)
- this.transition('addClass', $.Event('show'), 'shown')
- $.support.transition && this.$element[dimension](this.$element[0][scroll])
- }
-
- , hide: function () {
- var dimension
- if (this.transitioning) return
- dimension = this.dimension()
- this.reset(this.$element[dimension]())
- this.transition('removeClass', $.Event('hide'), 'hidden')
- this.$element[dimension](0)
- }
-
- , reset: function (size) {
- var dimension = this.dimension()
-
- this.$element
- .removeClass('collapse')
- [dimension](size || 'auto')
- [0].offsetWidth
-
- this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
-
- return this
- }
-
- , transition: function (method, startEvent, completeEvent) {
- var that = this
- , complete = function () {
- if (startEvent.type == 'show') that.reset()
- that.transitioning = 0
- that.$element.trigger(completeEvent)
- }
-
- this.$element.trigger(startEvent)
-
- if (startEvent.isDefaultPrevented()) return
-
- this.transitioning = 1
-
- this.$element[method]('in')
-
- $.support.transition && this.$element.hasClass('collapse') ?
- this.$element.one($.support.transition.end, complete) :
- complete()
- }
-
- , toggle: function () {
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
- }
-
- }
-
-
- /* COLLAPSIBLE PLUGIN DEFINITION
- * ============================== */
-
- $.fn.collapse = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('collapse')
- , options = typeof option == 'object' && option
- if (!data) $this.data('collapse', (data = new Collapse(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.collapse.defaults = {
- toggle: true
- }
-
- $.fn.collapse.Constructor = Collapse
-
-
- /* COLLAPSIBLE DATA-API
- * ==================== */
-
- $(function () {
- $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
- var $this = $(this), href
- , target = $this.attr('data-target')
- || e.preventDefault()
- || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
- , option = $(target).data('collapse') ? 'toggle' : $this.data()
- $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
- $(target).collapse(option)
- })
- })
-
-}(window.jQuery);/* ============================================================
- * bootstrap-dropdown.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#dropdowns
- * ============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============================================================ */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* DROPDOWN CLASS DEFINITION
- * ========================= */
-
- var toggle = '[data-toggle=dropdown]'
- , Dropdown = function (element) {
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
- $('html').on('click.dropdown.data-api', function () {
- $el.parent().removeClass('open')
- })
- }
-
- Dropdown.prototype = {
-
- constructor: Dropdown
-
- , toggle: function (e) {
- var $this = $(this)
- , $parent
- , isActive
-
- if ($this.is('.disabled, :disabled')) return
-
- $parent = getParent($this)
-
- isActive = $parent.hasClass('open')
-
- clearMenus()
-
- if (!isActive) {
- $parent.toggleClass('open')
- $this.focus()
- }
-
- return false
- }
-
- , keydown: function (e) {
- var $this
- , $items
- , $active
- , $parent
- , isActive
- , index
-
- if (!/(38|40|27)/.test(e.keyCode)) return
-
- $this = $(this)
-
- e.preventDefault()
- e.stopPropagation()
-
- if ($this.is('.disabled, :disabled')) return
-
- $parent = getParent($this)
-
- isActive = $parent.hasClass('open')
-
- if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
-
- $items = $('[role=menu] li:not(.divider) a', $parent)
-
- if (!$items.length) return
-
- index = $items.index($items.filter(':focus'))
-
- if (e.keyCode == 38 && index > 0) index-- // up
- if (e.keyCode == 40 && index < $items.length - 1) index++ // down
- if (!~index) index = 0
-
- $items
- .eq(index)
- .focus()
- }
-
- }
-
- function clearMenus() {
- getParent($(toggle))
- .removeClass('open')
- }
-
- function getParent($this) {
- var selector = $this.attr('data-target')
- , $parent
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- $parent = $(selector)
- $parent.length || ($parent = $this.parent())
-
- return $parent
- }
-
-
- /* DROPDOWN PLUGIN DEFINITION
- * ========================== */
-
- $.fn.dropdown = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('dropdown')
- if (!data) $this.data('dropdown', (data = new Dropdown(this)))
- if (typeof option == 'string') data[option].call($this)
- })
- }
-
- $.fn.dropdown.Constructor = Dropdown
-
-
- /* APPLY TO STANDARD DROPDOWN ELEMENTS
- * =================================== */
-
- $(function () {
- $('html')
- .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
- $('body')
- .on('click.dropdown touchstart.dropdown.data-api', '.dropdown', function (e) { e.stopPropagation() })
- .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
- .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
- })
-
-}(window.jQuery);/* =========================================================
- * bootstrap-modal.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#modals
- * =========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================= */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* MODAL CLASS DEFINITION
- * ====================== */
-
- var Modal = function (element, options) {
- this.options = options
- this.$element = $(element)
- .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
- this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
- }
-
- Modal.prototype = {
-
- constructor: Modal
-
- , toggle: function () {
- return this[!this.isShown ? 'show' : 'hide']()
- }
-
- , show: function () {
- var that = this
- , e = $.Event('show')
-
- this.$element.trigger(e)
-
- if (this.isShown || e.isDefaultPrevented()) return
-
- $('body').addClass('modal-open')
-
- this.isShown = true
-
- this.escape()
-
- this.backdrop(function () {
- var transition = $.support.transition && that.$element.hasClass('fade')
-
- if (!that.$element.parent().length) {
- that.$element.appendTo(document.body) //don't move modals dom position
- }
-
- that.$element
- .show()
-
- if (transition) {
- that.$element[0].offsetWidth // force reflow
- }
-
- that.$element
- .addClass('in')
- .attr('aria-hidden', false)
- .focus()
-
- that.enforceFocus()
-
- transition ?
- that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
- that.$element.trigger('shown')
-
- })
- }
-
- , hide: function (e) {
- e && e.preventDefault()
-
- var that = this
-
- e = $.Event('hide')
-
- this.$element.trigger(e)
-
- if (!this.isShown || e.isDefaultPrevented()) return
-
- this.isShown = false
-
- $('body').removeClass('modal-open')
-
- this.escape()
-
- $(document).off('focusin.modal')
-
- this.$element
- .removeClass('in')
- .attr('aria-hidden', true)
-
- $.support.transition && this.$element.hasClass('fade') ?
- this.hideWithTransition() :
- this.hideModal()
- }
-
- , enforceFocus: function () {
- var that = this
- $(document).on('focusin.modal', function (e) {
- if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
- that.$element.focus()
- }
- })
- }
-
- , escape: function () {
- var that = this
- if (this.isShown && this.options.keyboard) {
- this.$element.on('keyup.dismiss.modal', function ( e ) {
- e.which == 27 && that.hide()
- })
- } else if (!this.isShown) {
- this.$element.off('keyup.dismiss.modal')
- }
- }
-
- , hideWithTransition: function () {
- var that = this
- , timeout = setTimeout(function () {
- that.$element.off($.support.transition.end)
- that.hideModal()
- }, 500)
-
- this.$element.one($.support.transition.end, function () {
- clearTimeout(timeout)
- that.hideModal()
- })
- }
-
- , hideModal: function (that) {
- this.$element
- .hide()
- .trigger('hidden')
-
- this.backdrop()
- }
-
- , removeBackdrop: function () {
- this.$backdrop.remove()
- this.$backdrop = null
- }
-
- , backdrop: function (callback) {
- var that = this
- , animate = this.$element.hasClass('fade') ? 'fade' : ''
-
- if (this.isShown && this.options.backdrop) {
- var doAnimate = $.support.transition && animate
-
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
- .appendTo(document.body)
-
- if (this.options.backdrop != 'static') {
- this.$backdrop.click($.proxy(this.hide, this))
- }
-
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
-
- this.$backdrop.addClass('in')
-
- doAnimate ?
- this.$backdrop.one($.support.transition.end, callback) :
- callback()
-
- } else if (!this.isShown && this.$backdrop) {
- this.$backdrop.removeClass('in')
-
- $.support.transition && this.$element.hasClass('fade')?
- this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
- this.removeBackdrop()
-
- } else if (callback) {
- callback()
- }
- }
- }
-
-
- /* MODAL PLUGIN DEFINITION
- * ======================= */
-
- $.fn.modal = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('modal')
- , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
- if (!data) $this.data('modal', (data = new Modal(this, options)))
- if (typeof option == 'string') data[option]()
- else if (options.show) data.show()
- })
- }
-
- $.fn.modal.defaults = {
- backdrop: true
- , keyboard: true
- , show: true
- }
-
- $.fn.modal.Constructor = Modal
-
-
- /* MODAL DATA-API
- * ============== */
-
- $(function () {
- $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
- var $this = $(this)
- , href = $this.attr('href')
- , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
- , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
-
- e.preventDefault()
-
- $target
- .modal(option)
- .one('hide', function () {
- $this.focus()
- })
- })
- })
-
-}(window.jQuery);/* ===========================================================
- * bootstrap-tooltip.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#tooltips
- * Inspired by the original jQuery.tipsy by Jason Frame
- * ===========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* TOOLTIP PUBLIC CLASS DEFINITION
- * =============================== */
-
- var Tooltip = function (element, options) {
- this.init('tooltip', element, options)
- }
-
- Tooltip.prototype = {
-
- constructor: Tooltip
-
- , init: function (type, element, options) {
- var eventIn
- , eventOut
-
- this.type = type
- this.$element = $(element)
- this.options = this.getOptions(options)
- this.enabled = true
-
- if (this.options.trigger == 'click') {
- this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
- } else if (this.options.trigger != 'manual') {
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
- this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
- this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
- }
-
- this.options.selector ?
- (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
- this.fixTitle()
- }
-
- , getOptions: function (options) {
- options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
-
- if (options.delay && typeof options.delay == 'number') {
- options.delay = {
- show: options.delay
- , hide: options.delay
- }
- }
-
- return options
- }
-
- , enter: function (e) {
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
-
- if (!self.options.delay || !self.options.delay.show) return self.show()
-
- clearTimeout(this.timeout)
- self.hoverState = 'in'
- this.timeout = setTimeout(function() {
- if (self.hoverState == 'in') self.show()
- }, self.options.delay.show)
- }
-
- , leave: function (e) {
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
-
- if (this.timeout) clearTimeout(this.timeout)
- if (!self.options.delay || !self.options.delay.hide) return self.hide()
-
- self.hoverState = 'out'
- this.timeout = setTimeout(function() {
- if (self.hoverState == 'out') self.hide()
- }, self.options.delay.hide)
- }
-
- , show: function () {
- var $tip
- , inside
- , pos
- , actualWidth
- , actualHeight
- , placement
- , tp
-
- if (this.hasContent() && this.enabled) {
- $tip = this.tip()
- this.setContent()
-
- if (this.options.animation) {
- $tip.addClass('fade')
- }
-
- placement = typeof this.options.placement == 'function' ?
- this.options.placement.call(this, $tip[0], this.$element[0]) :
- this.options.placement
-
- inside = /in/.test(placement)
-
- $tip
- .remove()
- .css({ top: 0, left: 0, display: 'block' })
- .appendTo(inside ? this.$element : document.body)
-
- pos = this.getPosition(inside)
-
- actualWidth = $tip[0].offsetWidth
- actualHeight = $tip[0].offsetHeight
-
- switch (inside ? placement.split(' ')[1] : placement) {
- case 'bottom':
- tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
- break
- case 'top':
- tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
- break
- case 'left':
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
- break
- case 'right':
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
- break
- }
-
- $tip
- .css(tp)
- .addClass(placement)
- .addClass('in')
- }
- }
-
- , setContent: function () {
- var $tip = this.tip()
- , title = this.getTitle()
-
- $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
- $tip.removeClass('fade in top bottom left right')
- }
-
- , hide: function () {
- var that = this
- , $tip = this.tip()
-
- $tip.removeClass('in')
-
- function removeWithAnimation() {
- var timeout = setTimeout(function () {
- $tip.off($.support.transition.end).remove()
- }, 500)
-
- $tip.one($.support.transition.end, function () {
- clearTimeout(timeout)
- $tip.remove()
- })
- }
-
- $.support.transition && this.$tip.hasClass('fade') ?
- removeWithAnimation() :
- $tip.remove()
-
- return this
- }
-
- , fixTitle: function () {
- var $e = this.$element
- if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
- $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
- }
- }
-
- , hasContent: function () {
- return this.getTitle()
- }
-
- , getPosition: function (inside) {
- return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
- width: this.$element[0].offsetWidth
- , height: this.$element[0].offsetHeight
- })
- }
-
- , getTitle: function () {
- var title
- , $e = this.$element
- , o = this.options
-
- title = $e.attr('data-original-title')
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
-
- return title
- }
-
- , tip: function () {
- return this.$tip = this.$tip || $(this.options.template)
- }
-
- , validate: function () {
- if (!this.$element[0].parentNode) {
- this.hide()
- this.$element = null
- this.options = null
- }
- }
-
- , enable: function () {
- this.enabled = true
- }
-
- , disable: function () {
- this.enabled = false
- }
-
- , toggleEnabled: function () {
- this.enabled = !this.enabled
- }
-
- , toggle: function () {
- this[this.tip().hasClass('in') ? 'hide' : 'show']()
- }
-
- , destroy: function () {
- this.hide().$element.off('.' + this.type).removeData(this.type)
- }
-
- }
-
-
- /* TOOLTIP PLUGIN DEFINITION
- * ========================= */
-
- $.fn.tooltip = function ( option ) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('tooltip')
- , options = typeof option == 'object' && option
- if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.tooltip.Constructor = Tooltip
-
- $.fn.tooltip.defaults = {
- animation: true
- , placement: 'top'
- , selector: false
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
- , trigger: 'hover'
- , title: ''
- , delay: 0
- , html: true
- }
-
-}(window.jQuery);
-/* ===========================================================
- * bootstrap-popover.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#popovers
- * ===========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * =========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* POPOVER PUBLIC CLASS DEFINITION
- * =============================== */
-
- var Popover = function (element, options) {
- this.init('popover', element, options)
- }
-
-
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
- ========================================== */
-
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
-
- constructor: Popover
-
- , setContent: function () {
- var $tip = this.tip()
- , title = this.getTitle()
- , content = this.getContent()
-
- $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
- $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
-
- $tip.removeClass('fade top bottom left right in')
- }
-
- , hasContent: function () {
- return this.getTitle() || this.getContent()
- }
-
- , getContent: function () {
- var content
- , $e = this.$element
- , o = this.options
-
- content = $e.attr('data-content')
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
-
- return content
- }
-
- , tip: function () {
- if (!this.$tip) {
- this.$tip = $(this.options.template)
- }
- return this.$tip
- }
-
- , destroy: function () {
- this.hide().$element.off('.' + this.type).removeData(this.type)
- }
-
- })
-
-
- /* POPOVER PLUGIN DEFINITION
- * ======================= */
-
- $.fn.popover = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('popover')
- , options = typeof option == 'object' && option
- if (!data) $this.data('popover', (data = new Popover(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.popover.Constructor = Popover
-
- $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
- placement: 'right'
- , trigger: 'click'
- , content: ''
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
- })
-
-}(window.jQuery);/* =============================================================
- * bootstrap-scrollspy.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#scrollspy
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* SCROLLSPY CLASS DEFINITION
- * ========================== */
-
- function ScrollSpy(element, options) {
- var process = $.proxy(this.process, this)
- , $element = $(element).is('body') ? $(window) : $(element)
- , href
- this.options = $.extend({}, $.fn.scrollspy.defaults, options)
- this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
- this.selector = (this.options.target
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- || '') + ' .nav li > a'
- this.$body = $('body')
- this.refresh()
- this.process()
- }
-
- ScrollSpy.prototype = {
-
- constructor: ScrollSpy
-
- , refresh: function () {
- var self = this
- , $targets
-
- this.offsets = $([])
- this.targets = $([])
-
- $targets = this.$body
- .find(this.selector)
- .map(function () {
- var $el = $(this)
- , href = $el.data('target') || $el.attr('href')
- , $href = /^#\w/.test(href) && $(href)
- return ( $href
- && $href.length
- && [[ $href.position().top, href ]] ) || null
- })
- .sort(function (a, b) { return a[0] - b[0] })
- .each(function () {
- self.offsets.push(this[0])
- self.targets.push(this[1])
- })
- }
-
- , process: function () {
- var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
- , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
- , maxScroll = scrollHeight - this.$scrollElement.height()
- , offsets = this.offsets
- , targets = this.targets
- , activeTarget = this.activeTarget
- , i
-
- if (scrollTop >= maxScroll) {
- return activeTarget != (i = targets.last()[0])
- && this.activate ( i )
- }
-
- for (i = offsets.length; i--;) {
- activeTarget != targets[i]
- && scrollTop >= offsets[i]
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
- && this.activate( targets[i] )
- }
- }
-
- , activate: function (target) {
- var active
- , selector
-
- this.activeTarget = target
-
- $(this.selector)
- .parent('.active')
- .removeClass('active')
-
- selector = this.selector
- + '[data-target="' + target + '"],'
- + this.selector + '[href="' + target + '"]'
-
- active = $(selector)
- .parent('li')
- .addClass('active')
-
- if (active.parent('.dropdown-menu').length) {
- active = active.closest('li.dropdown').addClass('active')
- }
-
- active.trigger('activate')
- }
-
- }
-
-
- /* SCROLLSPY PLUGIN DEFINITION
- * =========================== */
-
- $.fn.scrollspy = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('scrollspy')
- , options = typeof option == 'object' && option
- if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.scrollspy.Constructor = ScrollSpy
-
- $.fn.scrollspy.defaults = {
- offset: 10
- }
-
-
- /* SCROLLSPY DATA-API
- * ================== */
-
- $(window).on('load', function () {
- $('[data-spy="scroll"]').each(function () {
- var $spy = $(this)
- $spy.scrollspy($spy.data())
- })
- })
-
-}(window.jQuery);/* ========================================================
- * bootstrap-tab.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#tabs
- * ========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ======================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* TAB CLASS DEFINITION
- * ==================== */
-
- var Tab = function (element) {
- this.element = $(element)
- }
-
- Tab.prototype = {
-
- constructor: Tab
-
- , show: function () {
- var $this = this.element
- , $ul = $this.closest('ul:not(.dropdown-menu)')
- , selector = $this.attr('data-target')
- , previous
- , $target
- , e
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- if ( $this.parent('li').hasClass('active') ) return
-
- previous = $ul.find('.active a').last()[0]
-
- e = $.Event('show', {
- relatedTarget: previous
- })
-
- $this.trigger(e)
-
- if (e.isDefaultPrevented()) return
-
- $target = $(selector)
-
- this.activate($this.parent('li'), $ul)
- this.activate($target, $target.parent(), function () {
- $this.trigger({
- type: 'shown'
- , relatedTarget: previous
- })
- })
- }
-
- , activate: function ( element, container, callback) {
- var $active = container.find('> .active')
- , transition = callback
- && $.support.transition
- && $active.hasClass('fade')
-
- function next() {
- $active
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
-
- element.addClass('active')
-
- if (transition) {
- element[0].offsetWidth // reflow for transition
- element.addClass('in')
- } else {
- element.removeClass('fade')
- }
-
- if ( element.parent('.dropdown-menu') ) {
- element.closest('li.dropdown').addClass('active')
- }
-
- callback && callback()
- }
-
- transition ?
- $active.one($.support.transition.end, next) :
- next()
-
- $active.removeClass('in')
- }
- }
-
-
- /* TAB PLUGIN DEFINITION
- * ===================== */
-
- $.fn.tab = function ( option ) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('tab')
- if (!data) $this.data('tab', (data = new Tab(this)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.tab.Constructor = Tab
-
-
- /* TAB DATA-API
- * ============ */
-
- $(function () {
- $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
- e.preventDefault()
- $(this).tab('show')
- })
- })
-
-}(window.jQuery);/* =============================================================
- * bootstrap-typeahead.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#typeahead
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============================================================ */
-
-
-!function($){
-
- "use strict"; // jshint ;_;
-
-
- /* TYPEAHEAD PUBLIC CLASS DEFINITION
- * ================================= */
-
- var Typeahead = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.typeahead.defaults, options)
- this.matcher = this.options.matcher || this.matcher
- this.sorter = this.options.sorter || this.sorter
- this.highlighter = this.options.highlighter || this.highlighter
- this.updater = this.options.updater || this.updater
- this.$menu = $(this.options.menu).appendTo('body')
- this.source = this.options.source
- this.shown = false
- this.listen()
- }
-
- Typeahead.prototype = {
-
- constructor: Typeahead
-
- , select: function () {
- var val = this.$menu.find('.active').attr('data-value')
- this.$element
- .val(this.updater(val))
- .change()
- return this.hide()
- }
-
- , updater: function (item) {
- return item
- }
-
- , show: function () {
- var pos = $.extend({}, this.$element.offset(), {
- height: this.$element[0].offsetHeight
- })
-
- this.$menu.css({
- top: pos.top + pos.height
- , left: pos.left
- })
-
- this.$menu.show()
- this.shown = true
- return this
- }
-
- , hide: function () {
- this.$menu.hide()
- this.shown = false
- return this
- }
-
- , lookup: function (event) {
- var items
-
- this.query = this.$element.val()
-
- if (!this.query || this.query.length < this.options.minLength) {
- return this.shown ? this.hide() : this
- }
-
- items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
-
- return items ? this.process(items) : this
- }
-
- , process: function (items) {
- var that = this
-
- items = $.grep(items, function (item) {
- return that.matcher(item)
- })
-
- items = this.sorter(items)
-
- if (!items.length) {
- return this.shown ? this.hide() : this
- }
-
- return this.render(items.slice(0, this.options.items)).show()
- }
-
- , matcher: function (item) {
- return ~item.toLowerCase().indexOf(this.query.toLowerCase())
- }
-
- , sorter: function (items) {
- var beginswith = []
- , caseSensitive = []
- , caseInsensitive = []
- , item
-
- while (item = items.shift()) {
- if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
- else if (~item.indexOf(this.query)) caseSensitive.push(item)
- else caseInsensitive.push(item)
- }
-
- return beginswith.concat(caseSensitive, caseInsensitive)
- }
-
- , highlighter: function (item) {
- var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
- return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
- return '<strong>' + match + '</strong>'
- })
- }
-
- , render: function (items) {
- var that = this
-
- items = $(items).map(function (i, item) {
- i = $(that.options.item).attr('data-value', item)
- i.find('a').html(that.highlighter(item))
- return i[0]
- })
-
- items.first().addClass('active')
- this.$menu.html(items)
- return this
- }
-
- , next: function (event) {
- var active = this.$menu.find('.active').removeClass('active')
- , next = active.next()
-
- if (!next.length) {
- next = $(this.$menu.find('li')[0])
- }
-
- next.addClass('active')
- }
-
- , prev: function (event) {
- var active = this.$menu.find('.active').removeClass('active')
- , prev = active.prev()
-
- if (!prev.length) {
- prev = this.$menu.find('li').last()
- }
-
- prev.addClass('active')
- }
-
- , listen: function () {
- this.$element
- .on('blur', $.proxy(this.blur, this))
- .on('keypress', $.proxy(this.keypress, this))
- .on('keyup', $.proxy(this.keyup, this))
-
- if ($.browser.webkit || $.browser.msie) {
- this.$element.on('keydown', $.proxy(this.keydown, this))
- }
-
- this.$menu
- .on('click', $.proxy(this.click, this))
- .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
- }
-
- , move: function (e) {
- if (!this.shown) return
-
- switch(e.keyCode) {
- case 9: // tab
- case 13: // enter
- case 27: // escape
- e.preventDefault()
- break
-
- case 38: // up arrow
- e.preventDefault()
- this.prev()
- break
-
- case 40: // down arrow
- e.preventDefault()
- this.next()
- break
- }
-
- e.stopPropagation()
- }
-
- , keydown: function (e) {
- this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
- this.move(e)
- }
-
- , keypress: function (e) {
- if (this.suppressKeyPressRepeat) return
- this.move(e)
- }
-
- , keyup: function (e) {
- switch(e.keyCode) {
- case 40: // down arrow
- case 38: // up arrow
- break
-
- case 9: // tab
- case 13: // enter
- if (!this.shown) return
- this.select()
- break
-
- case 27: // escape
- if (!this.shown) return
- this.hide()
- break
-
- default:
- this.lookup()
- }
-
- e.stopPropagation()
- e.preventDefault()
- }
-
- , blur: function (e) {
- var that = this
- setTimeout(function () { that.hide() }, 150)
- }
-
- , click: function (e) {
- e.stopPropagation()
- e.preventDefault()
- this.select()
- }
-
- , mouseenter: function (e) {
- this.$menu.find('.active').removeClass('active')
- $(e.currentTarget).addClass('active')
- }
-
- }
-
-
- /* TYPEAHEAD PLUGIN DEFINITION
- * =========================== */
-
- $.fn.typeahead = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('typeahead')
- , options = typeof option == 'object' && option
- if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.typeahead.defaults = {
- source: []
- , items: 8
- , menu: '<ul class="typeahead dropdown-menu"></ul>'
- , item: '<li><a href="#"></a></li>'
- , minLength: 1
- }
-
- $.fn.typeahead.Constructor = Typeahead
-
-
- /* TYPEAHEAD DATA-API
- * ================== */
-
- $(function () {
- $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
- var $this = $(this)
- if ($this.data('typeahead')) return
- e.preventDefault()
- $this.typeahead($this.data())
- })
- })
-
-}(window.jQuery);
-/* ==========================================================
- * bootstrap-affix.js v2.1.0
- * http://twitter.github.com/bootstrap/javascript.html#affix
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* AFFIX CLASS DEFINITION
- * ====================== */
-
- var Affix = function (element, options) {
- this.options = $.extend({}, $.fn.affix.defaults, options)
- this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
- this.$element = $(element)
- this.checkPosition()
- }
-
- Affix.prototype.checkPosition = function () {
- if (!this.$element.is(':visible')) return
-
- var scrollHeight = $(document).height()
- , scrollTop = this.$window.scrollTop()
- , position = this.$element.offset()
- , offset = this.options.offset
- , offsetBottom = offset.bottom
- , offsetTop = offset.top
- , reset = 'affix affix-top affix-bottom'
- , affix
-
- if (typeof offset != 'object') offsetBottom = offsetTop = offset
- if (typeof offsetTop == 'function') offsetTop = offset.top()
- if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
-
- affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
- false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
- 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
- 'top' : false
-
- if (this.affixed === affix) return
-
- this.affixed = affix
- this.unpin = affix == 'bottom' ? position.top - scrollTop : null
-
- this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
- }
-
-
- /* AFFIX PLUGIN DEFINITION
- * ======================= */
-
- $.fn.affix = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('affix')
- , options = typeof option == 'object' && option
- if (!data) $this.data('affix', (data = new Affix(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.affix.Constructor = Affix
-
- $.fn.affix.defaults = {
- offset: 0
- }
-
-
- /* AFFIX DATA-API
- * ============== */
-
- $(window).on('load', function () {
- $('[data-spy="affix"]').each(function () {
- var $spy = $(this)
- , data = $spy.data()
-
- data.offset = data.offset || {}
-
- data.offsetBottom && (data.offset.bottom = data.offsetBottom)
- data.offsetTop && (data.offset.top = data.offsetTop)
-
- $spy.affix(data)
- })
- })
-
-
-}(window.jQuery);
\ No newline at end of file
[05/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/filters/LoggerFilterStringMatchTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/filters/LoggerFilterStringMatchTest.php b/src/test/php/filters/LoggerFilterStringMatchTest.php
deleted file mode 100644
index 366e685..0000000
--- a/src/test/php/filters/LoggerFilterStringMatchTest.php
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage filters
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group filters
- */
-class LoggerFilterStringMatchTest extends PHPUnit_Framework_TestCase {
-
- public function testDecideAccept() {
- $filter = new LoggerFilterStringMatch();
- $filter->setAcceptOnMatch("true");
- $filter->setStringToMatch("testmessage");
-
- $eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventError2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "xyz");
- $eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventDebug2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "xyz");
- $eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
- $eventWarn2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "xyz");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, LoggerFilter::ACCEPT);
-
- $result = $filter->decide($eventError2);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, LoggerFilter::ACCEPT);
-
- $result = $filter->decide($eventDebug2);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, LoggerFilter::ACCEPT);
-
- $result = $filter->decide($eventWarn2);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
- }
-
- public function testDecideDeny() {
- $filter = new LoggerFilterStringMatch();
- $filter->setAcceptOnMatch("false");
- $filter->setStringToMatch("testmessage");
-
- $eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventError2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "xyz");
- $eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventDebug2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "xyz");
- $eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
- $eventWarn2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "xyz");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, LoggerFilter::DENY);
-
- $result = $filter->decide($eventError2);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, LoggerFilter::DENY);
-
- $result = $filter->decide($eventDebug2);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, LoggerFilter::DENY);
-
- $result = $filter->decide($eventWarn2);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
- }
-
- public function testDecideNullMessage() {
- $filter = new LoggerFilterStringMatch();
- $filter->setAcceptOnMatch("false");
- $filter->setStringToMatch("testmessage");
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), null);
-
- $result = $filter->decide($event);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
- }
-
- public function testDecideNullMatch() {
- $filter = new LoggerFilterStringMatch();
- $filter->setAcceptOnMatch("false");
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $result = $filter->decide($event);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/helpers/LoggerOptionConverterTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/helpers/LoggerOptionConverterTest.php b/src/test/php/helpers/LoggerOptionConverterTest.php
deleted file mode 100644
index 3f64321..0000000
--- a/src/test/php/helpers/LoggerOptionConverterTest.php
+++ /dev/null
@@ -1,147 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage helpers
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-define('MY_CONSTANT_CONSTANT', 'DEFINE');
-define('MY_CONSTANT_CONSTANT_OTHER', 'DEFINE_OTHER');
-
-/**
- * @group helpers
- */
-class LoggerOptionConverterTest extends PHPUnit_Framework_TestCase {
-
- public function testToBoolean() {
- self::assertTrue(LoggerOptionConverter::toBooleanEx(1));
- self::assertTrue(LoggerOptionConverter::toBooleanEx("1"));
- self::assertTrue(LoggerOptionConverter::toBooleanEx(true));
- self::assertTrue(LoggerOptionConverter::toBooleanEx("true"));
- self::assertTrue(LoggerOptionConverter::toBooleanEx("on"));
- self::assertTrue(LoggerOptionConverter::toBooleanEx("yes"));
-
- self::assertFalse(LoggerOptionConverter::toBooleanEx(0));
- self::assertFalse(LoggerOptionConverter::toBooleanEx("0"));
- self::assertFalse(LoggerOptionConverter::toBooleanEx(false));
- self::assertFalse(LoggerOptionConverter::toBooleanEx("false"));
- self::assertFalse(LoggerOptionConverter::toBooleanEx("off"));
- self::assertFalse(LoggerOptionConverter::toBooleanEx("no"));
- }
-
- /**
- * Test fail on NULL.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value [NULL] cannot be converted to boolean.
- */
- public function testToBooleanFailure1() {
- LoggerOptionConverter::toBooleanEx(null);
- }
-
- /**
- * Test fail on invalid string.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value ['foo'] cannot be converted to boolean.
- */
- public function testToBooleanFailure2() {
- LoggerOptionConverter::toBooleanEx('foo');
- }
-
- public function testToInteger() {
- self::assertSame(1, LoggerOptionConverter::toIntegerEx('1'));
- self::assertSame(1, LoggerOptionConverter::toIntegerEx(1));
- self::assertSame(0, LoggerOptionConverter::toIntegerEx('0'));
- self::assertSame(0, LoggerOptionConverter::toIntegerEx(0));
- self::assertSame(-1, LoggerOptionConverter::toIntegerEx('-1'));
- self::assertSame(-1, LoggerOptionConverter::toIntegerEx(-1));
- }
-
- /**
- * Test fail on NULL.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value [NULL] cannot be converted to integer.
- */
- public function testToIntegerFailure1() {
- LoggerOptionConverter::toIntegerEx(null);
- }
-
- /**
- * Test fail on empty string.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value [''] cannot be converted to integer.
- */
- public function testToIntegerFailure2() {
- LoggerOptionConverter::toIntegerEx('');
- }
-
- /**
- * Test fail on invalid string.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value ['foo'] cannot be converted to integer.
- */
- public function testToIntegerFailure3() {
- LoggerOptionConverter::toIntegerEx('foo');
- }
-
- /**
- * Test fail on boolean.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value [true] cannot be converted to integer.
- */
- public function testToIntegerFailure4() {
- LoggerOptionConverter::toIntegerEx(true);
- }
-
- /**
- * Test fail on boolean.
- * @expectedException LoggerException
- * @expectedExceptionMessage Given value [false] cannot be converted to integer.
- */
- public function testToIntegerFailure5() {
- LoggerOptionConverter::toIntegerEx(false);
- }
-
- public function testSubstituteConstants() {
- define('OTHER_CONSTANT', 'OTHER');
- define('MY_CONSTANT', 'TEST');
- define('NEXT_CONSTANT', 'NEXT');
-
- $result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT}.');
- self::assertEquals('Value of key is TEST.', $result);
-
- $result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT} or ${OTHER_CONSTANT}.');
- self::assertEquals('Value of key is TEST or OTHER.', $result);
-
- $result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT_CONSTANT}.');
- self::assertEquals('Value of key is DEFINE.', $result);
-
- $result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT_CONSTANT} or ${MY_CONSTANT_CONSTANT_OTHER}.');
- self::assertEquals('Value of key is DEFINE or DEFINE_OTHER.', $result);
- }
-
- public function testActualSubstituteConstants() {
- $a = new LoggerAppenderFile();
- $a->setFile('${PHPUNIT_TEMP_DIR}/log.txt');
- $actual = $a->getFile();
- $expected = PHPUNIT_TEMP_DIR . '/log.txt';
- self::assertSame($expected, $actual);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/helpers/LoggerPatternParserTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/helpers/LoggerPatternParserTest.php b/src/test/php/helpers/LoggerPatternParserTest.php
deleted file mode 100644
index d0f68ef..0000000
--- a/src/test/php/helpers/LoggerPatternParserTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage helpers
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group helpers
- *
- * TODO: Should also test complex patterns like: "%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n"
- */
-class LoggerPatternParserTest extends PHPUnit_Framework_TestCase {
-
- public function testErrorLayout() {
-// $event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-// $expected = '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();
-
-// $actual = '';
-// $c->format($actual, $event);
-// self::assertEquals($expected, $actual);
-
- }
-
- 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/helpers/LoggerUtilsTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/helpers/LoggerUtilsTest.php b/src/test/php/helpers/LoggerUtilsTest.php
deleted file mode 100644
index 5a473ba..0000000
--- a/src/test/php/helpers/LoggerUtilsTest.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage helpers
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group helpers
- */
-class LoggerUtilsTest extends PHPUnit_Framework_TestCase {
-
- public function testShorten() {
- $name = 'org\\apache\\logging\\log4php\\Foo';
-
- $actual = LoggerUtils::shortenClassName($name, null);
- self::assertSame($name, $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 0);
- self::assertSame('Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 5);
- self::assertSame('o\\a\\l\\l\\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 16);
- self::assertSame('o\\a\\l\\l\\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 17);
- self::assertSame('o\\a\\l\\log4php\\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 25);
- self::assertSame('o\\a\\logging\\log4php\\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 28);
- self::assertSame('o\\apache\\logging\\log4php\\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 30);
- self::assertSame('org\\apache\\logging\\log4php\\Foo', $actual);
- }
-
- /** Dot separated notation must be supported for legacy reasons. */
- public function testShortenWithDots() {
- $name = 'org.apache.logging.log4php.Foo';
-
- $actual = LoggerUtils::shortenClassName($name, null);
- self::assertSame($name, $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 0);
- self::assertSame('Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 5);
- self::assertSame('o\a\l\l\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 16);
- self::assertSame('o\a\l\l\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 17);
- self::assertSame('o\a\l\log4php\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 25);
- self::assertSame('o\a\logging\log4php\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 28);
- self::assertSame('o\apache\logging\log4php\Foo', $actual);
-
- $actual = LoggerUtils::shortenClassName($name, 30);
- self::assertSame('org\apache\logging\log4php\Foo', $actual);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/layouts/LoggerLayoutHtmlTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/layouts/LoggerLayoutHtmlTest.php b/src/test/php/layouts/LoggerLayoutHtmlTest.php
deleted file mode 100644
index 59d7e5c..0000000
--- a/src/test/php/layouts/LoggerLayoutHtmlTest.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group layouts
- */
-class LoggerLayoutHtmlTest extends PHPUnit_Framework_TestCase {
-
- public function testErrorLayout() {
- $event = new LoggerLoggingEvent("LoggerLayoutHtmlTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $layout = new LoggerLayoutHtml();
- $v = $layout->format($event);
-
- $e = PHP_EOL."<tr>".PHP_EOL.
- "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
- "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
- "<td title=\"Level\">ERROR</td>".PHP_EOL.
- "<td title=\"TEST category\">TEST</td>".PHP_EOL.
- "<td title=\"Message\">testmessage</td>".PHP_EOL.
- "</tr>".PHP_EOL;
-
- self::assertEquals($v, $e);
- }
-
- public function testWarnLayout() {
- $event = new LoggerLoggingEvent("LoggerLayoutHtmlTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
-
- $layout = new LoggerLayoutHtml();
- $v = $layout->format($event);
-
- $e = PHP_EOL."<tr>".PHP_EOL.
- "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
- "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
- "<td title=\"Level\"><font color=\"#993300\"><strong>WARN</strong></font></td>".PHP_EOL.
- "<td title=\"TEST category\">TEST</td>".PHP_EOL.
- "<td title=\"Message\">testmessage</td>".PHP_EOL.
- "</tr>".PHP_EOL;
-
- self::assertEquals($v, $e);
- }
-
- public function testContentType() {
- $layout = new LoggerLayoutHtml();
- $v = $layout->getContentType();
- $e = "text/html";
- self::assertEquals($v, $e);
- }
-
- public function testTitle() {
- $layout = new LoggerLayoutHtml();
- $v = $layout->getTitle();
- $e = "Log4php Log Messages";
- self::assertEquals($v, $e);
-
- $layout->setTitle("test");
- $v = $layout->getTitle();
- $e = "test";
- self::assertEquals($v, $e);
- }
-
- public function testHeader() {
- $layout = new LoggerLayoutHtml();
- $v = $layout->getHeader();
- self::assertTrue(strpos($v, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">") === 0);
- }
-
- public function testFooter() {
- $layout = new LoggerLayoutHtml();
- $v = $layout->getFooter();
- self::assertTrue(strpos($v, "</table>") === 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/layouts/LoggerLayoutPatternTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/layouts/LoggerLayoutPatternTest.php b/src/test/php/layouts/LoggerLayoutPatternTest.php
deleted file mode 100644
index cc322cd..0000000
--- a/src/test/php/layouts/LoggerLayoutPatternTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group layouts
- */
-class LoggerLayoutPatternTest extends PHPUnit_Framework_TestCase {
-
- /** Pattern used for testing. */
- private $pattern = "%-6level %logger: %msg from %class::%method() in %file at %line%n";
-
- public function testComplexLayout() {
-
- $config = LoggerTestHelper::getEchoPatternConfig($this->pattern);
- Logger::configure($config);
-
- ob_start();
- $log = Logger::getLogger('LoggerTest');
- $log->error("my message"); $line = __LINE__;
- $actual = ob_get_contents();
- ob_end_clean();
-
- $file = __FILE__;
- $class = __CLASS__;
- $method = __FUNCTION__;
-
- $expected = "ERROR LoggerTest: my message from $class::$method() in $file at $line" . PHP_EOL;
- self::assertSame($expected, $actual);
-
- Logger::resetConfiguration();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/layouts/LoggerLayoutSerializedTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/layouts/LoggerLayoutSerializedTest.php b/src/test/php/layouts/LoggerLayoutSerializedTest.php
deleted file mode 100644
index 7237127..0000000
--- a/src/test/php/layouts/LoggerLayoutSerializedTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group layouts
- */
-class LoggerLayoutSerializedTest extends PHPUnit_Framework_TestCase {
-
- public function testLocationInfo() {
- $layout = new LoggerLayoutSerialized();
- self::assertFalse($layout->getLocationInfo());
- $layout->setLocationInfo(true);
- self::assertTrue($layout->getLocationInfo());
- $layout->setLocationInfo(false);
- self::assertFalse($layout->getLocationInfo());
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid value given for 'locationInfo' property: ['foo']. Expected a boolean value. Property not changed.
- */
- public function testLocationInfoFail() {
- $layout = new LoggerLayoutSerialized();
- $layout->setLocationInfo('foo');
- }
-
- public function testLayout() {
- Logger::configure(array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSerialized'
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- )
- ));
-
- ob_start();
- $foo = Logger::getLogger('foo');
- $foo->info("Interesting message.");
- $actual = ob_get_contents();
- ob_end_clean();
-
- $event = unserialize($actual);
-
- self::assertInstanceOf('LoggerLoggingEvent', $event);
- self::assertEquals('Interesting message.', $event->getMessage());
- self::assertEquals(LoggerLevel::getLevelInfo(), $event->getLevel());
- }
-
- public function testLayoutWithLocationInfo() {
- Logger::configure(array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSerialized',
- 'params' => array(
- 'locationInfo' => true
- )
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- )
- ));
-
- ob_start();
- $foo = Logger::getLogger('foo');
- $foo->info("Interesting message.");
- $actual = ob_get_contents();
- ob_end_clean();
-
- $event = unserialize($actual);
-
- self::assertInstanceOf('LoggerLoggingEvent', $event);
- self::assertEquals('Interesting message.', $event->getMessage());
- self::assertEquals(LoggerLevel::getLevelInfo(), $event->getLevel());
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/layouts/LoggerLayoutSimpleTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/layouts/LoggerLayoutSimpleTest.php b/src/test/php/layouts/LoggerLayoutSimpleTest.php
deleted file mode 100644
index 76a35c9..0000000
--- a/src/test/php/layouts/LoggerLayoutSimpleTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group layouts
- */
-class LoggerLayoutSimpleTest extends PHPUnit_Framework_TestCase {
-
- public function testSimpleLayout() {
- $event = new LoggerLoggingEvent("LoggerLayoutSimpleTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $layout = new LoggerLayoutSimple();
- $actual = $layout->format($event);
- $expected = "ERROR - testmessage" . PHP_EOL;
- self::assertEquals($expected, $actual);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/layouts/LoggerLayoutTTCCTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/layouts/LoggerLayoutTTCCTest.php b/src/test/php/layouts/LoggerLayoutTTCCTest.php
deleted file mode 100644
index 9baf060..0000000
--- a/src/test/php/layouts/LoggerLayoutTTCCTest.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group layouts
- */
-class LoggerLayoutTTCCTest extends PHPUnit_Framework_TestCase {
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage LoggerLayout TTCC is deprecated and will be removed in a future release.
- */
- public function testDeprecationWarning() {
- $layout = new LoggerLayoutTTCC();
- }
-
- public function testErrorLayout() {
- $event = new LoggerLoggingEvent("LoggerLayoutTTCC", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $layout = @new LoggerLayoutTTCC();
- $v = $layout->format($event);
-
- $pos = strpos($v, "[".$event->getThreadName()."] ERROR TEST - testmessage");
-
- if ($pos === false) {
- self::assertTrue(false);
- } else if ($pos === true) {
- self::assertTrue(true);
- }
- }
-
- public function testWarnLayout() {
- $event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
-
- $layout = @new LoggerLayoutTTCC();
- $v = $layout->format($event);
-
- $pos = strpos($v, "[".$event->getThreadName()."] WARN TEST - testmessage");
-
- if ($pos === false) {
- self::assertTrue(false);
- } else if ($pos === true) {
- self::assertTrue(true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/layouts/LoggerLayoutXmlTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/layouts/LoggerLayoutXmlTest.php b/src/test/php/layouts/LoggerLayoutXmlTest.php
deleted file mode 100644
index 34bb77c..0000000
--- a/src/test/php/layouts/LoggerLayoutXmlTest.php
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group layouts
- */
-class LoggerLayoutXmlTest extends PHPUnit_Framework_TestCase {
-
- public function testErrorLayout() {
- $event = LoggerTestHelper::getErrorEvent("testmessage");
-
- $layout = new LoggerLayoutXml();
- $layout->activateOptions();
-
- $actual = $layout->format($event);
-
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
-
- $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
-
- self::assertEquals($expected, $actual);
- }
-
- public function testWarnLayout() {
- $event = LoggerTestHelper::getWarnEvent("testmessage");
-
- $layout = new LoggerLayoutXml();
- $layout->activateOptions();
-
- $actual = $layout->format($event);
-
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
-
- $expected = "<log4php:event logger=\"test\" level=\"WARN\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
-
- self::assertEquals($expected, $actual);
- }
-
- public function testLog4JNamespaceErrorLayout() {
- $event = LoggerTestHelper::getErrorEvent("testmessage");
-
- $layout = new LoggerLayoutXml();
- $layout->setLog4jNamespace(true);
- $layout->activateOptions();
-
- $actual = $layout->format($event);
-
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
-
- $expected = "<log4j:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4j:message><![CDATA[testmessage]]></log4j:message>" . PHP_EOL .
- "<log4j:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4j:event>" . PHP_EOL;
-
- self::assertEquals($expected, $actual);
- }
-
- public function testNDC()
- {
- LoggerNDC::push('foo');
- LoggerNDC::push('bar');
-
- $event = LoggerTestHelper::getErrorEvent("testmessage");
-
- $layout = new LoggerLayoutXml();
- $layout->activateOptions();
-
- $actual = $layout->format($event);
-
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
-
- $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:NDC><![CDATA[<![CDATA[foo bar]]>]]></log4php:NDC>" . PHP_EOL .
- "<log4php:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
-
- self::assertEquals($expected, $actual);
-
- LoggerNDC::clear();
- }
-
- public function testMDC()
- {
- LoggerMDC::put('foo', 'bar');
- LoggerMDC::put('bla', 'tra');
-
- $event = LoggerTestHelper::getErrorEvent("testmessage");
-
- $layout = new LoggerLayoutXml();
- $layout->activateOptions();
-
- $actual = $layout->format($event);
-
- $thread = $event->getThreadName();
- $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
-
- $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
- "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
- "<log4php:properties>" . PHP_EOL .
- "<log4php:data name=\"foo\" value=\"bar\" />" . PHP_EOL .
- "<log4php:data name=\"bla\" value=\"tra\" />" . PHP_EOL .
- "</log4php:properties>" . PHP_EOL .
- "<log4php:locationInfo class=\"LoggerLoggingEvent\" file=\"NA\" line=\"NA\" " .
- "method=\"getLocationInformation\" />" . PHP_EOL .
- "</log4php:event>" . PHP_EOL;
-
- self::assertEquals($expected, $actual);
-
- LoggerMDC::clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/pattern/LoggerPatternConverterTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/pattern/LoggerPatternConverterTest.php b/src/test/php/pattern/LoggerPatternConverterTest.php
deleted file mode 100644
index 12ab854..0000000
--- a/src/test/php/pattern/LoggerPatternConverterTest.php
+++ /dev/null
@@ -1,384 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage pattern
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/** Converter referencing non-existant superglobal variable. */
-class LoggerInvalidSuperglobalConverter extends LoggerPatternConverterSuperglobal {
- protected $name = '_FOO';
-}
-
-/**
- * @group pattern
- */
-class LoggerPatternConverterTest extends PHPUnit_Framework_TestCase {
-
- /**
- * A logging event for testing.
- * @var LoggerLoggingEvent
- */
- private $event;
-
- /**
- * Fromatting info used with the logging event.
- * @var LoggerFormattingInfos
- */
- private $info;
-
- public function __construct() {
- $this->event = LoggerTestHelper::getInfoEvent('foobar');
- $this->info = new LoggerFormattingInfo();
- }
-
- public function testCookie() {
- // Fake a couple of cookies
- $_COOKIE['test1'] = 'value1';
- $_COOKIE['test2'] = 'value2';
-
- $converter = new LoggerPatternConverterCookie($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
-
- $converter = new LoggerPatternConverterCookie($this->info, 'test2');
- $actual = $converter->convert($this->event);
- $expected = 'value2';
- self::assertSame($expected, $actual);
-
- $converter = new LoggerPatternConverterCookie($this->info);
- $actual = $converter->convert($this->event);
- $expected = "test1=value1, test2=value2";
- self::assertSame($expected, $actual);
- }
-
- public function testDate() {
- $converter = new LoggerPatternConverterDate($this->info, 'c');
- $actual = $converter->convert($this->event);
- $expected = date('c', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- // Format defaults to 'c'
- $converter = new LoggerPatternConverterDate($this->info);
- $actual = $converter->convert($this->event);
- $expected = date('c', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- $converter = new LoggerPatternConverterDate($this->info, '');
- $actual = $converter->convert($this->event);
- $expected = date('c', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- // Test ABSOLUTE
- $converter = new LoggerPatternConverterDate($this->info, 'ABSOLUTE');
- $actual = $converter->convert($this->event);
- $expected = date('H:i:s', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- // Test DATE
- $converter = new LoggerPatternConverterDate($this->info, 'DATE');
- $actual = $converter->convert($this->event);
- $expected = date('d M Y H:i:s.', $this->event->getTimeStamp());
-
- $timestamp = $this->event->getTimeStamp();
- $ms = floor(($timestamp - floor($timestamp)) * 1000);
- $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
-
- $expected .= $ms;
-
- self::assertSame($expected, $actual);
- }
-
- public function testEnvironment() {
- // Fake a couple of environment values
- $_ENV['test1'] = 'value1';
- $_ENV['test2'] = 'value2';
-
- $converter = new LoggerPatternConverterEnvironment($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
-
- $converter = new LoggerPatternConverterEnvironment($this->info, 'test2');
- $actual = $converter->convert($this->event);
- $expected = 'value2';
- self::assertSame($expected, $actual);
- }
-
- public function testLevel() {
- $converter = new LoggerPatternConverterLevel($this->info);
- $actual = $converter->convert($this->event);
- $expected = $this->event->getLevel()->toString();
- self::assertEquals($expected, $actual);
- }
-
- public function testLiteral() {
- $converter = new LoggerPatternConverterLiteral('foo bar baz');
- $actual = $converter->convert($this->event);
- $expected = 'foo bar baz';
- self::assertEquals($expected, $actual);
- }
-
- public function testLoggerWithoutOption() {
- $event = LoggerTestHelper::getInfoEvent('foo', 'TestLoggerName');
- $converter = new LoggerPatternConverterLogger($this->info);
-
- $actual = $converter->convert($event);
- $expected = 'TestLoggerName';
- self::assertEquals($expected, $actual);
- }
-
- public function testLoggerWithOption0() {
- $event = LoggerTestHelper::getInfoEvent('foo', 'TestLoggerName');
- $converter = new LoggerPatternConverterLogger($this->info, '0');
-
- $actual = $converter->convert($event);
- $expected = 'TestLoggerName';
- self::assertEquals($expected, $actual);
- }
-
- public function testLocation() {
- $config = LoggerTestHelper::getEchoPatternConfig("%file:%line:%class:%method");
- Logger::configure($config);
-
- // Test by capturing output. Logging methods of a Logger object must
- // be used for the location info to be formed correctly.
- ob_start();
- $log = Logger::getLogger('foo');
- $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
- $actual = ob_get_contents();
- ob_end_clean();
-
- $expected = implode(':', array(__FILE__, $line, __CLASS__, __FUNCTION__));
- self::assertSame($expected, $actual);
-
- Logger::resetConfiguration();
- }
-
- public function testLocation2() {
- $config = LoggerTestHelper::getEchoPatternConfig("%location");
- Logger::configure($config);
-
- // Test by capturing output. Logging methods of a Logger object must
- // be used for the location info to be formed correctly.
- ob_start();
- $log = Logger::getLogger('foo');
- $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
- $actual = ob_get_contents();
- ob_end_clean();
-
- $class = __CLASS__;
- $func = __FUNCTION__;
- $file = __FILE__;
-
- $expected = "$class.$func($file:$line)";
- self::assertSame($expected, $actual);
-
- Logger::resetConfiguration();
- }
-
- public function testMessage() {
- $expected = "This is a message.";
- $event = LoggerTestHelper::getInfoEvent($expected);
- $converter = new LoggerPatternConverterMessage($this->info);
- $actual = $converter->convert($event);
- self::assertSame($expected, $actual);
- }
-
- public function testMDC() {
- LoggerMDC::put('foo', 'bar');
- LoggerMDC::put('bla', 'tra');
-
- // Entire context
- $converter = new LoggerPatternConverterMDC($this->info);
- $actual = $converter->convert($this->event);
- $expected = 'foo=bar, bla=tra';
- self::assertSame($expected, $actual);
-
- // Just foo
- $converter = new LoggerPatternConverterMDC($this->info, 'foo');
- $actual = $converter->convert($this->event);
- $expected = 'bar';
- self::assertSame($expected, $actual);
-
- // Non existant key
- $converter = new LoggerPatternConverterMDC($this->info, 'doesnotexist');
- $actual = $converter->convert($this->event);
- $expected = '';
- self::assertSame($expected, $actual);
-
- LoggerMDC::clear();
- }
-
- public function testNDC() {
- LoggerNDC::push('foo');
- LoggerNDC::push('bar');
- LoggerNDC::push('baz');
-
- $converter = new LoggerPatternConverterNDC($this->info);
- $expected = 'foo bar baz';
- $actual = $converter->convert($this->event);
- self::assertEquals($expected, $actual);
- }
-
- public function testNewline() {
- $converter = new LoggerPatternConverterNewLine($this->info);
- $actual = $converter->convert($this->event);
- $expected = PHP_EOL;
- self::assertSame($expected, $actual);
- }
-
- public function testProcess() {
- $converter = new LoggerPatternConverterProcess($this->info);
- $actual = $converter->convert($this->event);
- $expected = getmypid();
- self::assertSame($expected, $actual);
- }
-
- 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);
- }
-
- public function testRequest() {
- // Fake a couple of request values
- $_REQUEST['test1'] = 'value1';
- $_REQUEST['test2'] = 'value2';
-
- // Entire request
- $converter = new LoggerPatternConverterRequest($this->info);
- $actual = $converter->convert($this->event);
- $expected = 'test1=value1, test2=value2';
- self::assertSame($expected, $actual);
-
- // Just test2
- $converter = new LoggerPatternConverterRequest($this->info, 'test2');
- $actual = $converter->convert($this->event);
- $expected = 'value2';
- self::assertSame($expected, $actual);
- }
-
- public function testServer() {
- // Fake a server value
- $_SERVER['test1'] = 'value1';
-
- $converter = new LoggerPatternConverterServer($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
- }
-
- public function testSession() {
- // Fake a session value
- $_SESSION['test1'] = 'value1';
-
- $converter = new LoggerPatternConverterSession($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
- }
-
- public function testSessionID() {
- $converter = new LoggerPatternConverterSessionID($this->info);
- $actual = $converter->convert($this->event);
- $expected = session_id();
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: LoggerInvalidSuperglobalConverter: Cannot find superglobal variable $_FOO
- */
- public function testNonexistantSuperglobal() {
- $converter = new LoggerInvalidSuperglobalConverter($this->info);
- $actual = $converter->convert($this->event);
- }
-
- public function testFormattingTrimRight() {
- $event = LoggerTestHelper::getInfoEvent('0123456789');
-
- $info = new LoggerFormattingInfo();
- $info->max = 5;
-
- $converter = new LoggerPatternConverterMessage($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = "01234";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingTrimLeft() {
- $event = LoggerTestHelper::getInfoEvent('0123456789');
-
- $info = new LoggerFormattingInfo();
- $info->max = 5;
- $info->trimLeft = true;
-
- $converter = new LoggerPatternConverterMessage($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = "56789";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingPadEmpty() {
- $event = LoggerTestHelper::getInfoEvent('');
-
- $info = new LoggerFormattingInfo();
- $info->min = 5;
-
- $converter = new LoggerPatternConverterMessage($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = " ";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingPadLeft() {
- $event = LoggerTestHelper::getInfoEvent('0');
-
- $info = new LoggerFormattingInfo();
- $info->min = 5;
-
- $converter = new LoggerPatternConverterMessage($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = " 0";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingPadRight() {
- $event = LoggerTestHelper::getInfoEvent('0');
-
- $info = new LoggerFormattingInfo();
- $info->min = 5;
- $info->padLeft = false;
-
- $converter = new LoggerPatternConverterMessage($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = "0 ";
- self::assertSame($expected, $actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/renderers/LoggerRendererMapTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/renderers/LoggerRendererMapTest.php b/src/test/php/renderers/LoggerRendererMapTest.php
deleted file mode 100644
index 030f4b5..0000000
--- a/src/test/php/renderers/LoggerRendererMapTest.php
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage renderers
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/** Renders everything as 'foo'. */
-class FooRenderer implements LoggerRenderer {
- public function render($input) {
- return 'foo';
- }
-}
-
-class InvalidCostumObjectRenderer { }
-
-class Fruit3 {
- public $test1 = 'test1';
- public $test2 = 'test2';
- public $test3 = 'test3';
-}
-
-class Fruit3Descendant extends Fruit3 {
-}
-
-class FruitRenderer3 implements LoggerRenderer {
- public function render($fruit) {
- return $fruit->test1 . ',' . $fruit->test2 . ',' . $fruit->test3;
- }
-}
-
-class SampleObject {
-}
-
-/**
- * @group renderers
- */
-class LoggerRendererMapTest extends PHPUnit_Framework_TestCase {
-
- public function testDefaults() {
-
- $map = new LoggerRendererMap();
- $actual = $map->getByClassName('Exception');
- self::assertInstanceOf('LoggerRendererException', $actual);
-
- // Check non-configured objects return null
- self::assertNull($map->getByObject(new stdClass()));
- self::assertNull($map->getByClassName('stdClass'));
- }
-
- public function testClear()
- {
- $map = new LoggerRendererMap();
- $map->clear(); // This should clear the map and remove default renderers
- self::assertNull($map->getByClassName('Exception'));
- }
-
- public function testFindAndRender()
- {
- $map = new LoggerRendererMap();
- $map->addRenderer('Fruit3', 'FruitRenderer3');
-
- $fruit = new Fruit3();
- $descendant = new Fruit3Descendant();
-
- // Check rendering of fruit
- $actual = $map->findAndRender($fruit);
- $expected = 'test1,test2,test3';
- self::assertSame($expected, $actual);
-
- $actual = $map->getByObject($fruit);
- self::assertInstanceOf('FruitRenderer3', $actual);
-
- // Check rendering of fruit's descendant
- $actual = $map->findAndRender($descendant);
- $expected = 'test1,test2,test3';
- self::assertSame($expected, $actual);
-
- $actual = $map->getByObject($descendant);
- self::assertInstanceOf('FruitRenderer3', $actual);
-
- // Test rendering null returns null
- self::assertNull($map->findAndRender(null));
- }
-
- /**
- * Try adding a non-existant class as renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExist] not found.
- */
- public function testAddRendererError1()
- {
- $map = new LoggerRendererMap();
- $map->addRenderer('Fruit3', 'DoesNotExist');
- }
-
- /**
- * Try adding a class which does not implement LoggerRenderer as renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the LoggerRenderer interface.
- */
- public function testAddRendererError2()
- {
- $map = new LoggerRendererMap();
- $map->addRenderer('Fruit3', 'stdClass');
- }
-
- public function testAddRendererError3()
- {
- $map = new LoggerRendererMap();
- @$map->addRenderer('Fruit3', 'stdClass');
- self::assertNull($map->getByClassName('Fruit3'));
-
- @$map->addRenderer('Fruit3', 'DoesNotExist');
- self::assertNull($map->getByClassName('Fruit3'));
- }
-
- /**
- * Try setting a non-existant class as default renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed setting default renderer. Rendering class [DoesNotExist] not found.
- */
- public function testSetDefaultRendererError1()
- {
- $map = new LoggerRendererMap();
- $map->setDefaultRenderer('DoesNotExist');
- }
-
- /**
- * Try setting a class which does not implement LoggerRenderer as default renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed setting default renderer. Rendering class [stdClass] does not implement the LoggerRenderer interface.
- */
- public function testSetDefaultRendererError2()
- {
- $map = new LoggerRendererMap();
- $map->setDefaultRenderer('stdClass');
- }
-
- public function testSetDefaultRendererError3()
- {
- $map = new LoggerRendererMap();
- $expected = $map->getDefaultRenderer();
-
- @$map->setDefaultRenderer('stdClass');
- $actual = $map->getDefaultRenderer();
- self::assertSame($expected, $actual);
-
- @$map->setDefaultRenderer('DoesNotExist');
- $actual = $map->getDefaultRenderer();
- self::assertSame($expected, $actual);
- }
-
- public function testFetchingRenderer()
- {
- $map = new LoggerRendererMap();
- $map->addRenderer('Fruit3', 'FruitRenderer3');
- }
-
- public function testDefaultRenderer()
- {
- $fruit = new Fruit3();
-
- $map = new LoggerRendererMap();
- $actual = $map->findAndRender($fruit);
-
- $defaultRenderer = new LoggerRendererDefault();
- $expected = $defaultRenderer->render($fruit);
- self::assertSame($expected, $actual);
- }
-
- public function testOverrideDefaultRenderer()
- {
- $map = new LoggerRendererMap();
- $default = $map->getDefaultRenderer();
-
- $array = array(1, 2, 3);
-
- $actual = $map->findAndRender($array);
- $expected = print_r($array, true);
- self::assertSame($actual, $expected);
-
- // Now switch the default renderer
- $map->setDefaultRenderer('FooRenderer');
- $actual = $map->findAndRender($array);
- $expected = 'foo';
- self::assertSame($actual, $expected);
- }
-
- public function testGetByObjectCrap()
- {
- $map = new LoggerRendererMap();
-
- // Non object input should always return null
- self::assertNull($map->getByObject(null));
- self::assertNull($map->getByObject(array()));
- self::assertNull($map->getByObject('sdasda'));
- }
-
- public function testXMLConfig()
- {
- $map = Logger::getHierarchy()->getRendererMap();
- Logger::resetConfiguration();
- self::assertInstanceOf('LoggerRendererDefault', $map->getDefaultRenderer());
-
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_default_renderer.xml');
- self::assertInstanceOf('FruitRenderer3', $map->getDefaultRenderer());
-
- Logger::resetConfiguration();
- self::assertInstanceOf('LoggerRendererDefault', $map->getDefaultRenderer());
- }
-
- public function testExceptionRenderer()
- {
- $ex = new LoggerException("This is a test");
-
- $map = new LoggerRendererMap();
- $actual = $map->findAndRender($ex);
- $expected = (string) $ex;
-
- self::assertSame($expected, $actual);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini b/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini
deleted file mode 100644
index 4b29374..0000000
--- a/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini
+++ /dev/null
@@ -1,24 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-
-log4php.rootLogger = DEBUG, default
-
-log4php.appender.default = LoggerAppenderEcho
-
-# invalid appender line should trigger warning
-log4php.appender.default.layout.param.bla = LoggerLayoutTTCC
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini b/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini
deleted file mode 100644
index d36aa43..0000000
--- a/src/test/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini
+++ /dev/null
@@ -1,24 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-
-log4php.rootLogger = DEBUG, default
-
-log4php.appender.default = LoggerAppenderEcho
-
-# invalid appender line should trigger warning
-log4php.appender.default.not-layout.param = LoggerLayoutTTCC
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/ini/config_invalid_syntax.ini
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/ini/config_invalid_syntax.ini b/src/test/resources/configs/adapters/ini/config_invalid_syntax.ini
deleted file mode 100644
index 9971ea2..0000000
--- a/src/test/resources/configs/adapters/ini/config_invalid_syntax.ini
+++ /dev/null
@@ -1,19 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-
-not a valid ini file ()
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/ini/config_valid.ini
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/ini/config_valid.ini b/src/test/resources/configs/adapters/ini/config_valid.ini
deleted file mode 100644
index 5e2a6d9..0000000
--- a/src/test/resources/configs/adapters/ini/config_valid.ini
+++ /dev/null
@@ -1,41 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-
-log4php.rootLogger = DEBUG, default
-
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutTTCC
-
-log4php.appender.file = LoggerAppenderDailyFile
-log4php.appender.file.layout = LoggerLayoutPattern
-log4php.appender.file.layout.conversionPattern = "%d{ISO8601} [%p] %c: %m (at %F line %L)%n"
-log4php.appender.file.datePattern = Ymd
-log4php.appender.file.file = target/examples/daily_%s.log
-log4php.appender.file.threshold = warn
-
-log4php.logger.foo = warn, default
-
-log4php.logger.foo.bar = debug, file
-log4php.additivity.foo.bar = "true"
-
-log4php.logger.foo.bar.baz = trace, default, file
-log4php.additivity.foo.bar.baz = "false"
-
-log4php.renderer.Fruit = FruitRenderer
-log4php.renderer.Beer = BeerRenderer
-
-log4php.threshold = debug
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/ini/values.ini
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/ini/values.ini b/src/test/resources/configs/adapters/ini/values.ini
deleted file mode 100644
index bd4239a..0000000
--- a/src/test/resources/configs/adapters/ini/values.ini
+++ /dev/null
@@ -1,25 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-
-unquoted_true = true
-unquoted_false = false
-unquoted_yes = true
-unquoted_no = false
-quoted_true = "true"
-quoted_false = "false"
-unquoted_one = 1
-unquoted_zero = 0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/php/config_empty.php
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/php/config_empty.php b/src/test/resources/configs/adapters/php/config_empty.php
deleted file mode 100644
index 7b0b37c..0000000
--- a/src/test/resources/configs/adapters/php/config_empty.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-// Empty config
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/php/config_invalid_syntax.php
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/php/config_invalid_syntax.php b/src/test/resources/configs/adapters/php/config_invalid_syntax.php
deleted file mode 100644
index bd0220f..0000000
--- a/src/test/resources/configs/adapters/php/config_invalid_syntax.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-return array(
- 'rootLogger' => array(
- 'level' => 'info',
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- )
- )
- )
-
-// Invalid file - no closing brace.
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/php/config_not_an_array.php
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/php/config_not_an_array.php b/src/test/resources/configs/adapters/php/config_not_an_array.php
deleted file mode 100644
index 4ed942c..0000000
--- a/src/test/resources/configs/adapters/php/config_not_an_array.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-// Not an array
-return new Exception();
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/php/config_valid.php
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/php/config_valid.php b/src/test/resources/configs/adapters/php/config_valid.php
deleted file mode 100644
index 176a704..0000000
--- a/src/test/resources/configs/adapters/php/config_valid.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-return array(
- 'rootLogger' => array(
- 'level' => 'info',
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- )
- )
- )
-)
-;
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/xml/config_duplicate_logger.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/xml/config_duplicate_logger.xml b/src/test/resources/configs/adapters/xml/config_duplicate_logger.xml
deleted file mode 100644
index fde2223..0000000
--- a/src/test/resources/configs/adapters/xml/config_duplicate_logger.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
-
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple"/>
- </appender>
-
- <!-- Duplicate logger -->
- <logger name="foo">
- <level value="info" />
- <appender_ref ref="default" />
- </logger>
-
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/xml/config_duplicate_renderer.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/xml/config_duplicate_renderer.xml b/src/test/resources/configs/adapters/xml/config_duplicate_renderer.xml
deleted file mode 100644
index a9310ad..0000000
--- a/src/test/resources/configs/adapters/xml/config_duplicate_renderer.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration>
- <!-- Duplicate renderer -->
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer1" />
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer2" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple"/>
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/xml/config_invalid_syntax.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/xml/config_invalid_syntax.xml b/src/test/resources/configs/adapters/xml/config_invalid_syntax.xml
deleted file mode 100644
index f367fbf..0000000
--- a/src/test/resources/configs/adapters/xml/config_invalid_syntax.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple"/>
- </appender>
-
- <!-- Duplicate logger -->
- <logger name="foo">
- <level value="info" />
- <appender_ref ref="default" />
- </logger>
-
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-
- <!-- Invalid XML file for testing -->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/xml/config_valid.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/xml/config_valid.xml b/src/test/resources/configs/adapters/xml/config_valid.xml
deleted file mode 100644
index 70f06c4..0000000
--- a/src/test/resources/configs/adapters/xml/config_valid.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LoggerFilterLevelRange">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- <filter class="LoggerFilterDenyAll" />
- </appender>
- <appender name="file" class="LoggerAppenderDailyFile" threshold="warn">
- <param name="datePattern" value="Ymd" />
- <param name="file" value="target/examples/daily_%s.log" />
- <layout class="LoggerLayoutPattern">
- <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
- </layout>
- </appender>
- <logger name="foo.bar.baz" additivity="false">
- <level value="trace" />
- <appender_ref ref="default" />
- </logger>
- <logger name="foo.bar" additivity="true">
- <level value="debug" />
- <appender_ref ref="file" />
- </logger>
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- <appender_ref ref="file" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/adapters/xml/config_valid_underscore.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/adapters/xml/config_valid_underscore.xml b/src/test/resources/configs/adapters/xml/config_valid_underscore.xml
deleted file mode 100644
index 020530f..0000000
--- a/src/test/resources/configs/adapters/xml/config_valid_underscore.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Same as config_valid.xml but uses appender-ref instead of appender_ref -->
-
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LoggerFilterLevelRange">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- <filter class="LoggerFilterDenyAll" />
- </appender>
- <appender name="file" class="LoggerAppenderDailyFile" threshold="warn">
- <param name="datePattern" value="Ymd" />
- <param name="file" value="target/examples/daily_%s.log" />
- <layout class="LoggerLayoutPattern">
- <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
- </layout>
- </appender>
- <logger name="foo.bar.baz" additivity="false">
- <level value="trace" />
- <appender-ref ref="default" />
- </logger>
- <logger name="foo.bar" additivity="true">
- <level value="debug" />
- <appender-ref ref="file" />
- </logger>
- <logger name="foo">
- <level value="warn" />
- <appender-ref ref="default" />
- <appender-ref ref="file" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender-ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_invalid_appender_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_invalid_appender_class.xml b/src/test/resources/configs/appenders/config_invalid_appender_class.xml
deleted file mode 100644
index db3ccf0..0000000
--- a/src/test/resources/configs/appenders/config_invalid_appender_class.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="foo" class="stdClass"/>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_invalid_filter_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_invalid_filter_class.xml b/src/test/resources/configs/appenders/config_invalid_filter_class.xml
deleted file mode 100644
index eb0364f..0000000
--- a/src/test/resources/configs/appenders/config_invalid_filter_class.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <filter class="stdClass" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
[17/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/css/bootstrap.css
----------------------------------------------------------------------
diff --git a/src/site/resources/css/bootstrap.css b/src/site/resources/css/bootstrap.css
deleted file mode 100644
index 0664207..0000000
--- a/src/site/resources/css/bootstrap.css
+++ /dev/null
@@ -1,5624 +0,0 @@
-/*!
- * Bootstrap v2.1.0
- *
- * Copyright 2012 Twitter, Inc
- * Licensed under the Apache License v2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Designed and built with all the love in the world @twitter by @mdo and @fat.
- */
-
-article,
-aside,
-details,
-figcaption,
-figure,
-footer,
-header,
-hgroup,
-nav,
-section {
- display: block;
-}
-
-audio,
-canvas,
-video {
- display: inline-block;
- *display: inline;
- *zoom: 1;
-}
-
-audio:not([controls]) {
- display: none;
-}
-
-html {
- font-size: 100%;
- -webkit-text-size-adjust: 100%;
- -ms-text-size-adjust: 100%;
-}
-
-a:focus {
- outline: thin dotted #333;
- outline: 5px auto -webkit-focus-ring-color;
- outline-offset: -2px;
-}
-
-a:hover,
-a:active {
- outline: 0;
-}
-
-sub,
-sup {
- position: relative;
- font-size: 75%;
- line-height: 0;
- vertical-align: baseline;
-}
-
-sup {
- top: -0.5em;
-}
-
-sub {
- bottom: -0.25em;
-}
-
-img {
- height: auto;
- max-width: 100%;
- vertical-align: middle;
- border: 0;
- -ms-interpolation-mode: bicubic;
-}
-
-#map_canvas img {
- max-width: none;
-}
-
-button,
-input,
-select,
-textarea {
- margin: 0;
- font-size: 100%;
- vertical-align: middle;
-}
-
-button,
-input {
- *overflow: visible;
- line-height: normal;
-}
-
-button::-moz-focus-inner,
-input::-moz-focus-inner {
- padding: 0;
- border: 0;
-}
-
-button,
-input[type="button"],
-input[type="reset"],
-input[type="submit"] {
- cursor: pointer;
- -webkit-appearance: button;
-}
-
-input[type="search"] {
- -webkit-box-sizing: content-box;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
- -webkit-appearance: textfield;
-}
-
-input[type="search"]::-webkit-search-decoration,
-input[type="search"]::-webkit-search-cancel-button {
- -webkit-appearance: none;
-}
-
-textarea {
- overflow: auto;
- vertical-align: top;
-}
-
-.clearfix {
- *zoom: 1;
-}
-
-.clearfix:before,
-.clearfix:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.clearfix:after {
- clear: both;
-}
-
-.hide-text {
- font: 0/0 a;
- color: transparent;
- text-shadow: none;
- background-color: transparent;
- border: 0;
-}
-
-.input-block-level {
- display: block;
- width: 100%;
- min-height: 30px;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-
-body {
- margin: 0;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 14px;
- line-height: 20px;
- color: #333333;
- background-color: #ffffff;
-}
-
-a {
- color: #0088cc;
- text-decoration: none;
-}
-
-a:hover {
- color: #005580;
- text-decoration: underline;
-}
-
-.img-rounded {
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
-}
-
-.img-polaroid {
- padding: 4px;
- background-color: #fff;
- border: 1px solid #ccc;
- border: 1px solid rgba(0, 0, 0, 0.2);
- -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
- -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
-}
-
-.img-circle {
- -webkit-border-radius: 500px;
- -moz-border-radius: 500px;
- border-radius: 500px;
-}
-
-.row {
- margin-left: -20px;
- *zoom: 1;
-}
-
-.row:before,
-.row:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.row:after {
- clear: both;
-}
-
-[class*="span"] {
- float: left;
- margin-left: 20px;
-}
-
-.container,
-.navbar-static-top .container,
-.navbar-fixed-top .container,
-.navbar-fixed-bottom .container {
- width: 940px;
-}
-
-.span12 {
- width: 940px;
-}
-
-.span11 {
- width: 860px;
-}
-
-.span10 {
- width: 780px;
-}
-
-.span9 {
- width: 700px;
-}
-
-.span8 {
- width: 620px;
-}
-
-.span7 {
- width: 540px;
-}
-
-.span6 {
- width: 460px;
-}
-
-.span5 {
- width: 380px;
-}
-
-.span4 {
- width: 300px;
-}
-
-.span3 {
- width: 220px;
-}
-
-.span2 {
- width: 140px;
-}
-
-.span1 {
- width: 60px;
-}
-
-.offset12 {
- margin-left: 980px;
-}
-
-.offset11 {
- margin-left: 900px;
-}
-
-.offset10 {
- margin-left: 820px;
-}
-
-.offset9 {
- margin-left: 740px;
-}
-
-.offset8 {
- margin-left: 660px;
-}
-
-.offset7 {
- margin-left: 580px;
-}
-
-.offset6 {
- margin-left: 500px;
-}
-
-.offset5 {
- margin-left: 420px;
-}
-
-.offset4 {
- margin-left: 340px;
-}
-
-.offset3 {
- margin-left: 260px;
-}
-
-.offset2 {
- margin-left: 180px;
-}
-
-.offset1 {
- margin-left: 100px;
-}
-
-.row-fluid {
- width: 100%;
- *zoom: 1;
-}
-
-.row-fluid:before,
-.row-fluid:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.row-fluid:after {
- clear: both;
-}
-
-.row-fluid [class*="span"] {
- display: block;
- float: left;
- width: 100%;
- min-height: 30px;
- margin-left: 2.127659574468085%;
- *margin-left: 2.074468085106383%;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-
-.row-fluid [class*="span"]:first-child {
- margin-left: 0;
-}
-
-.row-fluid .span12 {
- width: 100%;
- *width: 99.94680851063829%;
-}
-
-.row-fluid .span11 {
- width: 91.48936170212765%;
- *width: 91.43617021276594%;
-}
-
-.row-fluid .span10 {
- width: 82.97872340425532%;
- *width: 82.92553191489361%;
-}
-
-.row-fluid .span9 {
- width: 74.46808510638297%;
- *width: 74.41489361702126%;
-}
-
-.row-fluid .span8 {
- width: 65.95744680851064%;
- *width: 65.90425531914893%;
-}
-
-.row-fluid .span7 {
- width: 57.44680851063829%;
- *width: 57.39361702127659%;
-}
-
-.row-fluid .span6 {
- width: 48.93617021276595%;
- *width: 48.88297872340425%;
-}
-
-.row-fluid .span5 {
- width: 40.42553191489362%;
- *width: 40.37234042553192%;
-}
-
-.row-fluid .span4 {
- width: 31.914893617021278%;
- *width: 31.861702127659576%;
-}
-
-.row-fluid .span3 {
- width: 23.404255319148934%;
- *width: 23.351063829787233%;
-}
-
-.row-fluid .span2 {
- width: 14.893617021276595%;
- *width: 14.840425531914894%;
-}
-
-.row-fluid .span1 {
- width: 6.382978723404255%;
- *width: 6.329787234042553%;
-}
-
-.row-fluid .offset12 {
- margin-left: 104.25531914893617%;
- *margin-left: 104.14893617021275%;
-}
-
-.row-fluid .offset12:first-child {
- margin-left: 102.12765957446808%;
- *margin-left: 102.02127659574467%;
-}
-
-.row-fluid .offset11 {
- margin-left: 95.74468085106382%;
- *margin-left: 95.6382978723404%;
-}
-
-.row-fluid .offset11:first-child {
- margin-left: 93.61702127659574%;
- *margin-left: 93.51063829787232%;
-}
-
-.row-fluid .offset10 {
- margin-left: 87.23404255319149%;
- *margin-left: 87.12765957446807%;
-}
-
-.row-fluid .offset10:first-child {
- margin-left: 85.1063829787234%;
- *margin-left: 84.99999999999999%;
-}
-
-.row-fluid .offset9 {
- margin-left: 78.72340425531914%;
- *margin-left: 78.61702127659572%;
-}
-
-.row-fluid .offset9:first-child {
- margin-left: 76.59574468085106%;
- *margin-left: 76.48936170212764%;
-}
-
-.row-fluid .offset8 {
- margin-left: 70.2127659574468%;
- *margin-left: 70.10638297872339%;
-}
-
-.row-fluid .offset8:first-child {
- margin-left: 68.08510638297872%;
- *margin-left: 67.9787234042553%;
-}
-
-.row-fluid .offset7 {
- margin-left: 61.70212765957446%;
- *margin-left: 61.59574468085106%;
-}
-
-.row-fluid .offset7:first-child {
- margin-left: 59.574468085106375%;
- *margin-left: 59.46808510638297%;
-}
-
-.row-fluid .offset6 {
- margin-left: 53.191489361702125%;
- *margin-left: 53.085106382978715%;
-}
-
-.row-fluid .offset6:first-child {
- margin-left: 51.063829787234035%;
- *margin-left: 50.95744680851063%;
-}
-
-.row-fluid .offset5 {
- margin-left: 44.68085106382979%;
- *margin-left: 44.57446808510638%;
-}
-
-.row-fluid .offset5:first-child {
- margin-left: 42.5531914893617%;
- *margin-left: 42.4468085106383%;
-}
-
-.row-fluid .offset4 {
- margin-left: 36.170212765957444%;
- *margin-left: 36.06382978723405%;
-}
-
-.row-fluid .offset4:first-child {
- margin-left: 34.04255319148936%;
- *margin-left: 33.93617021276596%;
-}
-
-.row-fluid .offset3 {
- margin-left: 27.659574468085104%;
- *margin-left: 27.5531914893617%;
-}
-
-.row-fluid .offset3:first-child {
- margin-left: 25.53191489361702%;
- *margin-left: 25.425531914893618%;
-}
-
-.row-fluid .offset2 {
- margin-left: 19.148936170212764%;
- *margin-left: 19.04255319148936%;
-}
-
-.row-fluid .offset2:first-child {
- margin-left: 17.02127659574468%;
- *margin-left: 16.914893617021278%;
-}
-
-.row-fluid .offset1 {
- margin-left: 10.638297872340425%;
- *margin-left: 10.53191489361702%;
-}
-
-.row-fluid .offset1:first-child {
- margin-left: 8.51063829787234%;
- *margin-left: 8.404255319148938%;
-}
-
-[class*="span"].hide,
-.row-fluid [class*="span"].hide {
- display: none;
-}
-
-[class*="span"].pull-right,
-.row-fluid [class*="span"].pull-right {
- float: right;
-}
-
-.container {
- margin-right: auto;
- margin-left: auto;
- *zoom: 1;
-}
-
-.container:before,
-.container:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.container:after {
- clear: both;
-}
-
-.container-fluid {
- padding-right: 20px;
- padding-left: 20px;
- *zoom: 1;
-}
-
-.container-fluid:before,
-.container-fluid:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.container-fluid:after {
- clear: both;
-}
-
-p {
- margin: 0 0 10px;
-}
-
-.lead {
- margin-bottom: 20px;
- font-size: 20px;
- font-weight: 200;
- line-height: 30px;
-}
-
-small {
- font-size: 85%;
-}
-
-strong {
- font-weight: bold;
-}
-
-em {
- font-style: italic;
-}
-
-cite {
- font-style: normal;
-}
-
-.muted {
- color: #999999;
-}
-
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
- margin: 10px 0;
- font-family: inherit;
- font-weight: bold;
- line-height: 1;
- color: inherit;
- text-rendering: optimizelegibility;
-}
-
-h1 small,
-h2 small,
-h3 small,
-h4 small,
-h5 small,
-h6 small {
- font-weight: normal;
- line-height: 1;
- color: #999999;
-}
-
-h1 {
- font-size: 36px;
- line-height: 40px;
-}
-
-h2 {
- font-size: 30px;
- line-height: 40px;
-}
-
-h3 {
- font-size: 24px;
- line-height: 40px;
-}
-
-h4 {
- font-size: 18px;
- line-height: 20px;
-}
-
-h5 {
- font-size: 14px;
- line-height: 20px;
-}
-
-h6 {
- font-size: 12px;
- line-height: 20px;
-}
-
-h1 small {
- font-size: 24px;
-}
-
-h2 small {
- font-size: 18px;
-}
-
-h3 small {
- font-size: 14px;
-}
-
-h4 small {
- font-size: 14px;
-}
-
-.page-header {
- padding-bottom: 9px;
- margin: 20px 0 30px;
- border-bottom: 1px solid #eeeeee;
-}
-
-ul,
-ol {
- padding: 0;
- margin: 0 0 10px 25px;
-}
-
-ul ul,
-ul ol,
-ol ol,
-ol ul {
- margin-bottom: 0;
-}
-
-li {
- line-height: 20px;
-}
-
-ul.unstyled,
-ol.unstyled {
- margin-left: 0;
- list-style: none;
-}
-
-dl {
- margin-bottom: 20px;
-}
-
-dt,
-dd {
- line-height: 20px;
-}
-
-dt {
- font-weight: bold;
-}
-
-dd {
- margin-left: 10px;
-}
-
-.dl-horizontal dt {
- float: left;
- width: 120px;
- overflow: hidden;
- clear: left;
- text-align: right;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.dl-horizontal dd {
- margin-left: 130px;
-}
-
-hr {
- margin: 20px 0;
- border: 0;
- border-top: 1px solid #eeeeee;
- border-bottom: 1px solid #ffffff;
-}
-
-abbr[title] {
- cursor: help;
- border-bottom: 1px dotted #999999;
-}
-
-abbr.initialism {
- font-size: 90%;
- text-transform: uppercase;
-}
-
-blockquote {
- padding: 0 0 0 15px;
- margin: 0 0 20px;
- border-left: 5px solid #eeeeee;
-}
-
-blockquote p {
- margin-bottom: 0;
- font-size: 16px;
- font-weight: 300;
- line-height: 25px;
-}
-
-blockquote small {
- display: block;
- line-height: 20px;
- color: #999999;
-}
-
-blockquote small:before {
- content: '\2014 \00A0';
-}
-
-blockquote.pull-right {
- float: right;
- padding-right: 15px;
- padding-left: 0;
- border-right: 5px solid #eeeeee;
- border-left: 0;
-}
-
-blockquote.pull-right p,
-blockquote.pull-right small {
- text-align: right;
-}
-
-blockquote.pull-right small:before {
- content: '';
-}
-
-blockquote.pull-right small:after {
- content: '\00A0 \2014';
-}
-
-q:before,
-q:after,
-blockquote:before,
-blockquote:after {
- content: "";
-}
-
-address {
- display: block;
- margin-bottom: 20px;
- font-style: normal;
- line-height: 20px;
-}
-
-code,
-pre {
- padding: 0 3px 2px;
- font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
- font-size: 12px;
- color: #333333;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
-}
-
-code {
- padding: 2px 4px;
- color: #d14;
- background-color: #f7f7f9;
- border: 1px solid #e1e1e8;
-}
-
-pre {
- display: block;
- padding: 9.5px;
- margin: 0 0 10px;
- font-size: 13px;
- line-height: 20px;
- word-break: break-all;
- word-wrap: break-word;
- white-space: pre;
- white-space: pre-wrap;
- background-color: #f5f5f5;
- border: 1px solid #ccc;
- border: 1px solid rgba(0, 0, 0, 0.15);
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
-}
-
-pre.prettyprint {
- margin-bottom: 20px;
-}
-
-pre code {
- padding: 0;
- color: inherit;
- background-color: transparent;
- border: 0;
-}
-
-.pre-scrollable {
- max-height: 340px;
- overflow-y: scroll;
-}
-
-form {
- margin: 0 0 20px;
-}
-
-fieldset {
- padding: 0;
- margin: 0;
- border: 0;
-}
-
-legend {
- display: block;
- width: 100%;
- padding: 0;
- margin-bottom: 20px;
- font-size: 21px;
- line-height: 40px;
- color: #333333;
- border: 0;
- border-bottom: 1px solid #e5e5e5;
-}
-
-legend small {
- font-size: 15px;
- color: #999999;
-}
-
-label,
-input,
-button,
-select,
-textarea {
- font-size: 14px;
- font-weight: normal;
- line-height: 20px;
-}
-
-input,
-button,
-select,
-textarea {
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
-}
-
-label {
- display: block;
- margin-bottom: 5px;
-}
-
-select,
-textarea,
-input[type="text"],
-input[type="password"],
-input[type="datetime"],
-input[type="datetime-local"],
-input[type="date"],
-input[type="month"],
-input[type="time"],
-input[type="week"],
-input[type="number"],
-input[type="email"],
-input[type="url"],
-input[type="search"],
-input[type="tel"],
-input[type="color"],
-.uneditable-input {
- display: inline-block;
- height: 20px;
- padding: 4px 6px;
- margin-bottom: 9px;
- font-size: 14px;
- line-height: 20px;
- color: #555555;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
-}
-
-input,
-textarea {
- width: 210px;
-}
-
-textarea {
- height: auto;
-}
-
-textarea,
-input[type="text"],
-input[type="password"],
-input[type="datetime"],
-input[type="datetime-local"],
-input[type="date"],
-input[type="month"],
-input[type="time"],
-input[type="week"],
-input[type="number"],
-input[type="email"],
-input[type="url"],
-input[type="search"],
-input[type="tel"],
-input[type="color"],
-.uneditable-input {
- background-color: #ffffff;
- border: 1px solid #cccccc;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
- -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
- -o-transition: border linear 0.2s, box-shadow linear 0.2s;
- transition: border linear 0.2s, box-shadow linear 0.2s;
-}
-
-textarea:focus,
-input[type="text"]:focus,
-input[type="password"]:focus,
-input[type="datetime"]:focus,
-input[type="datetime-local"]:focus,
-input[type="date"]:focus,
-input[type="month"]:focus,
-input[type="time"]:focus,
-input[type="week"]:focus,
-input[type="number"]:focus,
-input[type="email"]:focus,
-input[type="url"]:focus,
-input[type="search"]:focus,
-input[type="tel"]:focus,
-input[type="color"]:focus,
-.uneditable-input:focus {
- border-color: rgba(82, 168, 236, 0.8);
- outline: 0;
- outline: thin dotted \9;
- /* IE6-9 */
-
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-}
-
-input[type="radio"],
-input[type="checkbox"] {
- margin: 4px 0 0;
- margin-top: 1px \9;
- *margin-top: 0;
- line-height: normal;
- cursor: pointer;
-}
-
-input[type="file"],
-input[type="image"],
-input[type="submit"],
-input[type="reset"],
-input[type="button"],
-input[type="radio"],
-input[type="checkbox"] {
- width: auto;
-}
-
-select,
-input[type="file"] {
- height: 30px;
- /* In IE7, the height of the select element cannot be changed by height, only font-size */
-
- *margin-top: 4px;
- /* For IE7, add top margin to align select with labels */
-
- line-height: 30px;
-}
-
-select {
- width: 220px;
- background-color: #ffffff;
- border: 1px solid #bbb;
-}
-
-select[multiple],
-select[size] {
- height: auto;
-}
-
-select:focus,
-input[type="file"]:focus,
-input[type="radio"]:focus,
-input[type="checkbox"]:focus {
- outline: thin dotted #333;
- outline: 5px auto -webkit-focus-ring-color;
- outline-offset: -2px;
-}
-
-.uneditable-input,
-.uneditable-textarea {
- color: #999999;
- cursor: not-allowed;
- background-color: #fcfcfc;
- border-color: #cccccc;
- -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
- -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
- box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
-}
-
-.uneditable-input {
- overflow: hidden;
- white-space: nowrap;
-}
-
-.uneditable-textarea {
- width: auto;
- height: auto;
-}
-
-input:-moz-placeholder,
-textarea:-moz-placeholder {
- color: #999999;
-}
-
-input:-ms-input-placeholder,
-textarea:-ms-input-placeholder {
- color: #999999;
-}
-
-input::-webkit-input-placeholder,
-textarea::-webkit-input-placeholder {
- color: #999999;
-}
-
-.radio,
-.checkbox {
- min-height: 18px;
- padding-left: 18px;
-}
-
-.radio input[type="radio"],
-.checkbox input[type="checkbox"] {
- float: left;
- margin-left: -18px;
-}
-
-.controls > .radio:first-child,
-.controls > .checkbox:first-child {
- padding-top: 5px;
-}
-
-.radio.inline,
-.checkbox.inline {
- display: inline-block;
- padding-top: 5px;
- margin-bottom: 0;
- vertical-align: middle;
-}
-
-.radio.inline + .radio.inline,
-.checkbox.inline + .checkbox.inline {
- margin-left: 10px;
-}
-
-.input-mini {
- width: 60px;
-}
-
-.input-small {
- width: 90px;
-}
-
-.input-medium {
- width: 150px;
-}
-
-.input-large {
- width: 210px;
-}
-
-.input-xlarge {
- width: 270px;
-}
-
-.input-xxlarge {
- width: 530px;
-}
-
-input[class*="span"],
-select[class*="span"],
-textarea[class*="span"],
-.uneditable-input[class*="span"],
-.row-fluid input[class*="span"],
-.row-fluid select[class*="span"],
-.row-fluid textarea[class*="span"],
-.row-fluid .uneditable-input[class*="span"] {
- float: none;
- margin-left: 0;
-}
-
-.input-append input[class*="span"],
-.input-append .uneditable-input[class*="span"],
-.input-prepend input[class*="span"],
-.input-prepend .uneditable-input[class*="span"],
-.row-fluid input[class*="span"],
-.row-fluid select[class*="span"],
-.row-fluid textarea[class*="span"],
-.row-fluid .uneditable-input[class*="span"],
-.row-fluid .input-prepend [class*="span"],
-.row-fluid .input-append [class*="span"] {
- display: inline-block;
-}
-
-input,
-textarea,
-.uneditable-input {
- margin-left: 0;
-}
-
-.controls-row [class*="span"] + [class*="span"] {
- margin-left: 20px;
-}
-
-input.span12,
-textarea.span12,
-.uneditable-input.span12 {
- width: 926px;
-}
-
-input.span11,
-textarea.span11,
-.uneditable-input.span11 {
- width: 846px;
-}
-
-input.span10,
-textarea.span10,
-.uneditable-input.span10 {
- width: 766px;
-}
-
-input.span9,
-textarea.span9,
-.uneditable-input.span9 {
- width: 686px;
-}
-
-input.span8,
-textarea.span8,
-.uneditable-input.span8 {
- width: 606px;
-}
-
-input.span7,
-textarea.span7,
-.uneditable-input.span7 {
- width: 526px;
-}
-
-input.span6,
-textarea.span6,
-.uneditable-input.span6 {
- width: 446px;
-}
-
-input.span5,
-textarea.span5,
-.uneditable-input.span5 {
- width: 366px;
-}
-
-input.span4,
-textarea.span4,
-.uneditable-input.span4 {
- width: 286px;
-}
-
-input.span3,
-textarea.span3,
-.uneditable-input.span3 {
- width: 206px;
-}
-
-input.span2,
-textarea.span2,
-.uneditable-input.span2 {
- width: 126px;
-}
-
-input.span1,
-textarea.span1,
-.uneditable-input.span1 {
- width: 46px;
-}
-
-.controls-row {
- *zoom: 1;
-}
-
-.controls-row:before,
-.controls-row:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.controls-row:after {
- clear: both;
-}
-
-.controls-row [class*="span"] {
- float: left;
-}
-
-input[disabled],
-select[disabled],
-textarea[disabled],
-input[readonly],
-select[readonly],
-textarea[readonly] {
- cursor: not-allowed;
- background-color: #eeeeee;
-}
-
-input[type="radio"][disabled],
-input[type="checkbox"][disabled],
-input[type="radio"][readonly],
-input[type="checkbox"][readonly] {
- background-color: transparent;
-}
-
-.control-group.warning > label,
-.control-group.warning .help-block,
-.control-group.warning .help-inline {
- color: #c09853;
-}
-
-.control-group.warning .checkbox,
-.control-group.warning .radio,
-.control-group.warning input,
-.control-group.warning select,
-.control-group.warning textarea {
- color: #c09853;
- border-color: #c09853;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-}
-
-.control-group.warning .checkbox:focus,
-.control-group.warning .radio:focus,
-.control-group.warning input:focus,
-.control-group.warning select:focus,
-.control-group.warning textarea:focus {
- border-color: #a47e3c;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
-}
-
-.control-group.warning .input-prepend .add-on,
-.control-group.warning .input-append .add-on {
- color: #c09853;
- background-color: #fcf8e3;
- border-color: #c09853;
-}
-
-.control-group.error > label,
-.control-group.error .help-block,
-.control-group.error .help-inline {
- color: #b94a48;
-}
-
-.control-group.error .checkbox,
-.control-group.error .radio,
-.control-group.error input,
-.control-group.error select,
-.control-group.error textarea {
- color: #b94a48;
- border-color: #b94a48;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-}
-
-.control-group.error .checkbox:focus,
-.control-group.error .radio:focus,
-.control-group.error input:focus,
-.control-group.error select:focus,
-.control-group.error textarea:focus {
- border-color: #953b39;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
-}
-
-.control-group.error .input-prepend .add-on,
-.control-group.error .input-append .add-on {
- color: #b94a48;
- background-color: #f2dede;
- border-color: #b94a48;
-}
-
-.control-group.success > label,
-.control-group.success .help-block,
-.control-group.success .help-inline {
- color: #468847;
-}
-
-.control-group.success .checkbox,
-.control-group.success .radio,
-.control-group.success input,
-.control-group.success select,
-.control-group.success textarea {
- color: #468847;
- border-color: #468847;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-}
-
-.control-group.success .checkbox:focus,
-.control-group.success .radio:focus,
-.control-group.success input:focus,
-.control-group.success select:focus,
-.control-group.success textarea:focus {
- border-color: #356635;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
-}
-
-.control-group.success .input-prepend .add-on,
-.control-group.success .input-append .add-on {
- color: #468847;
- background-color: #dff0d8;
- border-color: #468847;
-}
-
-input:focus:required:invalid,
-textarea:focus:required:invalid,
-select:focus:required:invalid {
- color: #b94a48;
- border-color: #ee5f5b;
-}
-
-input:focus:required:invalid:focus,
-textarea:focus:required:invalid:focus,
-select:focus:required:invalid:focus {
- border-color: #e9322d;
- -webkit-box-shadow: 0 0 6px #f8b9b7;
- -moz-box-shadow: 0 0 6px #f8b9b7;
- box-shadow: 0 0 6px #f8b9b7;
-}
-
-.form-actions {
- padding: 19px 20px 20px;
- margin-top: 20px;
- margin-bottom: 20px;
- background-color: #f5f5f5;
- border-top: 1px solid #e5e5e5;
- *zoom: 1;
-}
-
-.form-actions:before,
-.form-actions:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.form-actions:after {
- clear: both;
-}
-
-.help-block,
-.help-inline {
- color: #595959;
-}
-
-.help-block {
- display: block;
- margin-bottom: 10px;
-}
-
-.help-inline {
- display: inline-block;
- *display: inline;
- padding-left: 5px;
- vertical-align: middle;
- *zoom: 1;
-}
-
-.input-append,
-.input-prepend {
- margin-bottom: 5px;
- font-size: 0;
- white-space: nowrap;
-}
-
-.input-append input,
-.input-prepend input,
-.input-append select,
-.input-prepend select,
-.input-append .uneditable-input,
-.input-prepend .uneditable-input {
- position: relative;
- margin-bottom: 0;
- *margin-left: 0;
- font-size: 14px;
- vertical-align: top;
- -webkit-border-radius: 0 3px 3px 0;
- -moz-border-radius: 0 3px 3px 0;
- border-radius: 0 3px 3px 0;
-}
-
-.input-append input:focus,
-.input-prepend input:focus,
-.input-append select:focus,
-.input-prepend select:focus,
-.input-append .uneditable-input:focus,
-.input-prepend .uneditable-input:focus {
- z-index: 2;
-}
-
-.input-append .add-on,
-.input-prepend .add-on {
- display: inline-block;
- width: auto;
- height: 20px;
- min-width: 16px;
- padding: 4px 5px;
- font-size: 14px;
- font-weight: normal;
- line-height: 20px;
- text-align: center;
- text-shadow: 0 1px 0 #ffffff;
- background-color: #eeeeee;
- border: 1px solid #ccc;
-}
-
-.input-append .add-on,
-.input-prepend .add-on,
-.input-append .btn,
-.input-prepend .btn {
- margin-left: -1px;
- vertical-align: top;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.input-append .active,
-.input-prepend .active {
- background-color: #a9dba9;
- border-color: #46a546;
-}
-
-.input-prepend .add-on,
-.input-prepend .btn {
- margin-right: -1px;
-}
-
-.input-prepend .add-on:first-child,
-.input-prepend .btn:first-child {
- -webkit-border-radius: 3px 0 0 3px;
- -moz-border-radius: 3px 0 0 3px;
- border-radius: 3px 0 0 3px;
-}
-
-.input-append input,
-.input-append select,
-.input-append .uneditable-input {
- -webkit-border-radius: 3px 0 0 3px;
- -moz-border-radius: 3px 0 0 3px;
- border-radius: 3px 0 0 3px;
-}
-
-.input-append .add-on:last-child,
-.input-append .btn:last-child {
- -webkit-border-radius: 0 3px 3px 0;
- -moz-border-radius: 0 3px 3px 0;
- border-radius: 0 3px 3px 0;
-}
-
-.input-prepend.input-append input,
-.input-prepend.input-append select,
-.input-prepend.input-append .uneditable-input {
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.input-prepend.input-append .add-on:first-child,
-.input-prepend.input-append .btn:first-child {
- margin-right: -1px;
- -webkit-border-radius: 3px 0 0 3px;
- -moz-border-radius: 3px 0 0 3px;
- border-radius: 3px 0 0 3px;
-}
-
-.input-prepend.input-append .add-on:last-child,
-.input-prepend.input-append .btn:last-child {
- margin-left: -1px;
- -webkit-border-radius: 0 3px 3px 0;
- -moz-border-radius: 0 3px 3px 0;
- border-radius: 0 3px 3px 0;
-}
-
-input.search-query {
- padding-right: 14px;
- padding-right: 4px \9;
- padding-left: 14px;
- padding-left: 4px \9;
- /* IE7-8 doesn't have border-radius, so don't indent the padding */
-
- margin-bottom: 0;
- -webkit-border-radius: 15px;
- -moz-border-radius: 15px;
- border-radius: 15px;
-}
-
-/* Allow for input prepend/append in search forms */
-
-.form-search .input-append .search-query,
-.form-search .input-prepend .search-query {
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.form-search .input-append .search-query {
- -webkit-border-radius: 14px 0 0 14px;
- -moz-border-radius: 14px 0 0 14px;
- border-radius: 14px 0 0 14px;
-}
-
-.form-search .input-append .btn {
- -webkit-border-radius: 0 14px 14px 0;
- -moz-border-radius: 0 14px 14px 0;
- border-radius: 0 14px 14px 0;
-}
-
-.form-search .input-prepend .search-query {
- -webkit-border-radius: 0 14px 14px 0;
- -moz-border-radius: 0 14px 14px 0;
- border-radius: 0 14px 14px 0;
-}
-
-.form-search .input-prepend .btn {
- -webkit-border-radius: 14px 0 0 14px;
- -moz-border-radius: 14px 0 0 14px;
- border-radius: 14px 0 0 14px;
-}
-
-.form-search input,
-.form-inline input,
-.form-horizontal input,
-.form-search textarea,
-.form-inline textarea,
-.form-horizontal textarea,
-.form-search select,
-.form-inline select,
-.form-horizontal select,
-.form-search .help-inline,
-.form-inline .help-inline,
-.form-horizontal .help-inline,
-.form-search .uneditable-input,
-.form-inline .uneditable-input,
-.form-horizontal .uneditable-input,
-.form-search .input-prepend,
-.form-inline .input-prepend,
-.form-horizontal .input-prepend,
-.form-search .input-append,
-.form-inline .input-append,
-.form-horizontal .input-append {
- display: inline-block;
- *display: inline;
- margin-bottom: 0;
- vertical-align: middle;
- *zoom: 1;
-}
-
-.form-search .hide,
-.form-inline .hide,
-.form-horizontal .hide {
- display: none;
-}
-
-.form-search label,
-.form-inline label,
-.form-search .btn-group,
-.form-inline .btn-group {
- display: inline-block;
-}
-
-.form-search .input-append,
-.form-inline .input-append,
-.form-search .input-prepend,
-.form-inline .input-prepend {
- margin-bottom: 0;
-}
-
-.form-search .radio,
-.form-search .checkbox,
-.form-inline .radio,
-.form-inline .checkbox {
- padding-left: 0;
- margin-bottom: 0;
- vertical-align: middle;
-}
-
-.form-search .radio input[type="radio"],
-.form-search .checkbox input[type="checkbox"],
-.form-inline .radio input[type="radio"],
-.form-inline .checkbox input[type="checkbox"] {
- float: left;
- margin-right: 3px;
- margin-left: 0;
-}
-
-.control-group {
- margin-bottom: 10px;
-}
-
-legend + .control-group {
- margin-top: 20px;
- -webkit-margin-top-collapse: separate;
-}
-
-.form-horizontal .control-group {
- margin-bottom: 20px;
- *zoom: 1;
-}
-
-.form-horizontal .control-group:before,
-.form-horizontal .control-group:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.form-horizontal .control-group:after {
- clear: both;
-}
-
-.form-horizontal .control-label {
- float: left;
- width: 140px;
- padding-top: 5px;
- text-align: right;
-}
-
-.form-horizontal .controls {
- *display: inline-block;
- *padding-left: 20px;
- margin-left: 160px;
- *margin-left: 0;
-}
-
-.form-horizontal .controls:first-child {
- *padding-left: 160px;
-}
-
-.form-horizontal .help-block {
- margin-top: 10px;
- margin-bottom: 0;
-}
-
-.form-horizontal .form-actions {
- padding-left: 160px;
-}
-
-table {
- max-width: 100%;
- background-color: transparent;
- border-collapse: collapse;
- border-spacing: 0;
-}
-
-.table {
- width: 100%;
- margin-bottom: 20px;
-}
-
-.table th,
-.table td {
- padding: 8px;
- line-height: 20px;
- text-align: left;
- vertical-align: top;
- border-top: 1px solid #dddddd;
-}
-
-.table th {
- font-weight: bold;
-}
-
-.table thead th {
- vertical-align: bottom;
-}
-
-.table caption + thead tr:first-child th,
-.table caption + thead tr:first-child td,
-.table colgroup + thead tr:first-child th,
-.table colgroup + thead tr:first-child td,
-.table thead:first-child tr:first-child th,
-.table thead:first-child tr:first-child td {
- border-top: 0;
-}
-
-.table tbody + tbody {
- border-top: 2px solid #dddddd;
-}
-
-.table-condensed th,
-.table-condensed td {
- padding: 4px 5px;
-}
-
-.table-bordered {
- border: 1px solid #dddddd;
- border-collapse: separate;
- *border-collapse: collapse;
- border-left: 0;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
-}
-
-.table-bordered th,
-.table-bordered td {
- border-left: 1px solid #dddddd;
-}
-
-.table-bordered caption + thead tr:first-child th,
-.table-bordered caption + tbody tr:first-child th,
-.table-bordered caption + tbody tr:first-child td,
-.table-bordered colgroup + thead tr:first-child th,
-.table-bordered colgroup + tbody tr:first-child th,
-.table-bordered colgroup + tbody tr:first-child td,
-.table-bordered thead:first-child tr:first-child th,
-.table-bordered tbody:first-child tr:first-child th,
-.table-bordered tbody:first-child tr:first-child td {
- border-top: 0;
-}
-
-.table-bordered thead:first-child tr:first-child th:first-child,
-.table-bordered tbody:first-child tr:first-child td:first-child {
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-topleft: 4px;
-}
-
-.table-bordered thead:first-child tr:first-child th:last-child,
-.table-bordered tbody:first-child tr:first-child td:last-child {
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
- -moz-border-radius-topright: 4px;
-}
-
-.table-bordered thead:last-child tr:last-child th:first-child,
-.table-bordered tbody:last-child tr:last-child td:first-child,
-.table-bordered tfoot:last-child tr:last-child td:first-child {
- -webkit-border-radius: 0 0 0 4px;
- -moz-border-radius: 0 0 0 4px;
- border-radius: 0 0 0 4px;
- -webkit-border-bottom-left-radius: 4px;
- border-bottom-left-radius: 4px;
- -moz-border-radius-bottomleft: 4px;
-}
-
-.table-bordered thead:last-child tr:last-child th:last-child,
-.table-bordered tbody:last-child tr:last-child td:last-child,
-.table-bordered tfoot:last-child tr:last-child td:last-child {
- -webkit-border-bottom-right-radius: 4px;
- border-bottom-right-radius: 4px;
- -moz-border-radius-bottomright: 4px;
-}
-
-.table-bordered caption + thead tr:first-child th:first-child,
-.table-bordered caption + tbody tr:first-child td:first-child,
-.table-bordered colgroup + thead tr:first-child th:first-child,
-.table-bordered colgroup + tbody tr:first-child td:first-child {
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-topleft: 4px;
-}
-
-.table-bordered caption + thead tr:first-child th:last-child,
-.table-bordered caption + tbody tr:first-child td:last-child,
-.table-bordered colgroup + thead tr:first-child th:last-child,
-.table-bordered colgroup + tbody tr:first-child td:last-child {
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
- -moz-border-right-topleft: 4px;
-}
-
-.table-striped tbody tr:nth-child(odd) td,
-.table-striped tbody tr:nth-child(odd) th {
- background-color: #f9f9f9;
-}
-
-.table-hover tbody tr:hover td,
-.table-hover tbody tr:hover th {
- background-color: #f5f5f5;
-}
-
-table [class*=span],
-.row-fluid table [class*=span] {
- display: table-cell;
- float: none;
- margin-left: 0;
-}
-
-table .span1 {
- float: none;
- width: 44px;
- margin-left: 0;
-}
-
-table .span2 {
- float: none;
- width: 124px;
- margin-left: 0;
-}
-
-table .span3 {
- float: none;
- width: 204px;
- margin-left: 0;
-}
-
-table .span4 {
- float: none;
- width: 284px;
- margin-left: 0;
-}
-
-table .span5 {
- float: none;
- width: 364px;
- margin-left: 0;
-}
-
-table .span6 {
- float: none;
- width: 444px;
- margin-left: 0;
-}
-
-table .span7 {
- float: none;
- width: 524px;
- margin-left: 0;
-}
-
-table .span8 {
- float: none;
- width: 604px;
- margin-left: 0;
-}
-
-table .span9 {
- float: none;
- width: 684px;
- margin-left: 0;
-}
-
-table .span10 {
- float: none;
- width: 764px;
- margin-left: 0;
-}
-
-table .span11 {
- float: none;
- width: 844px;
- margin-left: 0;
-}
-
-table .span12 {
- float: none;
- width: 924px;
- margin-left: 0;
-}
-
-table .span13 {
- float: none;
- width: 1004px;
- margin-left: 0;
-}
-
-table .span14 {
- float: none;
- width: 1084px;
- margin-left: 0;
-}
-
-table .span15 {
- float: none;
- width: 1164px;
- margin-left: 0;
-}
-
-table .span16 {
- float: none;
- width: 1244px;
- margin-left: 0;
-}
-
-table .span17 {
- float: none;
- width: 1324px;
- margin-left: 0;
-}
-
-table .span18 {
- float: none;
- width: 1404px;
- margin-left: 0;
-}
-
-table .span19 {
- float: none;
- width: 1484px;
- margin-left: 0;
-}
-
-table .span20 {
- float: none;
- width: 1564px;
- margin-left: 0;
-}
-
-table .span21 {
- float: none;
- width: 1644px;
- margin-left: 0;
-}
-
-table .span22 {
- float: none;
- width: 1724px;
- margin-left: 0;
-}
-
-table .span23 {
- float: none;
- width: 1804px;
- margin-left: 0;
-}
-
-table .span24 {
- float: none;
- width: 1884px;
- margin-left: 0;
-}
-
-.table tbody tr.success td {
- background-color: #dff0d8;
-}
-
-.table tbody tr.error td {
- background-color: #f2dede;
-}
-
-.table tbody tr.info td {
- background-color: #d9edf7;
-}
-
-[class^="icon-"],
-[class*=" icon-"] {
- display: inline-block;
- width: 14px;
- height: 14px;
- margin-top: 1px;
- *margin-right: .3em;
- line-height: 14px;
- vertical-align: text-top;
- background-image: url("../img/glyphicons-halflings.png");
- background-position: 14px 14px;
- background-repeat: no-repeat;
-}
-
-/* White icons with optional class, or on hover/active states of certain elements */
-
-.icon-white,
-.nav > .active > a > [class^="icon-"],
-.nav > .active > a > [class*=" icon-"],
-.dropdown-menu > li > a:hover > [class^="icon-"],
-.dropdown-menu > li > a:hover > [class*=" icon-"],
-.dropdown-menu > .active > a > [class^="icon-"],
-.dropdown-menu > .active > a > [class*=" icon-"] {
- background-image: url("../img/glyphicons-halflings-white.png");
-}
-
-.icon-glass {
- background-position: 0 0;
-}
-
-.icon-music {
- background-position: -24px 0;
-}
-
-.icon-search {
- background-position: -48px 0;
-}
-
-.icon-envelope {
- background-position: -72px 0;
-}
-
-.icon-heart {
- background-position: -96px 0;
-}
-
-.icon-star {
- background-position: -120px 0;
-}
-
-.icon-star-empty {
- background-position: -144px 0;
-}
-
-.icon-user {
- background-position: -168px 0;
-}
-
-.icon-film {
- background-position: -192px 0;
-}
-
-.icon-th-large {
- background-position: -216px 0;
-}
-
-.icon-th {
- background-position: -240px 0;
-}
-
-.icon-th-list {
- background-position: -264px 0;
-}
-
-.icon-ok {
- background-position: -288px 0;
-}
-
-.icon-remove {
- background-position: -312px 0;
-}
-
-.icon-zoom-in {
- background-position: -336px 0;
-}
-
-.icon-zoom-out {
- background-position: -360px 0;
-}
-
-.icon-off {
- background-position: -384px 0;
-}
-
-.icon-signal {
- background-position: -408px 0;
-}
-
-.icon-cog {
- background-position: -432px 0;
-}
-
-.icon-trash {
- background-position: -456px 0;
-}
-
-.icon-home {
- background-position: 0 -24px;
-}
-
-.icon-file {
- background-position: -24px -24px;
-}
-
-.icon-time {
- background-position: -48px -24px;
-}
-
-.icon-road {
- background-position: -72px -24px;
-}
-
-.icon-download-alt {
- background-position: -96px -24px;
-}
-
-.icon-download {
- background-position: -120px -24px;
-}
-
-.icon-upload {
- background-position: -144px -24px;
-}
-
-.icon-inbox {
- background-position: -168px -24px;
-}
-
-.icon-play-circle {
- background-position: -192px -24px;
-}
-
-.icon-repeat {
- background-position: -216px -24px;
-}
-
-.icon-refresh {
- background-position: -240px -24px;
-}
-
-.icon-list-alt {
- background-position: -264px -24px;
-}
-
-.icon-lock {
- background-position: -287px -24px;
-}
-
-.icon-flag {
- background-position: -312px -24px;
-}
-
-.icon-headphones {
- background-position: -336px -24px;
-}
-
-.icon-volume-off {
- background-position: -360px -24px;
-}
-
-.icon-volume-down {
- background-position: -384px -24px;
-}
-
-.icon-volume-up {
- background-position: -408px -24px;
-}
-
-.icon-qrcode {
- background-position: -432px -24px;
-}
-
-.icon-barcode {
- background-position: -456px -24px;
-}
-
-.icon-tag {
- background-position: 0 -48px;
-}
-
-.icon-tags {
- background-position: -25px -48px;
-}
-
-.icon-book {
- background-position: -48px -48px;
-}
-
-.icon-bookmark {
- background-position: -72px -48px;
-}
-
-.icon-print {
- background-position: -96px -48px;
-}
-
-.icon-camera {
- background-position: -120px -48px;
-}
-
-.icon-font {
- background-position: -144px -48px;
-}
-
-.icon-bold {
- background-position: -167px -48px;
-}
-
-.icon-italic {
- background-position: -192px -48px;
-}
-
-.icon-text-height {
- background-position: -216px -48px;
-}
-
-.icon-text-width {
- background-position: -240px -48px;
-}
-
-.icon-align-left {
- background-position: -264px -48px;
-}
-
-.icon-align-center {
- background-position: -288px -48px;
-}
-
-.icon-align-right {
- background-position: -312px -48px;
-}
-
-.icon-align-justify {
- background-position: -336px -48px;
-}
-
-.icon-list {
- background-position: -360px -48px;
-}
-
-.icon-indent-left {
- background-position: -384px -48px;
-}
-
-.icon-indent-right {
- background-position: -408px -48px;
-}
-
-.icon-facetime-video {
- background-position: -432px -48px;
-}
-
-.icon-picture {
- background-position: -456px -48px;
-}
-
-.icon-pencil {
- background-position: 0 -72px;
-}
-
-.icon-map-marker {
- background-position: -24px -72px;
-}
-
-.icon-adjust {
- background-position: -48px -72px;
-}
-
-.icon-tint {
- background-position: -72px -72px;
-}
-
-.icon-edit {
- background-position: -96px -72px;
-}
-
-.icon-share {
- background-position: -120px -72px;
-}
-
-.icon-check {
- background-position: -144px -72px;
-}
-
-.icon-move {
- background-position: -168px -72px;
-}
-
-.icon-step-backward {
- background-position: -192px -72px;
-}
-
-.icon-fast-backward {
- background-position: -216px -72px;
-}
-
-.icon-backward {
- background-position: -240px -72px;
-}
-
-.icon-play {
- background-position: -264px -72px;
-}
-
-.icon-pause {
- background-position: -288px -72px;
-}
-
-.icon-stop {
- background-position: -312px -72px;
-}
-
-.icon-forward {
- background-position: -336px -72px;
-}
-
-.icon-fast-forward {
- background-position: -360px -72px;
-}
-
-.icon-step-forward {
- background-position: -384px -72px;
-}
-
-.icon-eject {
- background-position: -408px -72px;
-}
-
-.icon-chevron-left {
- background-position: -432px -72px;
-}
-
-.icon-chevron-right {
- background-position: -456px -72px;
-}
-
-.icon-plus-sign {
- background-position: 0 -96px;
-}
-
-.icon-minus-sign {
- background-position: -24px -96px;
-}
-
-.icon-remove-sign {
- background-position: -48px -96px;
-}
-
-.icon-ok-sign {
- background-position: -72px -96px;
-}
-
-.icon-question-sign {
- background-position: -96px -96px;
-}
-
-.icon-info-sign {
- background-position: -120px -96px;
-}
-
-.icon-screenshot {
- background-position: -144px -96px;
-}
-
-.icon-remove-circle {
- background-position: -168px -96px;
-}
-
-.icon-ok-circle {
- background-position: -192px -96px;
-}
-
-.icon-ban-circle {
- background-position: -216px -96px;
-}
-
-.icon-arrow-left {
- background-position: -240px -96px;
-}
-
-.icon-arrow-right {
- background-position: -264px -96px;
-}
-
-.icon-arrow-up {
- background-position: -289px -96px;
-}
-
-.icon-arrow-down {
- background-position: -312px -96px;
-}
-
-.icon-share-alt {
- background-position: -336px -96px;
-}
-
-.icon-resize-full {
- background-position: -360px -96px;
-}
-
-.icon-resize-small {
- background-position: -384px -96px;
-}
-
-.icon-plus {
- background-position: -408px -96px;
-}
-
-.icon-minus {
- background-position: -433px -96px;
-}
-
-.icon-asterisk {
- background-position: -456px -96px;
-}
-
-.icon-exclamation-sign {
- background-position: 0 -120px;
-}
-
-.icon-gift {
- background-position: -24px -120px;
-}
-
-.icon-leaf {
- background-position: -48px -120px;
-}
-
-.icon-fire {
- background-position: -72px -120px;
-}
-
-.icon-eye-open {
- background-position: -96px -120px;
-}
-
-.icon-eye-close {
- background-position: -120px -120px;
-}
-
-.icon-warning-sign {
- background-position: -144px -120px;
-}
-
-.icon-plane {
- background-position: -168px -120px;
-}
-
-.icon-calendar {
- background-position: -192px -120px;
-}
-
-.icon-random {
- width: 16px;
- background-position: -216px -120px;
-}
-
-.icon-comment {
- background-position: -240px -120px;
-}
-
-.icon-magnet {
- background-position: -264px -120px;
-}
-
-.icon-chevron-up {
- background-position: -288px -120px;
-}
-
-.icon-chevron-down {
- background-position: -313px -119px;
-}
-
-.icon-retweet {
- background-position: -336px -120px;
-}
-
-.icon-shopping-cart {
- background-position: -360px -120px;
-}
-
-.icon-folder-close {
- background-position: -384px -120px;
-}
-
-.icon-folder-open {
- width: 16px;
- background-position: -408px -120px;
-}
-
-.icon-resize-vertical {
- background-position: -432px -119px;
-}
-
-.icon-resize-horizontal {
- background-position: -456px -118px;
-}
-
-.icon-hdd {
- background-position: 0 -144px;
-}
-
-.icon-bullhorn {
- background-position: -24px -144px;
-}
-
-.icon-bell {
- background-position: -48px -144px;
-}
-
-.icon-certificate {
- background-position: -72px -144px;
-}
-
-.icon-thumbs-up {
- background-position: -96px -144px;
-}
-
-.icon-thumbs-down {
- background-position: -120px -144px;
-}
-
-.icon-hand-right {
- background-position: -144px -144px;
-}
-
-.icon-hand-left {
- background-position: -168px -144px;
-}
-
-.icon-hand-up {
- background-position: -192px -144px;
-}
-
-.icon-hand-down {
- background-position: -216px -144px;
-}
-
-.icon-circle-arrow-right {
- background-position: -240px -144px;
-}
-
-.icon-circle-arrow-left {
- background-position: -264px -144px;
-}
-
-.icon-circle-arrow-up {
- background-position: -288px -144px;
-}
-
-.icon-circle-arrow-down {
- background-position: -312px -144px;
-}
-
-.icon-globe {
- background-position: -336px -144px;
-}
-
-.icon-wrench {
- background-position: -360px -144px;
-}
-
-.icon-tasks {
- background-position: -384px -144px;
-}
-
-.icon-filter {
- background-position: -408px -144px;
-}
-
-.icon-briefcase {
- background-position: -432px -144px;
-}
-
-.icon-fullscreen {
- background-position: -456px -144px;
-}
-
-.dropup,
-.dropdown {
- position: relative;
-}
-
-.dropdown-toggle {
- *margin-bottom: -3px;
-}
-
-.dropdown-toggle:active,
-.open .dropdown-toggle {
- outline: 0;
-}
-
-.caret {
- display: inline-block;
- width: 0;
- height: 0;
- vertical-align: top;
- border-top: 4px solid #000000;
- border-right: 4px solid transparent;
- border-left: 4px solid transparent;
- content: "";
-}
-
-.dropdown .caret {
- margin-top: 8px;
- margin-left: 2px;
-}
-
-.dropdown-menu {
- position: absolute;
- top: 100%;
- left: 0;
- z-index: 1000;
- display: none;
- float: left;
- min-width: 160px;
- padding: 5px 0;
- margin: 2px 0 0;
- list-style: none;
- background-color: #ffffff;
- border: 1px solid #ccc;
- border: 1px solid rgba(0, 0, 0, 0.2);
- *border-right-width: 2px;
- *border-bottom-width: 2px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
- -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
- -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
- box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
- -webkit-background-clip: padding-box;
- -moz-background-clip: padding;
- background-clip: padding-box;
-}
-
-.dropdown-menu.pull-right {
- right: 0;
- left: auto;
-}
-
-.dropdown-menu .divider {
- *width: 100%;
- height: 1px;
- margin: 9px 1px;
- *margin: -5px 0 5px;
- overflow: hidden;
- background-color: #e5e5e5;
- border-bottom: 1px solid #ffffff;
-}
-
-.dropdown-menu a {
- display: block;
- padding: 3px 20px;
- clear: both;
- font-weight: normal;
- line-height: 20px;
- color: #333333;
- white-space: nowrap;
-}
-
-.dropdown-menu li > a:hover,
-.dropdown-menu li > a:focus,
-.dropdown-submenu:hover > a {
- color: #ffffff;
- text-decoration: none;
- background-color: #0088cc;
- background-color: #0081c2;
- background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
- background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
- background-image: -o-linear-gradient(top, #0088cc, #0077b3);
- background-image: linear-gradient(to bottom, #0088cc, #0077b3);
- background-repeat: repeat-x;
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
-}
-
-.dropdown-menu .active > a,
-.dropdown-menu .active > a:hover {
- color: #ffffff;
- text-decoration: none;
- background-color: #0088cc;
- background-color: #0081c2;
- background-image: linear-gradient(to bottom, #0088cc, #0077b3);
- background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
- background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
- background-image: -o-linear-gradient(top, #0088cc, #0077b3);
- background-repeat: repeat-x;
- outline: 0;
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
-}
-
-.dropdown-menu .disabled > a,
-.dropdown-menu .disabled > a:hover {
- color: #999999;
-}
-
-.dropdown-menu .disabled > a:hover {
- text-decoration: none;
- cursor: default;
- background-color: transparent;
-}
-
-.open {
- *z-index: 1000;
-}
-
-.open > .dropdown-menu {
- display: block;
-}
-
-.pull-right > .dropdown-menu {
- right: 0;
- left: auto;
-}
-
-.dropup .caret,
-.navbar-fixed-bottom .dropdown .caret {
- border-top: 0;
- border-bottom: 4px solid #000000;
- content: "\2191";
-}
-
-.dropup .dropdown-menu,
-.navbar-fixed-bottom .dropdown .dropdown-menu {
- top: auto;
- bottom: 100%;
- margin-bottom: 1px;
-}
-
-.dropdown-submenu {
- position: relative;
-}
-
-.dropdown-submenu > .dropdown-menu {
- top: 0;
- left: 100%;
- margin-top: -6px;
- margin-left: -1px;
- -webkit-border-radius: 0 6px 6px 6px;
- -moz-border-radius: 0 6px 6px 6px;
- border-radius: 0 6px 6px 6px;
-}
-
-.dropdown-submenu:hover .dropdown-menu {
- display: block;
-}
-
-.dropdown-submenu > a:after {
- display: block;
- float: right;
- width: 0;
- height: 0;
- margin-top: 5px;
- margin-right: -10px;
- border-color: transparent;
- border-left-color: #cccccc;
- border-style: solid;
- border-width: 5px 0 5px 5px;
- content: " ";
-}
-
-.dropdown-submenu:hover > a:after {
- border-left-color: #ffffff;
-}
-
-.dropdown .dropdown-menu .nav-header {
- padding-right: 20px;
- padding-left: 20px;
-}
-
-.typeahead {
- margin-top: 2px;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
-}
-
-.well {
- min-height: 20px;
- padding: 19px;
- margin-bottom: 20px;
- background-color: #f5f5f5;
- border: 1px solid #e3e3e3;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
- -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
- -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
- box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-}
-
-.well blockquote {
- border-color: #ddd;
- border-color: rgba(0, 0, 0, 0.15);
-}
-
-.well-large {
- padding: 24px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
-}
-
-.well-small {
- padding: 9px;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
-}
-
-.fade {
- opacity: 0;
- -webkit-transition: opacity 0.15s linear;
- -moz-transition: opacity 0.15s linear;
- -o-transition: opacity 0.15s linear;
- transition: opacity 0.15s linear;
-}
-
-.fade.in {
- opacity: 1;
-}
-
-.collapse {
- position: relative;
- height: 0;
- overflow: hidden;
- overflow: visible \9;
- -webkit-transition: height 0.35s ease;
- -moz-transition: height 0.35s ease;
- -o-transition: height 0.35s ease;
- transition: height 0.35s ease;
-}
-
-.collapse.in {
- height: auto;
-}
-
-.close {
- float: right;
- font-size: 20px;
- font-weight: bold;
- line-height: 20px;
- color: #000000;
- text-shadow: 0 1px 0 #ffffff;
- opacity: 0.2;
- filter: alpha(opacity=20);
-}
-
-.close:hover {
- color: #000000;
- text-decoration: none;
- cursor: pointer;
- opacity: 0.4;
- filter: alpha(opacity=40);
-}
-
-button.close {
- padding: 0;
- cursor: pointer;
- background: transparent;
- border: 0;
- -webkit-appearance: none;
-}
-
-.btn {
- display: inline-block;
- *display: inline;
- padding: 4px 14px;
- margin-bottom: 0;
- *margin-left: .3em;
- font-size: 14px;
- line-height: 20px;
- *line-height: 20px;
- color: #333333;
- text-align: center;
- text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
- vertical-align: middle;
- cursor: pointer;
- background-color: #f5f5f5;
- *background-color: #e6e6e6;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
- background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
- background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
- background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
- background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
- background-repeat: repeat-x;
- border: 1px solid #bbbbbb;
- *border: 0;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- border-color: #e6e6e6 #e6e6e6 #bfbfbf;
- border-bottom-color: #a2a2a2;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
- *zoom: 1;
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
- -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn:hover,
-.btn:active,
-.btn.active,
-.btn.disabled,
-.btn[disabled] {
- color: #333333;
- background-color: #e6e6e6;
- *background-color: #d9d9d9;
-}
-
-.btn:active,
-.btn.active {
- background-color: #cccccc \9;
-}
-
-.btn:first-child {
- *margin-left: 0;
-}
-
-.btn:hover {
- color: #333333;
- text-decoration: none;
- background-color: #e6e6e6;
- *background-color: #d9d9d9;
- /* Buttons in IE7 don't get borders, so darken on hover */
-
- background-position: 0 -15px;
- -webkit-transition: background-position 0.1s linear;
- -moz-transition: background-position 0.1s linear;
- -o-transition: background-position 0.1s linear;
- transition: background-position 0.1s linear;
-}
-
-.btn:focus {
- outline: thin dotted #333;
- outline: 5px auto -webkit-focus-ring-color;
- outline-offset: -2px;
-}
-
-.btn.active,
-.btn:active {
- background-color: #e6e6e6;
- background-color: #d9d9d9 \9;
- background-image: none;
- outline: 0;
- -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
- -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
- box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn.disabled,
-.btn[disabled] {
- cursor: default;
- background-color: #e6e6e6;
- background-image: none;
- opacity: 0.65;
- filter: alpha(opacity=65);
- -webkit-box-shadow: none;
- -moz-box-shadow: none;
- box-shadow: none;
-}
-
-.btn-large {
- padding: 9px 14px;
- font-size: 16px;
- line-height: normal;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
- border-radius: 5px;
-}
-
-.btn-large [class^="icon-"] {
- margin-top: 2px;
-}
-
-.btn-small {
- padding: 3px 9px;
- font-size: 12px;
- line-height: 18px;
-}
-
-.btn-small [class^="icon-"] {
- margin-top: 0;
-}
-
-.btn-mini {
- padding: 2px 6px;
- font-size: 11px;
- line-height: 16px;
-}
-
-.btn-block {
- display: block;
- width: 100%;
- padding-right: 0;
- padding-left: 0;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-
-.btn-block + .btn-block {
- margin-top: 5px;
-}
-
-.btn-primary.active,
-.btn-warning.active,
-.btn-danger.active,
-.btn-success.active,
-.btn-info.active,
-.btn-inverse.active {
- color: rgba(255, 255, 255, 0.75);
-}
-
-.btn {
- border-color: #c5c5c5;
- border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25);
-}
-
-.btn-primary {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #006dcc;
- *background-color: #0044cc;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
- background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
- background-image: -o-linear-gradient(top, #0088cc, #0044cc);
- background-image: linear-gradient(to bottom, #0088cc, #0044cc);
- background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
- background-repeat: repeat-x;
- border-color: #0044cc #0044cc #002a80;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-primary:hover,
-.btn-primary:active,
-.btn-primary.active,
-.btn-primary.disabled,
-.btn-primary[disabled] {
- color: #ffffff;
- background-color: #0044cc;
- *background-color: #003bb3;
-}
-
-.btn-primary:active,
-.btn-primary.active {
- background-color: #003399 \9;
-}
-
-.btn-warning {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #faa732;
- *background-color: #f89406;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
- background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
- background-image: -o-linear-gradient(top, #fbb450, #f89406);
- background-image: linear-gradient(to bottom, #fbb450, #f89406);
- background-image: -moz-linear-gradient(top, #fbb450, #f89406);
- background-repeat: repeat-x;
- border-color: #f89406 #f89406 #ad6704;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-warning:hover,
-.btn-warning:active,
-.btn-warning.active,
-.btn-warning.disabled,
-.btn-warning[disabled] {
- color: #ffffff;
- background-color: #f89406;
- *background-color: #df8505;
-}
-
-.btn-warning:active,
-.btn-warning.active {
- background-color: #c67605 \9;
-}
-
-.btn-danger {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #da4f49;
- *background-color: #bd362f;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
- background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
- background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
- background-image: linear-gradient(to bottom, #ee5f5b, #bd362f);
- background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
- background-repeat: repeat-x;
- border-color: #bd362f #bd362f #802420;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-danger:hover,
-.btn-danger:active,
-.btn-danger.active,
-.btn-danger.disabled,
-.btn-danger[disabled] {
- color: #ffffff;
- background-color: #bd362f;
- *background-color: #a9302a;
-}
-
-.btn-danger:active,
-.btn-danger.active {
- background-color: #942a25 \9;
-}
-
-.btn-success {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #5bb75b;
- *background-color: #51a351;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
- background-image: -webkit-linear-gradient(top, #62c462, #51a351);
- background-image: -o-linear-gradient(top, #62c462, #51a351);
- background-image: linear-gradient(to bottom, #62c462, #51a351);
- background-image: -moz-linear-gradient(top, #62c462, #51a351);
- background-repeat: repeat-x;
- border-color: #51a351 #51a351 #387038;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-success:hover,
-.btn-success:active,
-.btn-success.active,
-.btn-success.disabled,
-.btn-success[disabled] {
- color: #ffffff;
- background-color: #51a351;
- *background-color: #499249;
-}
-
-.btn-success:active,
-.btn-success.active {
- background-color: #408140 \9;
-}
-
-.btn-info {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #49afcd;
- *background-color: #2f96b4;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
- background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
- background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
- background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);
- background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
- background-repeat: repeat-x;
- border-color: #2f96b4 #2f96b4 #1f6377;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-info:hover,
-.btn-info:active,
-.btn-info.active,
-.btn-info.disabled,
-.btn-info[disabled] {
- color: #ffffff;
- background-color: #2f96b4;
- *background-color: #2a85a0;
-}
-
-.btn-info:active,
-.btn-info.active {
- background-color: #24748c \9;
-}
-
-.btn-inverse {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #363636;
- *background-color: #222222;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222));
- background-image: -webkit-linear-gradient(top, #444444, #222222);
- background-image: -o-linear-gradient(top, #444444, #222222);
- background-image: linear-gradient(to bottom, #444444, #222222);
- background-image: -moz-linear-gradient(top, #444444, #222222);
- background-repeat: repeat-x;
- border-color: #222222 #222222 #000000;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-inverse:hover,
-.btn-inverse:active,
-.btn-inverse.active,
-.btn-inverse.disabled,
-.btn-inverse[disabled] {
- color: #ffffff;
- background-color: #222222;
- *background-color: #151515;
-}
-
-.btn-inverse:active,
-.btn-inverse.active {
- background-color: #080808 \9;
-}
-
-button.btn,
-input[type="submit"].btn {
- *padding-top: 3px;
- *padding-bottom: 3px;
-}
-
-button.btn::-moz-focus-inner,
-input[type="submit"].btn::-moz-focus-inner {
- padding: 0;
- border: 0;
-}
-
-button.btn.btn-large,
-input[type="submit"].btn.btn-large {
- *padding-top: 7px;
- *padding-bottom: 7px;
-}
-
-button.btn.btn-small,
-input[type="submit"].btn.btn-small {
- *padding-top: 3px;
- *padding-bottom: 3px;
-}
-
-button.btn.btn-mini,
-input[type="submit"].btn.btn-mini {
- *padding-top: 1px;
- *padding-bottom: 1px;
-}
-
-.btn-link,
-.btn-link:active {
- background-color: transparent;
- background-image: none;
- -webkit-box-shadow: none;
- -moz-box-shadow: none;
- box-shadow: none;
-}
-
-.btn-link {
- color: #0088cc;
- cursor: pointer;
- border-color: transparent;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.btn-link:hover {
- color: #005580;
- text-decoration: underline;
- background-color: transparent;
-}
-
-.btn-group {
- position: relative;
- *margin-left: .3em;
- font-size: 0;
- white-space: nowrap;
-}
-
-.btn-group:first-child {
- *margin-left: 0;
-}
-
-.btn-group + .btn-group {
- margin-left: 5px;
-}
-
-.btn-toolbar {
- margin-top: 10px;
- margin-bottom: 10px;
- font-size: 0;
-}
-
-.btn-toolbar .btn-group {
- display: inline-block;
- *display: inline;
- /* IE7 inline-block hack */
-
- *zoom: 1;
-}
-
-.btn-toolbar .btn + .btn,
-.btn-toolbar .btn-group + .btn,
-.btn-toolbar .btn + .btn-group {
- margin-left: 5px;
-}
-
-.btn-group > .btn {
- position: relative;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.btn-group > .btn + .btn {
- margin-left: -1px;
-}
-
-.btn-group > .btn,
-.btn-group > .dropdown-menu {
- font-size: 14px;
-}
-
-.btn-group > .btn-mini {
- font-size: 11px;
-}
-
-.btn-group > .btn-small {
- font-size: 12px;
-}
-
-.btn-group > .btn-large {
- font-size: 16px;
-}
-
-.btn-group > .btn:first-child {
- margin-left: 0;
- -webkit-border-bottom-left-radius: 4px;
- border-bottom-left-radius: 4px;
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-bottomleft: 4px;
- -moz-border-radius-topleft: 4px;
-}
-
-.btn-group > .btn:last-child,
-.btn-group > .dropdown-toggle {
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
- -webkit-border-bottom-right-radius: 4px;
- border-bottom-right-radius: 4px;
- -moz-border-radius-topright: 4px;
- -moz-border-radius-bottomright: 4px;
-}
-
-.btn-group > .btn.large:first-child {
- margin-left: 0;
- -webkit-border-bottom-left-radius: 6px;
- border-bottom-left-radius: 6px;
- -webkit-border-top-left-radius: 6px;
- border-top-left-radius: 6px;
- -moz-border-radius-bottomleft: 6px;
- -moz-border-radius-topleft: 6px;
-}
-
-.btn-group > .btn.large:last-child,
-.btn-group > .large.dropdown-toggle {
- -webkit-border-top-right-radius: 6px;
- border-top-right-radius: 6px;
- -webkit-border-bottom-right-radius: 6px;
- border-bottom-right-radius: 6px;
- -moz-border-radius-topright: 6px;
- -moz-border-radius-bottomright: 6px;
-}
-
-.btn-group > .btn:hover,
-.btn-group > .btn:focus,
-.btn-group > .btn:active,
-.btn-group > .btn.active {
- z-index: 2;
-}
-
-.btn-group .dropdown-toggle:active,
-.btn-group.open .dropdown-toggle {
- outline: 0;
-}
-
-.btn-group > .btn + .dropdown-toggle {
- *padding-top: 5px;
- padding-right: 8px;
- *padding-bottom: 5px;
- padding-left: 8px;
- -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
- -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
- box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn-group > .btn-mini + .dropdown-toggle {
- *padding-top: 2px;
- padding-right: 5px;
- *padding-bottom: 2px;
- padding-left: 5px;
-}
-
-.btn-group > .btn-small + .dropdown-toggle {
- *padding-top: 5px;
- *padding-bottom: 4px;
-}
-
-.btn-group > .btn-large + .dropdown-toggle {
- *padding-top: 7px;
- padding-right: 12px;
- *padding-bottom: 7px;
- padding-left: 12px;
-}
-
-.btn-group.open .dropdown-toggle {
- background-image: none;
- -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
- -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
- box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn-group.open .btn.dropdown-toggle {
- background-color: #e6e6e6;
-}
-
-.btn-group.open .btn-primary.dropdown-toggle {
- background-color: #0044cc;
-}
-
-.btn-group.open .btn-warning.dropdown-toggle {
- background-color: #f89406;
-}
-
-.btn-group.open .btn-danger.dropdown-toggle {
- background-color: #bd362f;
-}
-
-.btn-group.open .btn-success.dropdown-toggle {
- background-color: #51a351;
-}
-
-.btn-group.open .btn-info.dropdown-toggle {
- background-color: #2f96b4;
-}
-
-.btn-group.open .btn-inverse.dropdown-toggle {
- background-color: #222222;
-}
-
-.btn .caret {
- margin-top: 8px;
- margin-left: 0;
-}
-
-.btn-mini .caret,
-.btn-small .caret,
-.btn-large .caret {
- margin-top: 6px;
-}
-
-.btn-large .caret {
- border-top-width: 5px;
- border-right-width: 5px;
- border-left-width: 5px;
-}
-
-.dropup .btn-large .caret {
- border-top: 0;
- border-bottom: 5px solid #000000;
-}
-
-.btn-primary .caret,
-.btn-warning .caret,
-.btn-danger .caret,
-.btn-info .caret,
-.btn-success .caret,
-.btn-inverse .caret {
- border-top-color: #ffffff;
- border-bottom-color: #ffffff;
-}
-
-.btn-group-vertical {
- display: inline-block;
- *display: inline;
- /* IE7 inline-block hack */
-
- *zoom: 1;
-}
-
-.btn-group-vertical .btn {
- display: block;
- float: none;
- width: 100%;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.btn-group-vertical .btn + .btn {
- margin-top: -1px;
- margin-left: 0;
-}
-
-.btn-group-vertical .btn:first-child {
- -webkit-border-radius: 4px 4px 0 0;
- -moz-border-radius: 4px 4px 0 0;
- border-radius: 4px 4px 0 0;
-}
-
-.btn-group-vertical .btn:last-child {
- -webkit-border-radius: 0 0 4px 4px;
- -moz-border-radius: 0 0 4px 4px;
- border-radius: 0 0 4px 4px;
-}
-
-.btn-group-vertical .btn-large:first-child {
- -webkit-border-radius: 6px 6px 0 0;
- -moz-border-radius: 6px 6px 0 0;
- border-radius: 6px 6px 0 0;
-}
-
-.btn-group-vertical .btn-large:last-child {
- -webkit-border-radius: 0 0 6px 6px;
- -moz-border-radius: 0 0 6px 6px;
- border-radius: 0 0 6px 6px;
-}
-
-.alert {
- padding: 8px 35px 8px 14px;
- margin-bottom: 20px;
- color: #c09853;
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
- background-color: #fcf8e3;
- border: 1px solid #fbeed5;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
-}
-
-.alert h4 {
- margin: 0;
-}
-
-.alert .close {
- position: relative;
- top: -2px;
- right: -21px;
- line-height: 20px;
-}
-
-.alert-success {
- color: #468847;
- background-color: #dff0d8;
- border-color: #d6e9c6;
-}
-
-.alert-danger,
-.alert-error {
- color: #b94a48;
- background-color: #f2dede;
- border-color: #eed3d7;
-}
-
-.alert-info {
- color: #3a87ad;
- background-color: #d9edf7;
- border-color: #bce8f1;
-}
-
-.alert-block {
- padding-top: 14px;
- padding-bottom: 14px;
-}
-
-.alert-block > p,
-.alert-block > ul {
- margin-bottom: 0;
-}
-
-.alert-block p + p {
- margin-top: 5px;
-}
-
-.nav {
- margin-bottom: 20px;
- margin-left: 0;
- list-style: none;
-}
-
-.nav > li > a {
- display: block;
-}
-
-.nav > li > a:hover {
- text-decoration: none;
- background-color: #eeeeee;
-}
-
-.nav > .pull-right {
- float: right;
-}
-
-.nav-header {
- display: block;
- padding: 3px 15px;
- font-size: 11px;
- font-weight: bold;
- line-height: 20px;
- color: #999999;
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
- text-transform: uppercase;
-}
-
-.nav li + .nav-header {
- margin-top: 9px;
-}
-
-.nav-list {
- padding-right: 15px;
- padding-left: 15px;
- margin-bottom: 0;
-}
-
-.nav-list > li > a,
-.nav-list .nav-header {
- margin-right: -15px;
- margin-left: -15px;
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
-}
-
-.nav-list > li > a {
- padding: 3px 15px;
-}
-
-.nav-list > .active > a,
-.nav-list > .active > a:hover {
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
- background-color: #0088cc;
-}
-
-.nav-list [class^="icon-"] {
- margin-right: 2px;
-}
-
-.nav-list .divider {
- *width: 100%;
- height: 1px;
- margin: 9px 1px;
- *margin: -5px 0 5px;
- overflow: hidden;
- background-color: #e5e5e5;
- border-bottom: 1px solid #ffffff;
-}
-
-.nav-tabs,
-.nav-pills {
- *zoom: 1;
-}
-
-.nav-tabs:before,
-.nav-pills:before,
-.nav-tabs:after,
-.nav-pills:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.nav-tabs:after,
-.nav-pills:after {
- clear: both;
-}
-
-.nav-tabs > li,
-.nav-pills > li {
- float: left;
-}
-
-.nav-tabs > li > a,
-.nav-pills > li > a {
- padding-right: 12px;
- padding-left: 12px;
- margin-right: 2px;
- line-height: 14px;
-}
-
-.nav-tabs {
- border-bottom: 1px solid #ddd;
-}
-
-.nav-tabs > li {
- margin-bottom: -1px;
-}
-
-.nav-tabs > li > a {
- padding-top: 8px;
- padding-bottom: 8px;
- line-height: 20px;
- border: 1px solid transparent;
- -webkit-border-radius: 4px 4px 0 0;
- -moz-border-radius: 4px 4px 0 0;
- border-radius: 4px 4px 0 0;
-}
-
-.nav-tabs > li > a:hover {
- border-color: #eeeeee #eeeeee #dddddd;
-}
-
-.nav-tabs > .active > a,
-.nav-tabs > .active > a:hover {
- color: #555555;
- cursor: default;
- background-color: #ffffff;
- border: 1px solid #ddd;
- border-bottom-color: transparent;
-}
-
-.nav-pills > li > a {
- padding-top: 8px;
- padding-bottom: 8px;
- margin-top: 2px;
- margin-bottom: 2px;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
- border-radius: 5px;
-}
-
-.nav-pills > .active > a,
-.nav-pills > .active > a:hover {
- color: #ffffff;
- background-color: #0088cc;
-}
-
-.nav-stacked > li {
- float: none;
-}
-
-.nav-stacked > li > a {
- margin-right: 0;
-}
-
-.nav-tabs.nav-stacked {
- border-bottom: 0;
-}
-
-.nav-tabs.nav-stacked > li > a {
- border: 1px solid #ddd;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.nav-tabs.nav-stacked > li:first-child > a {
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-topright: 4px;
- -moz-border-radius-topleft: 4px;
-}
-
-.nav-tabs.nav-stacked > li:last-child > a {
- -webkit-border-bottom-right-radius: 4px;
- border-bottom-right-radius: 4px;
- -webkit-border-bottom-left-radius: 4px;
- border-bottom-left-radius: 4px;
- -moz-border-radius-bottomright: 4px;
- -moz-border-radius-bottomleft: 4px;
-}
-
-.nav-tabs.nav-stacked > li > a:hover {
- z-index: 2;
- border-color: #ddd;
-}
-
-.nav-pills.nav-stacked > li > a {
- margin-bottom: 3px;
-}
-
-.nav-pills.nav-stacked > li:last-child > a {
- margin-bottom: 1px;
-}
-
-.nav-tabs .dropdown-menu {
- -webkit-border-radius: 0 0 6px 6px;
- -moz-border-radius: 0 0 6px 6px;
- border-radius: 0 0 6px 6px;
-}
-
-.nav-pills .dropdown-menu {
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
-}
-
-.nav .dropdown-toggle .caret {
- margin-top: 6px;
- border-top-color: #0088cc;
- border-bottom-color: #0088cc;
-}
-
-.nav .dropdown-toggle:hover .caret {
- border-top-color: #005580;
- border-bottom-color: #005580;
-}
-
-/* move down carets for tabs */
-
-.nav-tabs .dropdown-toggle .caret {
- margin-top: 8px;
-}
-
-.nav .active .dropdown-toggle .caret {
- border-top-color: #fff;
- border-bottom-color: #fff;
-}
-
-.nav-tabs .active .dropdown-toggle .caret {
- border-top-color: #555555;
- border-bottom-color: #555555;
-}
-
-.nav > .dropdown.active > a:hover {
- cursor: pointer;
-}
-
-.nav-tabs .open .dropdown-toggle,
-.nav-pills .open .dropdown-toggle,
-.nav > li.dropdown.open.active > a:hover {
- color: #ffffff;
- background-color: #999999;
- border-color: #999999;
-}
-
-.nav li.dropdown.open .caret,
-.nav li.dropdown.open.active .caret,
-.nav li.dropdown.open a:hover .caret {
- border-top-color: #ffffff;
- border-bottom-color: #ffffff;
- opacity: 1;
- filter: alpha(opacity=100);
-}
-
-.tabs-stacked .open > a:hover {
- border-color: #999999;
-}
-
-.tabbable {
- *zoom: 1;
-}
-
-.tabbable:before,
-.tabbable:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.tabbable:after {
- clear: both;
-}
-
-.tab-content {
- overflow: auto;
-}
-
-.tabs-below > .nav-tabs,
-.tabs-right > .nav-tabs,
-.tabs-left > .nav-tabs {
- border-bottom: 0;
-}
-
-.tab-content > .tab-pane,
-.pill-content > .pill-pane {
- display: none;
-}
-
-.tab-content > .active,
-.pill-content > .active {
- display: block;
-}
-
-.tabs-below > .nav-tabs {
- border-top: 1px solid #ddd;
-}
-
-.tabs-below > .nav-tabs > li {
- margin-top: -1px;
- margin-bottom: 0;
-}
-
-.tabs-below > .nav-tabs > li > a {
- -webkit-border-radius: 0 0 4px 4px;
- -moz-border-radius: 0 0 4px 4px;
- border-radius: 0 0 4px 4px;
-}
-
-.tabs-below > .nav-tabs > li > a:hover {
- border-top-color: #ddd;
- border-bottom-color: transparent;
-}
-
-.tabs-below > .nav-tabs > .active > a,
-.tabs-below > .nav-tabs > .active > a:hover {
- border-color: transparent #ddd #ddd #ddd;
-}
-
-.tabs-left > .nav-tabs > li,
-.tabs-right > .nav-tabs > li {
- float: none;
-}
-
-.tabs-left > .nav-tabs > li > a,
-.tabs-right > .nav-tabs > li > a {
- min-width: 74px;
- margin-right: 0;
- margin-bottom: 3px;
-}
-
-.tabs-left > .nav-tabs {
- float: left;
- margin-right: 19px;
- border-right: 1px solid #ddd;
-}
-
-.tabs-left > .nav-tabs > li > a {
- margin-right: -1px;
- -webkit-border-radius: 4px 0 0 4px;
- -moz-border-radius: 4px 0 0 4px;
- border-radius: 4px 0 0 4px;
-}
-
-.tabs-left > .nav-tabs > li > a:hover {
- border-color: #eeeeee #dddddd #eeeeee #eeeeee;
-}
-
-.tabs-left > .nav-tabs .active > a,
-.tabs-left > .nav-tabs .active > a:hover {
- border-color: #ddd transparent #ddd #ddd;
- *border-right-color: #ffffff;
-}
-
-.tabs-right > .nav-tabs {
- float: right;
- margin-left: 19px;
- border-left: 1px solid #ddd;
-}
-
-.tabs-right > .nav-tabs > li > a {
- margin-left: -1px;
- -webkit-border-radius: 0 4px 4px 0;
- -moz-border-radius: 0 4px 4px 0;
- border-radius: 0 4px 4px 0;
-}
-
-.tabs-right > .nav-tabs > li > a:hover {
- border-color: #eeeeee #eeeeee #eeeeee #dddddd;
-}
-
-.tabs-right > .nav-tabs .active > a,
-.tabs-right > .nav-tabs .active > a:hover {
- border-color: #ddd #ddd #ddd transparent;
- *border-left-color: #ffffff;
-}
-
-.nav > .disabled > a {
- color: #999999;
-}
-
-.nav > .disabled > a:hover {
- text-decoration: none;
- cursor: default;
- background-color: transparent;
-}
-
-.navbar {
- *position: relative;
- *z-index: 2;
- margin-bottom: 20px;
- overflow: visible;
- color: #555555;
-}
-
-.navbar-inner {
- min-height: 40px;
- padding-right: 20px;
- padding-left: 20px;
- background-color: #fafafa;
- background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2);
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f2f2f2));
- background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2);
- background-image: -o-linear-gradient(top, #ffffff, #f2f2f2);
- background-image: linear-gradient(to bottom, #ffffff, #f2f2f2);
- background-repeat: repeat-x;
- border: 1px solid #d4d4d4;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0);
- -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
- -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
-}
-
-.navbar .container {
- width: auto;
-}
-
-.nav-collapse.collapse {
- height: auto;
-}
-
-.navbar .brand {
- display: block;
- float: left;
- padding: 10px 20px 10px;
- margin-left: -20px;
- font-size: 20px;
- font-weight: 200;
- color: #555555;
- text-shadow: 0 1px 0 #ffffff;
-}
-
-.navbar .brand:hover {
- text-decoration: none;
-}
-
-.navbar-text {
- margin-bottom: 0;
- line-height: 40px;
-}
-
-.navbar-link {
- color: #555555;
-}
-
-.navbar-link:hover {
- color: #333333;
-}
-
-.navbar .divider-vertical {
- height: 40px;
- margin: 0 9px;
- border-right: 1px solid #ffffff;
- border-left: 1px solid #f2f2f2;
-}
-
-.navbar .btn,
-.navbar .btn-group {
- margin-top: 6px;
-}
-
-.navbar .btn-group .btn {
- margin: 0;
-}
-
-.navbar-form {
- margin-bottom: 0;
- *zoom: 1;
-}
-
-.navbar-form:before,
-.navbar-form:after {
- display: table;
- line-height: 0;
- content: "";
-}
-
-.navbar-form:after {
- clear: both;
-}
-
-.navbar-form input,
-.navbar-form select,
-.navbar-form .radio,
-.navbar-form .checkbox {
- margin-top: 5px;
-}
-
-.navbar-form input,
-.navbar-form select,
-.navbar-form .btn {
- display: inline-block;
- margin-bottom: 0;
-}
-
-.navbar-form input[type="image"],
-.navbar-form input[type="checkbox"],
-.navbar-form input[type="radio"] {
- margin-top: 3px;
-}
-
-.navbar-form .input-append,
-.navbar-form .input-prepend {
- margin-top: 6px;
- white-space: nowrap;
-}
-
-.navbar-form .input-append input,
-.navbar-form .input-prepend input {
- margin-top: 0;
-}
-
-.navbar-search {
- position: relative;
- float: left;
- margin-top: 5px;
- margin-bottom: 0;
-}
-
-.navbar-search .search-query {
- padding: 4px 14px;
- margin-bottom: 0;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 13px;
- font-weight: normal;
- line-height: 1;
- -webkit-border-radius: 15px;
- -moz-border-radius: 15px;
- border-radius: 15px;
-}
-
-.navbar-static-top {
- position: static;
- width: 100%;
- margin-bottom: 0;
-}
-
-.navbar-static-top .navbar-inner {
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.navbar-fixed-top,
-.navbar-fixed-bottom {
- position: fixed;
- right: 0;
- left: 0;
- z-index: 1030;
- margin-bottom: 0;
-}
-
-.navbar-fixed-top .navbar-inner,
-.navbar-fixed-bottom .navbar-inner,
-.navbar-static-top .navbar-inner {
- border: 0;
-}
-
-.navbar-fixed-top .navbar-inner,
-.navbar-fixed-bottom .navbar-inner {
- padding-right: 0;
- padding-left: 0;
- -webkit-border-radius: 0;
- -moz-border-radius: 0;
- border-radius: 0;
-}
-
-.navbar-static-top .container,
-.navbar-fixed-top .container,
-.navbar-fixed-bottom .container {
- width: 940px;
-}
-
-.navbar-fixed-top {
- top: 0;
-}
-
-.navbar-fixed-top .navbar-inner,
-.navbar-static-top .navbar-inner {
- -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
- -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
- box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
-}
-
-.navbar-fixed-bottom {
- bottom: 0;
-}
-
-.navbar-fixed-bottom .navbar-inner {
- -webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
- -moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
- box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
-}
-
-.navbar .nav {
- position: relative;
- left: 0;
- display: block;
- float: left;
- margin: 0 10px 0 0;
-}
-
-.navbar .nav.pull-right {
- float: right;
-}
-
-.navbar .nav > li {
- float: left;
-}
-
-.navbar .nav > li > a {
- float: none;
- padding: 10px 15px 10px;
- color: #555555;
- text-decoration: none;
- text-shadow: 0 1px 0 #ffffff;
-}
-
-.navbar .nav .dropdown-toggle .caret {
- margin-top: 8px;
-}
-
-.navbar .nav > li > a:focus,
-.navbar .nav > li > a:hover {
- color: #333333;
- text-decoration: none;
- background-color: transparent;
-}
-
-.navbar .nav > .active > a,
-.navbar .nav > .active > a:hover,
-.navbar .nav > .active > a:focus {
- color: #555555;
- text-decoration: none;
- background-color: #e5e5e5;
- -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
- -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
- box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
-}
-
-.navbar .btn-navbar {
- display: none;
- float: right;
- padding: 7px 10px;
- margin-right: 5px;
- margin-left: 5px;
- color: #ffffff;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
- background-color: #ededed;
- *background-color: #e5e5e5;
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#e5e5e5));
- background-image: -webkit-linear-gradient(top, #f2f2f2, #e5e5e5);
- background-image: -o-linear-gradient(top, #f2f2f2, #e5e5e5);
- background-image: linear-gradient(to bottom, #f2f2f2, #e5e5e5);
- background-image: -moz-linear-gradient(top, #f2f2f2, #e5e5e5);
- background-repeat: repeat-x;
- border-color: #e5e5e5 #e5e5e5 #bfbfbf;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffe5e5e5', GradientType=0);
- filter: progid:dximagetransform.microsoft.gradient(enabled=false);
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
- -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
-}
-
-.navbar .btn-navbar:hover,
-.navbar .btn-navbar:active,
-.navbar .btn-navbar.active,
-.navbar .btn-navbar.disabled,
-.navbar .btn-navbar[disabled] {
- color: #ffffff;
- background-color: #e5e5e5;
- *background-color: #d9d9d9;
-}
-
-.navbar .btn-navbar:active,
-.navbar .btn-navbar.active {
- background-color: #cccccc \9;
-}
-
-.navbar .btn-navbar .icon-bar {
- display: block;
- width: 18px;
- height: 2px;
- background-color: #f5f5f5;
- -webkit-border-radius: 1px;
- -moz-border-radius: 1px;
- border-radius: 1px;
- -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
- -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
- box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
-}
-
-.btn-navbar .icon-bar + .icon-bar {
- margin-top: 3px;
-}
-
-.navbar .nav > li > .dropdown-menu:before {
- position: absolute;
- top: -7px;
- left: 9px;
- display: inline-block;
- border-right: 7px solid transparent;
- border-bottom: 7px solid #ccc;
- border-left: 7px solid transparent;
- border-bottom-color: rgba(0, 0, 0, 0.2);
- content: '';
-}
-
-.navbar .nav > li > .dropdown-menu:after {
- position: absolute;
- top: -6px;
- left: 10px;
- display: inline-block;
- border-right: 6px solid transparent;
- border-bottom: 6px solid #ffffff;
- border-left: 6px solid transparent;
- content: '';
-}
-
-.navbar-fixed-bottom .nav > li > .dropdown-menu:before {
- top: auto;
- bottom: -7px;
- border-top: 7px solid #ccc;
- border-bottom: 0;
- border-top-color: rgba(0, 0, 0, 0.2);
-}
-
-.navbar-fixed-bottom .nav > li > .dropdown-menu:after {
- top: auto;
- bottom: -6px;
- border-top: 6px solid #ffffff;
- border-bottom: 0;
-}
-
-.navbar .nav li.dropdown.open > .dropdown-toggle,
-.navbar .nav li.dropdown.active > .dropdown-toggle,
-.navbar .nav li.dropdown.open.active > .dropdown-toggle {
- color: #555555;
- background-color: #e5e5e5;
-}
-
-.navbar .nav li.dropdown > .dropdown-toggle .caret {
- border-top-color: #555555;
- border-bottom-color: #555555;
-}
-
-.navbar .nav li.dropdown.open > .dropdown-toggle .caret,
-.navbar .nav li.dropdown.active > .dropdown-toggle .caret,
-.navbar .nav li.dropdown.open.active > .dropdown-toggle .caret {
- border-top-color: #555555;
- border-bottom-color: #555555;
-}
-
-.navbar .pull-right > li > .dropdown-menu,
-.navbar .nav > li > .dropdown-menu.pull-right {
- right: 0;
- left: auto;
-}
-
-.navbar .pull-right > li > .dropdown-menu:before,
-.navbar .nav > li > .dropdown-menu.pull-right:before {
- right: 12px;
- left: auto;
-}
-
-.navbar .pull-right > li > .dropdown-menu:after,
-.navbar .nav > li > .dropdown-menu.pull-right:after {
- right: 13px;
- left: auto;
-}
-
-.navbar .pull-right > li > .dropdown-menu .dropdown-menu,
-.navbar .nav > li > .dropdown-menu.pull-right .dropdown-menu {
- right: 100%;
- left: auto;
- margin-right: -1px;
- margin-left: 0;
- -webkit-border-radius: 6px 0 6px 6px;
- -moz-border-radius: 6px 0 6px 6px;
- border-radius: 6px 0 6px 6px;
-}
-
-.navbar-inverse {
<TRUNCATED>
[04/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_invalid_filter_parameters.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_invalid_filter_parameters.xml b/src/test/resources/configs/appenders/config_invalid_filter_parameters.xml
deleted file mode 100644
index fe52279..0000000
--- a/src/test/resources/configs/appenders/config_invalid_filter_parameters.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <filter class="LoggerFilterStringMatch">
- <param name="fooParameter" value="bar" />
- </filter>
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_invalid_layout_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_invalid_layout_class.xml b/src/test/resources/configs/appenders/config_invalid_layout_class.xml
deleted file mode 100644
index 0a3c40b..0000000
--- a/src/test/resources/configs/appenders/config_invalid_layout_class.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="stdClass" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_no_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_no_class.xml b/src/test/resources/configs/appenders/config_no_class.xml
deleted file mode 100644
index 1e581f3..0000000
--- a/src/test/resources/configs/appenders/config_no_class.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
-
- <appender name="foo" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_no_layout_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_no_layout_class.xml b/src/test/resources/configs/appenders/config_no_layout_class.xml
deleted file mode 100644
index a20257a..0000000
--- a/src/test/resources/configs/appenders/config_no_layout_class.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_not_existing_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_not_existing_class.xml b/src/test/resources/configs/appenders/config_not_existing_class.xml
deleted file mode 100644
index ec5aae0..0000000
--- a/src/test/resources/configs/appenders/config_not_existing_class.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="foo" class="unknownClass"/>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_not_existing_filter_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_not_existing_filter_class.xml b/src/test/resources/configs/appenders/config_not_existing_filter_class.xml
deleted file mode 100644
index 9cab011..0000000
--- a/src/test/resources/configs/appenders/config_not_existing_filter_class.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <filter class="Foo" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/appenders/config_not_existing_layout_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/appenders/config_not_existing_layout_class.xml b/src/test/resources/configs/appenders/config_not_existing_layout_class.xml
deleted file mode 100644
index e796566..0000000
--- a/src/test/resources/configs/appenders/config_not_existing_layout_class.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="Foo" />
- </appender>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/config.yml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/config.yml b/src/test/resources/configs/config.yml
deleted file mode 100644
index 07b86fb..0000000
--- a/src/test/resources/configs/config.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/config1.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/config1.xml b/src/test/resources/configs/config1.xml
deleted file mode 100644
index 70f06c4..0000000
--- a/src/test/resources/configs/config1.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LoggerFilterLevelRange">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- <filter class="LoggerFilterDenyAll" />
- </appender>
- <appender name="file" class="LoggerAppenderDailyFile" threshold="warn">
- <param name="datePattern" value="Ymd" />
- <param name="file" value="target/examples/daily_%s.log" />
- <layout class="LoggerLayoutPattern">
- <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
- </layout>
- </appender>
- <logger name="foo.bar.baz" additivity="false">
- <level value="trace" />
- <appender_ref ref="default" />
- </logger>
- <logger name="foo.bar" additivity="true">
- <level value="debug" />
- <appender_ref ref="file" />
- </logger>
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- <appender_ref ref="file" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/loggers/config_invalid_additivity.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/loggers/config_invalid_additivity.xml b/src/test/resources/configs/loggers/config_invalid_additivity.xml
deleted file mode 100644
index fc7151d..0000000
--- a/src/test/resources/configs/loggers/config_invalid_additivity.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple"/>
- </appender>
- <logger name="myLogger" additivity="4711">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/loggers/config_not_existing_appenders.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/loggers/config_not_existing_appenders.xml b/src/test/resources/configs/loggers/config_not_existing_appenders.xml
deleted file mode 100644
index 5e5ea1e..0000000
--- a/src/test/resources/configs/loggers/config_not_existing_appenders.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <logger name="myLogger">
- <level value="warn" />
- <appender_ref ref="unknownAppender" />
- </logger>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/renderers/config_default_renderer.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/renderers/config_default_renderer.xml b/src/test/resources/configs/renderers/config_default_renderer.xml
deleted file mode 100644
index 69f7dff..0000000
--- a/src/test/resources/configs/renderers/config_default_renderer.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole" />
-
- <defaultRenderer renderingClass="FruitRenderer3" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/renderers/config_invalid_rendering_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/renderers/config_invalid_rendering_class.xml b/src/test/resources/configs/renderers/config_invalid_rendering_class.xml
deleted file mode 100644
index 83ef7d3..0000000
--- a/src/test/resources/configs/renderers/config_invalid_rendering_class.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="LoggerLayoutSimple"/>
- </appender>
-
- <renderer renderedClass="stdClass" renderingClass="stdClass" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/renderers/config_no_rendered_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/renderers/config_no_rendered_class.xml b/src/test/resources/configs/renderers/config_no_rendered_class.xml
deleted file mode 100644
index b8fa71d..0000000
--- a/src/test/resources/configs/renderers/config_no_rendered_class.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="LoggerLayoutSimple"/>
- </appender>
-
- <renderer renderingClass="LoggerRendererDefault" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/renderers/config_no_rendering_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/renderers/config_no_rendering_class.xml b/src/test/resources/configs/renderers/config_no_rendering_class.xml
deleted file mode 100644
index 17659f4..0000000
--- a/src/test/resources/configs/renderers/config_no_rendering_class.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="LoggerLayoutSimple"/>
- </appender>
-
- <renderer />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/resources/configs/renderers/config_not_existing_rendering_class.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/configs/renderers/config_not_existing_rendering_class.xml b/src/test/resources/configs/renderers/config_not_existing_rendering_class.xml
deleted file mode 100644
index 8a32d3e..0000000
--- a/src/test/resources/configs/renderers/config_not_existing_rendering_class.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php">
- <appender name="foo" class="LoggerAppenderConsole">
- <layout class="LoggerLayoutSimple"/>
- </appender>
-
- <renderer renderedClass="stdClass" renderingClass="DoesNotExistRenderer" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="foo" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/bootstrap.php
----------------------------------------------------------------------
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 0000000..b95c505
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+error_reporting(E_ALL | E_STRICT);
+
+// Required for testing logging of sessionID in pattern layout
+session_start();
+
+date_default_timezone_set('Europe/London');
+
+// Define a temp dir where tests may write to
+$tmpDir = __DIR__ . '/../target/temp/phpunit';
+if (!is_dir($tmpDir)) {
+ mkdir($tmpDir, 0777, true);
+}
+define('PHPUNIT_TEMP_DIR', realpath($tmpDir));
+
+// Make the path to the configurations dir for easier access
+$confDir = __DIR__ . '/resources/configs';
+define('PHPUNIT_CONFIG_DIR', realpath($confDir));
+
+require __DIR__ . '/../src/Autoloader.php';
+require __DIR__ . '/src/TestHelper.php';
+
+$autoloader = new Apache\Log4php\Autoloader();
+$autoloader->register();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/config/phpunit_to_surefire.xslt
----------------------------------------------------------------------
diff --git a/tests/config/phpunit_to_surefire.xslt b/tests/config/phpunit_to_surefire.xslt
new file mode 100644
index 0000000..1f8fd61
--- /dev/null
+++ b/tests/config/phpunit_to_surefire.xslt
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xsl:stylesheet version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:fn="http://www.w3.org/2005/xpath-functions">
+ <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
+ <xsl:param name="outputDir">.</xsl:param>
+
+ <xsl:template match="testsuites">
+ <xsl:apply-templates select="testsuite" />
+ </xsl:template>
+
+ <xsl:template match="testsuite">
+ <xsl:if test="testcase">
+ <xsl:variable name="outputName" select="./@name" />
+ <xsl:result-document href="{$outputDir}/{$outputName}.xml" method="xml">
+ <xsl:copy-of select="." />
+ </xsl:result-document>
+ </xsl:if>
+
+ <xsl:apply-templates select="testsuite" />
+ </xsl:template>
+</xsl:stylesheet>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini b/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini
new file mode 100644
index 0000000..f7a8534
--- /dev/null
+++ b/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_1.ini
@@ -0,0 +1,23 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements. See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+log4php.rootLogger = DEBUG, default
+
+log4php.appender.default = EchoAppender
+
+# invalid appender line should trigger warning
+log4php.appender.default.layout.param.bla = LoggerLayoutTTCC
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini b/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini
new file mode 100644
index 0000000..043427c
--- /dev/null
+++ b/tests/resources/configs/adapters/ini/config_invalid_appender_declaration_2.ini
@@ -0,0 +1,23 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements. See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+log4php.rootLogger = DEBUG, default
+
+log4php.appender.default = EchoAppender
+
+# invalid appender line should trigger warning
+log4php.appender.default.not-layout.param = LoggerLayoutTTCC
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/ini/config_invalid_syntax.ini
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/ini/config_invalid_syntax.ini b/tests/resources/configs/adapters/ini/config_invalid_syntax.ini
new file mode 100644
index 0000000..9971ea2
--- /dev/null
+++ b/tests/resources/configs/adapters/ini/config_invalid_syntax.ini
@@ -0,0 +1,19 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements. See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+not a valid ini file ()
+
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/ini/config_valid.ini
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/ini/config_valid.ini b/tests/resources/configs/adapters/ini/config_valid.ini
new file mode 100644
index 0000000..f6c4d08
--- /dev/null
+++ b/tests/resources/configs/adapters/ini/config_valid.ini
@@ -0,0 +1,41 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements. See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+log4php.rootLogger = DEBUG, default
+
+log4php.appender.default = EchoAppender
+log4php.appender.default.layout = LoggerLayoutTTCC
+
+log4php.appender.file = DailyFileAppender
+log4php.appender.file.layout = PatternLayout
+log4php.appender.file.layout.conversionPattern = "%d{ISO8601} [%p] %c: %m (at %F line %L)%n"
+log4php.appender.file.datePattern = Ymd
+log4php.appender.file.file = target/examples/daily_%s.log
+log4php.appender.file.threshold = warn
+
+log4php.logger.foo = warn, default
+
+log4php.logger.foo.bar = debug, file
+log4php.additivity.foo.bar = "true"
+
+log4php.logger.foo.bar.baz = trace, default, file
+log4php.additivity.foo.bar.baz = "false"
+
+log4php.renderer.Fruit = FruitRenderer
+log4php.renderer.Beer = BeerRenderer
+
+log4php.threshold = debug
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/ini/values.ini
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/ini/values.ini b/tests/resources/configs/adapters/ini/values.ini
new file mode 100644
index 0000000..bd4239a
--- /dev/null
+++ b/tests/resources/configs/adapters/ini/values.ini
@@ -0,0 +1,25 @@
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements. See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.
+; The ASF licenses this file to You under the Apache License, Version 2.0
+; (the "License"); you may not use this file except in compliance with
+; the License. You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+;
+
+unquoted_true = true
+unquoted_false = false
+unquoted_yes = true
+unquoted_no = false
+quoted_true = "true"
+quoted_false = "false"
+unquoted_one = 1
+unquoted_zero = 0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/php/config_empty.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_empty.php b/tests/resources/configs/adapters/php/config_empty.php
new file mode 100644
index 0000000..5ca9004
--- /dev/null
+++ b/tests/resources/configs/adapters/php/config_empty.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+// Empty config
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/php/config_invalid_syntax.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_invalid_syntax.php b/tests/resources/configs/adapters/php/config_invalid_syntax.php
new file mode 100644
index 0000000..5019f68
--- /dev/null
+++ b/tests/resources/configs/adapters/php/config_invalid_syntax.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+return array(
+ 'rootLogger' => array(
+ 'level' => 'info',
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ )
+ )
+
+// Invalid file - no closing brace.
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/php/config_not_an_array.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_not_an_array.php b/tests/resources/configs/adapters/php/config_not_an_array.php
new file mode 100644
index 0000000..030bb10
--- /dev/null
+++ b/tests/resources/configs/adapters/php/config_not_an_array.php
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+// Not an array
+return new Exception();
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/php/config_valid.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_valid.php b/tests/resources/configs/adapters/php/config_valid.php
new file mode 100644
index 0000000..bfabfce
--- /dev/null
+++ b/tests/resources/configs/adapters/php/config_valid.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+return array(
+ 'rootLogger' => array(
+ 'level' => 'info',
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ )
+ )
+)
+;
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_duplicate_logger.xml b/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
new file mode 100644
index 0000000..978b9c7
--- /dev/null
+++ b/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <!-- Duplicate logger -->
+ <logger name="foo">
+ <level value="info" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml b/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
new file mode 100644
index 0000000..4ac97bc
--- /dev/null
+++ b/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration>
+ <!-- Duplicate renderer -->
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer1" />
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer2" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_invalid_syntax.xml b/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
new file mode 100644
index 0000000..6592fa5
--- /dev/null
+++ b/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <!-- Duplicate logger -->
+ <logger name="foo">
+ <level value="info" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+
+ <!-- Invalid XML file for testing -->
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/xml/config_valid.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_valid.xml b/tests/resources/configs/adapters/xml/config_valid.xml
new file mode 100644
index 0000000..6553c44
--- /dev/null
+++ b/tests/resources/configs/adapters/xml/config_valid.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="LoggerLayoutTTCC"/>
+ <filter class="LevelRangeFilter">
+ <param name="levelMin" value="ERROR" />
+ <param name="levelMax" value="FATAL" />
+ <param name="acceptOnMatch" value="false" />
+ </filter>
+ <filter class="DenyAllFilter" />
+ </appender>
+ <appender name="file" class="DailyFileAppender" threshold="warn">
+ <param name="datePattern" value="Ymd" />
+ <param name="file" value="target/examples/daily_%s.log" />
+ <layout class="PatternLayout">
+ <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
+ </layout>
+ </appender>
+ <logger name="foo.bar.baz" additivity="false">
+ <level value="trace" />
+ <appender_ref ref="default" />
+ </logger>
+ <logger name="foo.bar" additivity="true">
+ <level value="debug" />
+ <appender_ref ref="file" />
+ </logger>
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ <appender_ref ref="file" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/adapters/xml/config_valid_underscore.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_valid_underscore.xml b/tests/resources/configs/adapters/xml/config_valid_underscore.xml
new file mode 100644
index 0000000..4ff6e21
--- /dev/null
+++ b/tests/resources/configs/adapters/xml/config_valid_underscore.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Same as config_valid.xml but uses appender-ref instead of appender_ref -->
+
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="LoggerLayoutTTCC"/>
+ <filter class="LevelRangeFilter">
+ <param name="levelMin" value="ERROR" />
+ <param name="levelMax" value="FATAL" />
+ <param name="acceptOnMatch" value="false" />
+ </filter>
+ <filter class="DenyAllFilter" />
+ </appender>
+ <appender name="file" class="DailyFileAppender" threshold="warn">
+ <param name="datePattern" value="Ymd" />
+ <param name="file" value="target/examples/daily_%s.log" />
+ <layout class="PatternLayout">
+ <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
+ </layout>
+ </appender>
+ <logger name="foo.bar.baz" additivity="false">
+ <level value="trace" />
+ <appender-ref ref="default" />
+ </logger>
+ <logger name="foo.bar" additivity="true">
+ <level value="debug" />
+ <appender-ref ref="file" />
+ </logger>
+ <logger name="foo">
+ <level value="warn" />
+ <appender-ref ref="default" />
+ <appender-ref ref="file" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender-ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_invalid_appender_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_appender_class.xml b/tests/resources/configs/appenders/config_invalid_appender_class.xml
new file mode 100644
index 0000000..db3ccf0
--- /dev/null
+++ b/tests/resources/configs/appenders/config_invalid_appender_class.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="foo" class="stdClass"/>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_invalid_filter_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_filter_class.xml b/tests/resources/configs/appenders/config_invalid_filter_class.xml
new file mode 100644
index 0000000..80c9736
--- /dev/null
+++ b/tests/resources/configs/appenders/config_invalid_filter_class.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <filter class="stdClass" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_filter_parameters.xml b/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
new file mode 100644
index 0000000..d17183d
--- /dev/null
+++ b/tests/resources/configs/appenders/config_invalid_filter_parameters.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <filter class="StringMatchFilter">
+ <param name="fooParameter" value="bar" />
+ </filter>
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_invalid_layout_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_layout_class.xml b/tests/resources/configs/appenders/config_invalid_layout_class.xml
new file mode 100644
index 0000000..308243f
--- /dev/null
+++ b/tests/resources/configs/appenders/config_invalid_layout_class.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="stdClass" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_no_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_no_class.xml b/tests/resources/configs/appenders/config_no_class.xml
new file mode 100644
index 0000000..1e581f3
--- /dev/null
+++ b/tests/resources/configs/appenders/config_no_class.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+
+ <appender name="foo" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_no_layout_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_no_layout_class.xml b/tests/resources/configs/appenders/config_no_layout_class.xml
new file mode 100644
index 0000000..035226b
--- /dev/null
+++ b/tests/resources/configs/appenders/config_no_layout_class.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_not_existing_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_not_existing_class.xml b/tests/resources/configs/appenders/config_not_existing_class.xml
new file mode 100644
index 0000000..ec5aae0
--- /dev/null
+++ b/tests/resources/configs/appenders/config_not_existing_class.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="foo" class="unknownClass"/>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_not_existing_filter_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_not_existing_filter_class.xml b/tests/resources/configs/appenders/config_not_existing_filter_class.xml
new file mode 100644
index 0000000..1d4e1ea
--- /dev/null
+++ b/tests/resources/configs/appenders/config_not_existing_filter_class.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <filter class="Foo" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/appenders/config_not_existing_layout_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_not_existing_layout_class.xml b/tests/resources/configs/appenders/config_not_existing_layout_class.xml
new file mode 100644
index 0000000..5fc72a5
--- /dev/null
+++ b/tests/resources/configs/appenders/config_not_existing_layout_class.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="Foo" />
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/config.yml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/config.yml b/tests/resources/configs/config.yml
new file mode 100644
index 0000000..07b86fb
--- /dev/null
+++ b/tests/resources/configs/config.yml
@@ -0,0 +1,14 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/config1.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/config1.xml b/tests/resources/configs/config1.xml
new file mode 100644
index 0000000..6553c44
--- /dev/null
+++ b/tests/resources/configs/config1.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="LoggerLayoutTTCC"/>
+ <filter class="LevelRangeFilter">
+ <param name="levelMin" value="ERROR" />
+ <param name="levelMax" value="FATAL" />
+ <param name="acceptOnMatch" value="false" />
+ </filter>
+ <filter class="DenyAllFilter" />
+ </appender>
+ <appender name="file" class="DailyFileAppender" threshold="warn">
+ <param name="datePattern" value="Ymd" />
+ <param name="file" value="target/examples/daily_%s.log" />
+ <layout class="PatternLayout">
+ <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
+ </layout>
+ </appender>
+ <logger name="foo.bar.baz" additivity="false">
+ <level value="trace" />
+ <appender_ref ref="default" />
+ </logger>
+ <logger name="foo.bar" additivity="true">
+ <level value="debug" />
+ <appender_ref ref="file" />
+ </logger>
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ <appender_ref ref="file" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/loggers/config_invalid_additivity.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/loggers/config_invalid_additivity.xml b/tests/resources/configs/loggers/config_invalid_additivity.xml
new file mode 100644
index 0000000..13fe2cc
--- /dev/null
+++ b/tests/resources/configs/loggers/config_invalid_additivity.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+ <logger name="myLogger" additivity="4711">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/loggers/config_not_existing_appenders.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/loggers/config_not_existing_appenders.xml b/tests/resources/configs/loggers/config_not_existing_appenders.xml
new file mode 100644
index 0000000..5e5ea1e
--- /dev/null
+++ b/tests/resources/configs/loggers/config_not_existing_appenders.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <logger name="myLogger">
+ <level value="warn" />
+ <appender_ref ref="unknownAppender" />
+ </logger>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/renderers/config_default_renderer.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_default_renderer.xml b/tests/resources/configs/renderers/config_default_renderer.xml
new file mode 100644
index 0000000..5c22323
--- /dev/null
+++ b/tests/resources/configs/renderers/config_default_renderer.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender" />
+
+ <defaultRenderer renderingClass="FruitRenderer3" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/renderers/config_invalid_rendering_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_invalid_rendering_class.xml b/tests/resources/configs/renderers/config_invalid_rendering_class.xml
new file mode 100644
index 0000000..51886fe
--- /dev/null
+++ b/tests/resources/configs/renderers/config_invalid_rendering_class.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer renderedClass="stdClass" renderingClass="stdClass" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/renderers/config_no_rendered_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_no_rendered_class.xml b/tests/resources/configs/renderers/config_no_rendered_class.xml
new file mode 100644
index 0000000..836815e
--- /dev/null
+++ b/tests/resources/configs/renderers/config_no_rendered_class.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer renderingClass="DefaultRenderer" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/renderers/config_no_rendering_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_no_rendering_class.xml b/tests/resources/configs/renderers/config_no_rendering_class.xml
new file mode 100644
index 0000000..77b14c4
--- /dev/null
+++ b/tests/resources/configs/renderers/config_no_rendering_class.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/renderers/config_not_existing_rendering_class.xml b/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
new file mode 100644
index 0000000..467bd25
--- /dev/null
+++ b/tests/resources/configs/renderers/config_not_existing_rendering_class.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php">
+ <appender name="foo" class="ConsoleAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <renderer renderedClass="stdClass" renderingClass="DoesNotExistRenderer" />
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="foo" />
+ </root>
+</configuration>
[27/43] git commit: LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
LOG4PHP-121: Reorganized classes into namespaces
Base namespace for the project is Apache\Log4php.
Also renamed classes to have a sane naming scheme, e.g.
LoggerAppenderConsole becomes ConsoleAppender, and is located in the
Apache\Log4php\Appenders namespace.
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/79ed2d0d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/79ed2d0d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/79ed2d0d
Branch: refs/heads/v3
Commit: 79ed2d0d173de51ac47d934b0f658eee30a8eb04
Parents: ae4116e
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 13:48:45 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 13:48:45 2013 +0100
----------------------------------------------------------------------
.gitignore | 3 +
composer.json | 14 +-
phpunit.xml | 15 +-
src/AppenderPool.php | 97 +
src/Appenders/AbstractAppender.php | 288 +
src/Appenders/ConsoleAppender.php | 103 +
src/Appenders/DailyFileAppender.php | 130 +
src/Appenders/EchoAppender.php | 89 +
src/Appenders/FileAppender.php | 225 +
src/Appenders/MailAppender.php | 136 +
src/Appenders/MailEventAppender.php | 180 +
src/Appenders/MongoDBAppender.php | 366 +
src/Appenders/NullAppender.php | 44 +
src/Appenders/PdoAppender.php | 287 +
src/Appenders/PhpAppender.php | 50 +
src/Appenders/RollingFileAppender.php | 303 +
src/Appenders/SocketAppender.php | 123 +
src/Appenders/SyslogAppender.php | 304 +
src/Autoloader.php | 53 +
src/Configurable.php | 118 +
src/Configuration/ConfiguratorInterface.php | 41 +
src/Configuration/DefaultConfigurator.php | 512 +
src/Configuration/adapters/AdapterInterface.php | 35 +
src/Configuration/adapters/IniAdapter.php | 294 +
src/Configuration/adapters/PhpAdapter.php | 82 +
src/Configuration/adapters/XmlAdapter.php | 277 +
src/Filters/AbstractFilter.php | 126 +
src/Filters/DenyAllFilter.php | 45 +
src/Filters/LevelMatchFilter.php | 98 +
src/Filters/LevelRangeFilter.php | 136 +
src/Filters/StringMatchFilter.php | 87 +
src/Helpers/FormattingInfo.php | 51 +
src/Helpers/OptionConverter.php | 225 +
src/Helpers/PatternParser.php | 245 +
src/Helpers/Utils.php | 120 +
src/Hierarchy.php | 256 +
src/Layouts/AbstractLayout.php | 74 +
src/Layouts/HtmlLayout.php | 197 +
src/Layouts/PatternLayout.php | 171 +
src/Layouts/SerializedLayout.php | 53 +
src/Layouts/SimpleLayout.php | 44 +
src/Layouts/XmlLayout.php | 192 +
src/Level.php | 253 +
src/LocationInfo.php | 100 +
src/Logger.php | 592 ++
src/LoggerException.php | 25 +
src/LoggingEvent.php | 366 +
src/MDC.php | 87 +
src/NDC.php | 184 +
src/Pattern/AbstractConverter.php | 130 +
src/Pattern/ClassConverter.php | 62 +
src/Pattern/CookieConverter.php | 32 +
src/Pattern/DateConverter.php | 89 +
src/Pattern/EnvironmentConverter.php | 33 +
src/Pattern/FileConverter.php | 32 +
src/Pattern/LevelConverter.php | 32 +
src/Pattern/LineConverter.php | 33 +
src/Pattern/LiteralConverter.php | 38 +
src/Pattern/LocationConverter.php | 37 +
src/Pattern/LoggerConverter.php | 64 +
src/Pattern/MdcConverter.php | 52 +
src/Pattern/MessageConverter.php | 32 +
src/Pattern/MethodConverter.php | 33 +
src/Pattern/NdcConverter.php | 32 +
src/Pattern/NewLineConverter.php | 32 +
src/Pattern/ProcessConverter.php | 32 +
src/Pattern/RelativeConverter.php | 34 +
src/Pattern/RequestConverter.php | 35 +
src/Pattern/ServerConverter.php | 35 +
src/Pattern/SessionConverter.php | 35 +
src/Pattern/SessionIdConverter.php | 31 +
src/Pattern/SuperglobalConverter.php | 100 +
src/Pattern/ThrowableConverter.php | 35 +
src/ReflectionUtils.php | 151 +
src/Renderers/DefaultRenderer.php | 33 +
src/Renderers/ExceptionRenderer.php | 33 +
src/Renderers/RendererInterface.php | 32 +
src/Renderers/RendererMap.php | 189 +
src/RootLogger.php | 69 +
src/ThrowableInformation.php | 67 +
src/assembly/src.xml | 49 -
src/changes/changes.xml | 167 -
src/examples/php/appender_console.php | 23 -
src/examples/php/appender_dailyfile.php | 23 -
src/examples/php/appender_echo.php | 23 -
src/examples/php/appender_file.php | 22 -
src/examples/php/appender_firephp.php | 120 -
src/examples/php/appender_mail.php | 24 -
src/examples/php/appender_mailevent.php | 23 -
src/examples/php/appender_mongodb.php | 22 -
src/examples/php/appender_null.php | 23 -
src/examples/php/appender_pdo.php | 23 -
src/examples/php/appender_php.php | 22 -
src/examples/php/appender_rollingfile.php | 23 -
src/examples/php/appender_socket.php | 23 -
src/examples/php/appender_socket_server.php | 72 -
src/examples/php/appender_syslog.php | 23 -
src/examples/php/cache.php | 35 -
src/examples/php/configurator_basic.php | 23 -
src/examples/php/configurator_php.php | 23 -
src/examples/php/configurator_xml.php | 24 -
src/examples/php/filter_denyall.php | 23 -
src/examples/php/filter_levelmatch.php | 24 -
src/examples/php/filter_levelrange.php | 27 -
src/examples/php/filter_stringmatch.php | 24 -
src/examples/php/layout_html.php | 23 -
src/examples/php/layout_pattern.php | 24 -
src/examples/php/layout_simple.php | 23 -
src/examples/php/layout_ttcc.php | 23 -
src/examples/php/layout_xml.php | 23 -
src/examples/php/mdc.php | 24 -
src/examples/php/ndc.php | 30 -
src/examples/php/renderer_default.php | 35 -
src/examples/php/renderer_map.php | 37 -
src/examples/php/simple.php | 36 -
.../resources/appender_console.properties | 21 -
.../resources/appender_dailyfile.properties | 22 -
src/examples/resources/appender_echo.properties | 20 -
src/examples/resources/appender_file.properties | 21 -
src/examples/resources/appender_firephp.xml | 30 -
src/examples/resources/appender_mail.properties | 23 -
.../resources/appender_mailevent.properties | 23 -
src/examples/resources/appender_mongodb.xml | 25 -
src/examples/resources/appender_null.properties | 19 -
src/examples/resources/appender_pdo.properties | 37 -
src/examples/resources/appender_php.properties | 21 -
.../resources/appender_rollingfile.properties | 23 -
.../resources/appender_socket.properties | 24 -
.../resources/appender_socket_server.properties | 24 -
.../resources/appender_syslog.properties | 23 -
src/examples/resources/cache.properties | 20 -
src/examples/resources/configurator_php.php | 39 -
src/examples/resources/configurator_xml.xml | 26 -
src/examples/resources/filter_denyall.xml | 27 -
src/examples/resources/filter_levelmatch.xml | 30 -
src/examples/resources/filter_levelrange.xml | 31 -
src/examples/resources/filter_stringmatch.xml | 30 -
src/examples/resources/layout_html.properties | 20 -
.../resources/layout_pattern.properties | 21 -
src/examples/resources/layout_simple.properties | 20 -
src/examples/resources/layout_ttcc.properties | 23 -
src/examples/resources/layout_xml.properties | 20 -
src/examples/resources/mdc.properties | 22 -
src/examples/resources/ndc.properties | 21 -
.../resources/renderer_default.properties | 20 -
src/examples/resources/renderer_map.properties | 22 -
src/main/php/Logger.php | 596 --
src/main/php/LoggerAppender.php | 286 -
src/main/php/LoggerAppenderPool.php | 98 -
src/main/php/LoggerAutoloader.php | 142 -
src/main/php/LoggerConfigurable.php | 116 -
src/main/php/LoggerConfigurator.php | 42 -
src/main/php/LoggerException.php | 28 -
src/main/php/LoggerFilter.php | 126 -
src/main/php/LoggerHierarchy.php | 257 -
src/main/php/LoggerLayout.php | 74 -
src/main/php/LoggerLevel.php | 256 -
src/main/php/LoggerLocationInfo.php | 103 -
src/main/php/LoggerLoggingEvent.php | 368 -
src/main/php/LoggerMDC.php | 88 -
src/main/php/LoggerNDC.php | 203 -
src/main/php/LoggerReflectionUtils.php | 152 -
src/main/php/LoggerRoot.php | 71 -
src/main/php/LoggerThrowableInformation.php | 68 -
.../php/appenders/LoggerAppenderConsole.php | 103 -
.../php/appenders/LoggerAppenderDailyFile.php | 130 -
src/main/php/appenders/LoggerAppenderEcho.php | 88 -
src/main/php/appenders/LoggerAppenderFile.php | 225 -
.../php/appenders/LoggerAppenderFirePHP.php | 100 -
src/main/php/appenders/LoggerAppenderMail.php | 136 -
.../php/appenders/LoggerAppenderMailEvent.php | 180 -
.../php/appenders/LoggerAppenderMongoDB.php | 360 -
src/main/php/appenders/LoggerAppenderNull.php | 44 -
src/main/php/appenders/LoggerAppenderPDO.php | 282 -
src/main/php/appenders/LoggerAppenderPhp.php | 49 -
.../php/appenders/LoggerAppenderRollingFile.php | 305 -
src/main/php/appenders/LoggerAppenderSocket.php | 122 -
src/main/php/appenders/LoggerAppenderSyslog.php | 303 -
.../LoggerConfigurationAdapter.php | 39 -
.../LoggerConfigurationAdapterINI.php | 299 -
.../LoggerConfigurationAdapterPHP.php | 84 -
.../LoggerConfigurationAdapterXML.php | 278 -
.../configurators/LoggerConfiguratorDefault.php | 477 -
src/main/php/filters/LoggerFilterDenyAll.php | 56 -
src/main/php/filters/LoggerFilterLevelMatch.php | 100 -
src/main/php/filters/LoggerFilterLevelRange.php | 138 -
.../php/filters/LoggerFilterStringMatch.php | 89 -
src/main/php/helpers/LoggerFormattingInfo.php | 54 -
src/main/php/helpers/LoggerOptionConverter.php | 226 -
src/main/php/helpers/LoggerPatternParser.php | 237 -
src/main/php/helpers/LoggerUtils.php | 123 -
src/main/php/layouts/LoggerLayoutHtml.php | 214 -
src/main/php/layouts/LoggerLayoutPattern.php | 171 -
src/main/php/layouts/LoggerLayoutSerialized.php | 55 -
src/main/php/layouts/LoggerLayoutSimple.php | 56 -
src/main/php/layouts/LoggerLayoutTTCC.php | 201 -
src/main/php/layouts/LoggerLayoutXml.php | 210 -
src/main/php/pattern/LoggerPatternConverter.php | 131 -
.../php/pattern/LoggerPatternConverterClass.php | 64 -
.../pattern/LoggerPatternConverterCookie.php | 35 -
.../php/pattern/LoggerPatternConverterDate.php | 91 -
.../LoggerPatternConverterEnvironment.php | 35 -
.../php/pattern/LoggerPatternConverterFile.php | 34 -
.../php/pattern/LoggerPatternConverterLevel.php | 34 -
.../php/pattern/LoggerPatternConverterLine.php | 35 -
.../pattern/LoggerPatternConverterLiteral.php | 40 -
.../pattern/LoggerPatternConverterLocation.php | 39 -
.../pattern/LoggerPatternConverterLogger.php | 65 -
.../php/pattern/LoggerPatternConverterMDC.php | 55 -
.../pattern/LoggerPatternConverterMessage.php | 34 -
.../pattern/LoggerPatternConverterMethod.php | 35 -
.../php/pattern/LoggerPatternConverterNDC.php | 35 -
.../pattern/LoggerPatternConverterNewLine.php | 34 -
.../pattern/LoggerPatternConverterProcess.php | 34 -
.../pattern/LoggerPatternConverterRelative.php | 36 -
.../pattern/LoggerPatternConverterRequest.php | 35 -
.../pattern/LoggerPatternConverterServer.php | 35 -
.../pattern/LoggerPatternConverterSession.php | 35 -
.../pattern/LoggerPatternConverterSessionID.php | 33 -
.../LoggerPatternConverterSuperglobal.php | 102 -
.../pattern/LoggerPatternConverterThrowable.php | 40 -
src/main/php/renderers/LoggerRenderer.php | 36 -
.../php/renderers/LoggerRendererDefault.php | 36 -
.../php/renderers/LoggerRendererException.php | 36 -
src/main/php/renderers/LoggerRendererMap.php | 186 -
src/main/php/xml/log4php.dtd | 148 -
src/site/apt/contributingpatches.apt | 112 -
src/site/apt/download.apt | 92 -
src/site/apt/index.apt | 104 -
src/site/apt/privacy-policy.apt | 49 -
src/site/apt/volunteering.apt | 44 -
src/site/cse.xml | 48 -
src/site/resources/css/bootstrap.css | 5624 -----------
src/site/resources/css/bootstrap.min.css | 9 -
src/site/resources/css/site.css | 79 -
src/site/resources/images/collapsed.gif | Bin 820 -> 0 bytes
src/site/resources/images/expanded.gif | Bin 52 -> 0 bytes
src/site/resources/images/logos/ls-logo.jpg | Bin 41915 -> 0 bytes
.../resources/images/logos/maven-feather.png | Bin 3330 -> 0 bytes
.../img/glyphicons-halflings-white.png | Bin 8777 -> 0 bytes
src/site/resources/img/glyphicons-halflings.png | Bin 12799 -> 0 bytes
src/site/resources/js/bootstrap.js | 2027 ----
src/site/resources/js/bootstrap.min.js | 6 -
src/site/resources/js/jquery.js | 9266 ------------------
src/site/resources/js/jquery.min.js | 4 -
src/site/resources/js/prettify.js | 1477 ---
src/site/resources/js/prettify.min.js | 41 -
src/site/resources/js/site.js | 106 -
src/site/site.vm | 485 -
src/site/site.xml | 108 -
src/site/xdoc/changelog.xml | 182 -
src/site/xdoc/docs/appenders.xml | 191 -
src/site/xdoc/docs/appenders/console.xml | 108 -
src/site/xdoc/docs/appenders/daily-file.xml | 169 -
src/site/xdoc/docs/appenders/echo.xml | 112 -
src/site/xdoc/docs/appenders/file.xml | 125 -
src/site/xdoc/docs/appenders/firephp.xml | 115 -
src/site/xdoc/docs/appenders/mail-event.xml | 145 -
src/site/xdoc/docs/appenders/mail.xml | 137 -
src/site/xdoc/docs/appenders/mongodb.xml | 169 -
src/site/xdoc/docs/appenders/null.xml | 78 -
src/site/xdoc/docs/appenders/pdo.xml | 444 -
src/site/xdoc/docs/appenders/php.xml | 91 -
src/site/xdoc/docs/appenders/rolling-file.xml | 155 -
src/site/xdoc/docs/appenders/socket.xml | 146 -
src/site/xdoc/docs/appenders/syslog.xml | 355 -
src/site/xdoc/docs/configuration.xml | 285 -
src/site/xdoc/docs/filters.xml | 327 -
src/site/xdoc/docs/introduction.xml | 98 -
src/site/xdoc/docs/layouts.xml | 75 -
src/site/xdoc/docs/layouts/html.xml | 202 -
src/site/xdoc/docs/layouts/pattern.xml | 655 --
src/site/xdoc/docs/layouts/serialized.xml | 122 -
src/site/xdoc/docs/layouts/simple.xml | 104 -
src/site/xdoc/docs/layouts/ttcc.xml | 162 -
src/site/xdoc/docs/layouts/xml.xml | 189 -
src/site/xdoc/docs/loggers.xml | 289 -
src/site/xdoc/docs/renderers.xml | 218 -
src/site/xdoc/install.xml | 89 -
src/site/xdoc/privacy.xml | 53 -
src/site/xdoc/quickstart.xml | 208 -
src/test/config/phpunit_to_surefire.xslt | 38 -
src/test/php/LoggerAppenderPoolTest.php | 65 -
src/test/php/LoggerAppenderTest.php | 173 -
src/test/php/LoggerConfiguratorTest.php | 452 -
src/test/php/LoggerExceptionTest.php | 41 -
src/test/php/LoggerFilterTest.php | 49 -
src/test/php/LoggerHierarchyTest.php | 100 -
src/test/php/LoggerLevelTest.php | 84 -
src/test/php/LoggerLoggingEventTest.php | 135 -
src/test/php/LoggerMDCTest.php | 116 -
src/test/php/LoggerNDCTest.php | 92 -
src/test/php/LoggerReflectionUtilsTest.php | 89 -
src/test/php/LoggerRootTest.php | 63 -
src/test/php/LoggerTest.php | 223 -
src/test/php/LoggerTestHelper.php | 156 -
src/test/php/LoggerThrowableInformationTest.php | 74 -
src/test/php/README | 19 -
.../php/appenders/LoggerAppenderConsoleTest.php | 89 -
.../appenders/LoggerAppenderDailyFileTest.php | 190 -
.../php/appenders/LoggerAppenderEchoTest.php | 165 -
.../php/appenders/LoggerAppenderFileTest.php | 135 -
.../php/appenders/LoggerAppenderFirephpTest.php | 201 -
.../appenders/LoggerAppenderMailEventTest.php | 81 -
.../php/appenders/LoggerAppenderMailTest.php | 60 -
.../php/appenders/LoggerAppenderMongoDBTest.php | 207 -
.../php/appenders/LoggerAppenderNullTest.php | 47 -
.../php/appenders/LoggerAppenderPDOTest.php | 164 -
.../php/appenders/LoggerAppenderPhpTest.php | 97 -
.../appenders/LoggerAppenderRollingFileTest.php | 206 -
.../php/appenders/LoggerAppenderSocketTest.php | 149 -
.../php/appenders/LoggerAppenderSyslogTest.php | 264 -
src/test/php/appenders/socketServer.php | 98 -
src/test/php/bootstrap.php | 45 -
.../LoggerConfigurationAdapterINITest.php | 173 -
.../LoggerConfigurationAdapterPHPTest.php | 99 -
.../LoggerConfigurationAdapterXMLTest.php | 175 -
.../php/filters/LoggerFilterDenyAllTest.php | 71 -
.../php/filters/LoggerFilterLevelMatchTest.php | 181 -
.../php/filters/LoggerFilterLevelRangeTest.php | 70 -
.../php/filters/LoggerFilterStringMatchTest.php | 113 -
.../php/helpers/LoggerOptionConverterTest.php | 147 -
.../php/helpers/LoggerPatternParserTest.php | 55 -
src/test/php/helpers/LoggerUtilsTest.php | 88 -
src/test/php/layouts/LoggerLayoutHtmlTest.php | 95 -
.../php/layouts/LoggerLayoutPatternTest.php | 54 -
.../php/layouts/LoggerLayoutSerializedTest.php | 107 -
src/test/php/layouts/LoggerLayoutSimpleTest.php | 40 -
src/test/php/layouts/LoggerLayoutTTCCTest.php | 68 -
src/test/php/layouts/LoggerLayoutXmlTest.php | 148 -
.../php/pattern/LoggerPatternConverterTest.php | 384 -
.../php/renderers/LoggerRendererMapTest.php | 243 -
.../config_invalid_appender_declaration_1.ini | 24 -
.../config_invalid_appender_declaration_2.ini | 24 -
.../adapters/ini/config_invalid_syntax.ini | 19 -
.../configs/adapters/ini/config_valid.ini | 41 -
.../resources/configs/adapters/ini/values.ini | 25 -
.../configs/adapters/php/config_empty.php | 28 -
.../adapters/php/config_invalid_syntax.php | 42 -
.../adapters/php/config_not_an_array.php | 29 -
.../configs/adapters/php/config_valid.php | 42 -
.../adapters/xml/config_duplicate_logger.xml | 39 -
.../adapters/xml/config_duplicate_renderer.xml | 30 -
.../adapters/xml/config_invalid_syntax.xml | 39 -
.../configs/adapters/xml/config_valid.xml | 54 -
.../adapters/xml/config_valid_underscore.xml | 57 -
.../appenders/config_invalid_appender_class.xml | 25 -
.../appenders/config_invalid_filter_class.xml | 27 -
.../config_invalid_filter_parameters.xml | 29 -
.../appenders/config_invalid_layout_class.xml | 27 -
.../configs/appenders/config_no_class.xml | 26 -
.../appenders/config_no_layout_class.xml | 27 -
.../appenders/config_not_existing_class.xml | 25 -
.../config_not_existing_filter_class.xml | 27 -
.../config_not_existing_layout_class.xml | 27 -
src/test/resources/configs/config.yml | 14 -
src/test/resources/configs/config1.xml | 54 -
.../loggers/config_invalid_additivity.xml | 30 -
.../loggers/config_not_existing_appenders.xml | 23 -
.../renderers/config_default_renderer.xml | 27 -
.../config_invalid_rendering_class.xml | 29 -
.../renderers/config_no_rendered_class.xml | 29 -
.../renderers/config_no_rendering_class.xml | 29 -
.../config_not_existing_rendering_class.xml | 29 -
tests/bootstrap.php | 45 +
tests/config/phpunit_to_surefire.xslt | 38 +
.../config_invalid_appender_declaration_1.ini | 23 +
.../config_invalid_appender_declaration_2.ini | 23 +
.../adapters/ini/config_invalid_syntax.ini | 19 +
.../configs/adapters/ini/config_valid.ini | 41 +
tests/resources/configs/adapters/ini/values.ini | 25 +
.../configs/adapters/php/config_empty.php | 26 +
.../adapters/php/config_invalid_syntax.php | 40 +
.../adapters/php/config_not_an_array.php | 27 +
.../configs/adapters/php/config_valid.php | 40 +
.../adapters/xml/config_duplicate_logger.xml | 39 +
.../adapters/xml/config_duplicate_renderer.xml | 30 +
.../adapters/xml/config_invalid_syntax.xml | 39 +
.../configs/adapters/xml/config_valid.xml | 54 +
.../adapters/xml/config_valid_underscore.xml | 57 +
.../appenders/config_invalid_appender_class.xml | 25 +
.../appenders/config_invalid_filter_class.xml | 27 +
.../config_invalid_filter_parameters.xml | 29 +
.../appenders/config_invalid_layout_class.xml | 27 +
.../configs/appenders/config_no_class.xml | 26 +
.../appenders/config_no_layout_class.xml | 27 +
.../appenders/config_not_existing_class.xml | 25 +
.../config_not_existing_filter_class.xml | 27 +
.../config_not_existing_layout_class.xml | 27 +
tests/resources/configs/config.yml | 14 +
tests/resources/configs/config1.xml | 54 +
.../loggers/config_invalid_additivity.xml | 30 +
.../loggers/config_not_existing_appenders.xml | 23 +
.../renderers/config_default_renderer.xml | 27 +
.../config_invalid_rendering_class.xml | 29 +
.../renderers/config_no_rendered_class.xml | 29 +
.../renderers/config_no_rendering_class.xml | 29 +
.../config_not_existing_rendering_class.xml | 29 +
tests/src/AppenderPoolTest.php | 84 +
tests/src/AppenderTest.php | 181 +
tests/src/Appenders/ConsoleAppenderTest.php | 91 +
tests/src/Appenders/DailyFileAppenderTest.php | 194 +
tests/src/Appenders/EchoAppenderTest.php | 170 +
tests/src/Appenders/FileAppenderTest.php | 139 +
tests/src/Appenders/MailAppenderTest.php | 64 +
tests/src/Appenders/MailEventAppenderTest.php | 86 +
tests/src/Appenders/MongoDBAppenderTest.php | 213 +
tests/src/Appenders/NullAppenderTest.php | 51 +
tests/src/Appenders/PDOAppenderTest.php | 170 +
tests/src/Appenders/PhpAppenderTest.php | 98 +
tests/src/Appenders/RollingFileAppenderTest.php | 212 +
tests/src/Appenders/SocketAppenderTest.php | 151 +
tests/src/Appenders/SyslogAppenderTest.php | 253 +
tests/src/Appenders/socketServer.php | 95 +
tests/src/ConfiguratorTest.php | 453 +
tests/src/Configurators/INIAdapterTest.php | 177 +
tests/src/Configurators/PHPAdapterTest.php | 101 +
tests/src/Configurators/XMLAdapterTest.php | 178 +
tests/src/ExceptionTest.php | 42 +
tests/src/FilterTest.php | 54 +
tests/src/Filters/FilterDenyAllTest.php | 75 +
tests/src/Filters/FilterLevelMatchTest.php | 184 +
tests/src/Filters/FilterLevelRangeTest.php | 75 +
tests/src/Filters/FilterStringMatchTest.php | 118 +
tests/src/Helpers/OptionConverterTest.php | 149 +
tests/src/Helpers/PatternParserTest.php | 54 +
tests/src/Helpers/UtilsTest.php | 89 +
tests/src/HierarchyTest.php | 105 +
tests/src/Layouts/HtmlLayoutTest.php | 99 +
tests/src/Layouts/PatternLayoutTest.php | 56 +
tests/src/Layouts/SerializedLayoutTest.php | 110 +
tests/src/Layouts/SimpleLayoutTest.php | 43 +
tests/src/Layouts/XmlLayoutTest.php | 153 +
tests/src/LevelTest.php | 86 +
tests/src/LoggerTest.php | 225 +
tests/src/LoggingEventTest.php | 139 +
tests/src/MDCTest.php | 119 +
tests/src/NDCTest.php | 94 +
tests/src/Pattern/PatternConverterTest.php | 415 +
tests/src/README | 19 +
tests/src/ReflectionUtilsTest.php | 91 +
tests/src/Renderers/RendererMapTest.php | 249 +
tests/src/RootLoggerTest.php | 67 +
tests/src/TestHelper.php | 160 +
tests/src/ThrowableInformationTest.php | 58 +
445 files changed, 16919 insertions(+), 45094 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 957eace..4f8d6df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
+composer.lock
target
temp
+tmp
+vendor
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/composer.json
----------------------------------------------------------------------
diff --git a/composer.json b/composer.json
index 2859e7e..dc14081 100644
--- a/composer.json
+++ b/composer.json
@@ -10,10 +10,16 @@
"source": "https://svn.apache.org/repos/asf/logging/log4php",
"email": "log4php-user@logging.apache.org"
},
- "autoload": {
- "classmap": ["src/main/php/"]
- },
"require": {
- "php": ">=5.2.7"
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "apigen/apigen": "2.*",
+ "mockery/mockery": "0.*",
+ "netcarver/textile": "3.5.*",
+ "phing/phing": "2.*",
+ "phpunit/phpunit": "3.7.*",
+ "squizlabs/php_codesniffer": "1.*",
+ "twig/twig": "1.*"
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/phpunit.xml
----------------------------------------------------------------------
diff --git a/phpunit.xml b/phpunit.xml
index 58fa534..44d191e 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -15,7 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
- <phpunit bootstrap="src/test/php/bootstrap.php"
+<phpunit bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
@@ -23,18 +23,21 @@
stopOnFailure="false">
<testsuite name="log4php">
- <directory>src/test/php</directory>
+ <directory>tests/src</directory>
</testsuite>
-
+
<filter>
<whitelist>
- <directory suffix=".php">src/main/php</directory>
+ <directory suffix=".php">src/</directory>
</whitelist>
</filter>
-
+
<logging>
- <log type="coverage-html" target="target/test/report" charset="UTF-8"
+ <log type="coverage-html" target="target/test/report" charset="UTF-8"
yui="true" highlight="false" lowUpperBound="35" highLowerBound="70"/>
</logging>
+ <listeners>
+ <listener class="\Mockery\Adapter\Phpunit\TestListenerxxx"></listener>
+ </listeners>
</phpunit>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/AppenderPool.php
----------------------------------------------------------------------
diff --git a/src/AppenderPool.php b/src/AppenderPool.php
new file mode 100644
index 0000000..ca57179
--- /dev/null
+++ b/src/AppenderPool.php
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+use Apache\Log4php\Appenders\AbstractAppender;
+
+/**
+ * Pool implmentation for Appender instances.
+ *
+ * The pool is used when configuring log4php. First all appender instances
+ * are created in the pool. Afterward, they are linked to loggers, each
+ * appender can be linked to multiple loggers. This makes sure duplicate
+ * appenders are not created.
+ */
+class AppenderPool {
+
+ /** Holds appenders indexed by their name */
+ public static $appenders = array();
+
+ /**
+ * Adds an appender to the pool.
+ * The appender must be named for this operation.
+ * @param Appender $appender
+ */
+ public static function add(AbstractAppender $appender) {
+ $name = $appender->getName();
+
+ if(empty($name)) {
+ trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING);
+ return;
+ }
+
+ if (isset(self::$appenders[$name])) {
+ trigger_error("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
+ }
+
+ self::$appenders[$name] = $appender;
+ }
+
+ /**
+ * Retrieves an appender from the pool by name.
+ * @param string $name Name of the appender to retrieve.
+ * @return Appender The named appender or NULL if no such appender
+ * exists in the pool.
+ */
+ public static function get($name) {
+ return isset(self::$appenders[$name]) ? self::$appenders[$name] : null;
+ }
+
+ /**
+ * Removes an appender from the pool by name.
+ * @param string $name Name of the appender to remove.
+ */
+ public static function delete($name) {
+ unset(self::$appenders[$name]);
+ }
+
+ /**
+ * Returns all appenders from the pool.
+ * @return array Array of Appender objects.
+ */
+ public static function getAppenders() {
+ return self::$appenders;
+ }
+
+ /**
+ * Checks whether an appender exists in the pool.
+ * @param string $name Name of the appender to look for.
+ * @return boolean TRUE if the appender with the given name exists.
+ */
+ public static function exists($name) {
+ return isset(self::$appenders[$name]);
+ }
+
+ /**
+ * Clears all appenders from the pool.
+ */
+ public static function clear() {
+ self::$appenders = array();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/AbstractAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/AbstractAppender.php b/src/Appenders/AbstractAppender.php
new file mode 100644
index 0000000..9ac29e1
--- /dev/null
+++ b/src/Appenders/AbstractAppender.php
@@ -0,0 +1,288 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\Configurable;
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Abstract class that defines output logs strategies.
+ */
+abstract class AbstractAppender extends Configurable {
+
+ /**
+ * Set to true when the appender is closed. A closed appender will not
+ * accept any logging requests.
+ * @var boolean
+ */
+ protected $closed = false;
+
+ /**
+ * The first filter in the filter chain.
+ * @var AbstractFilter
+ */
+ protected $filter;
+
+ /**
+ * The appender's layout. Can be null if the appender does not use
+ * a layout.
+ * @var Layout
+ */
+ protected $layout;
+
+ /**
+ * Appender name. Used by other components to identify this appender.
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * Appender threshold level. Events whose level is below the threshold
+ * will not be logged.
+ * @var Level
+ */
+ protected $threshold;
+
+ /**
+ * Set to true if the appender requires a layout.
+ *
+ * True by default, appenders which do not use a layout should override
+ * this property to false.
+ *
+ * @var boolean
+ */
+ protected $requiresLayout = true;
+
+ /**
+ * Default constructor.
+ * @param string $name Appender name
+ */
+ public function __construct($name = '') {
+ $this->name = $name;
+
+ if ($this->requiresLayout) {
+ $this->layout = $this->getDefaultLayout();
+ }
+ }
+
+ public function __destruct() {
+ $this->close();
+ }
+
+ /**
+ * Returns the default layout for this appender. Can be overriden by
+ * derived appenders.
+ *
+ * @return Layout
+ */
+ public function getDefaultLayout() {
+ return new SimpleLayout();
+ }
+
+ /**
+ * Adds a filter to the end of the filter chain.
+ * @param AbstractFilter $filter add a new AbstractFilter
+ */
+ public function addFilter($filter) {
+ if($this->filter === null) {
+ $this->filter = $filter;
+ } else {
+ $this->filter->addNext($filter);
+ }
+ }
+
+ /**
+ * Clears the filter chain by removing all the filters in it.
+ */
+ public function clearFilters() {
+ $this->filter = null;
+ }
+
+ /**
+ * Returns the first filter in the filter chain.
+ * The return value may be <i>null</i> if no is filter is set.
+ * @return AbstractFilter
+ */
+ public function getFilter() {
+ return $this->filter;
+ }
+
+ /**
+ * Returns the first filter in the filter chain.
+ * The return value may be <i>null</i> if no is filter is set.
+ * @return AbstractFilter
+ */
+ public function getFirstFilter() {
+ return $this->filter;
+ }
+
+ /**
+ * Performs threshold checks and invokes filters before delegating logging
+ * to the subclass' specific <i>append()</i> method.
+ * @see Appender::append()
+ * @param LoggingEvent $event
+ */
+ public function doAppend(LoggingEvent $event) {
+ if($this->closed) {
+ return;
+ }
+
+ if(!$this->isAsSevereAsThreshold($event->getLevel())) {
+ return;
+ }
+
+ $filter = $this->getFirstFilter();
+ while($filter !== null) {
+ switch ($filter->decide($event)) {
+ case AbstractFilter::DENY: return;
+ case AbstractFilter::ACCEPT: return $this->append($event);
+ case AbstractFilter::NEUTRAL: $filter = $filter->getNext();
+ }
+ }
+ $this->append($event);
+ }
+
+ /**
+ * Sets the appender layout.
+ * @param Layout $layout
+ */
+ public function setLayout($layout) {
+ if($this->requiresLayout()) {
+ $this->layout = $layout;
+ }
+ }
+
+ /**
+ * Returns the appender layout.
+ * @return Layout
+ */
+ public function getLayout() {
+ return $this->layout;
+ }
+
+ /**
+ * Configurators call this method to determine if the appender
+ * requires a layout.
+ *
+ * <p>If this method returns <i>true</i>, meaning that layout is required,
+ * then the configurator will configure a layout using the configuration
+ * information at its disposal. If this method returns <i>false</i>,
+ * meaning that a layout is not required, then layout configuration will be
+ * skipped even if there is available layout configuration
+ * information at the disposal of the configurator.</p>
+ *
+ * <p>In the rather exceptional case, where the appender
+ * implementation admits a layout but can also work without it, then
+ * the appender should return <i>true</i>.</p>
+ *
+ * @return boolean
+ */
+ public function requiresLayout() {
+ return $this->requiresLayout;
+ }
+
+ /**
+ * Retruns the appender name.
+ * @return string
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Sets the appender name.
+ * @param string $name
+ */
+ public function setName($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Returns the appender's threshold level.
+ * @return Level
+ */
+ public function getThreshold() {
+ return $this->threshold;
+ }
+
+ /**
+ * Sets the appender threshold.
+ *
+ * @param Level|string $threshold Either a {@link Level}
+ * object or a string equivalent.
+ * @see OptionConverter::toLevel()
+ */
+ public function setThreshold($threshold) {
+ $this->setLevel('threshold', $threshold);
+ }
+
+ /**
+ * Checks whether the message level is below the appender's threshold.
+ *
+ * If there is no threshold set, then the return value is always <i>true</i>.
+ *
+ * @param Level $level
+ * @return boolean Returns true if level is greater or equal than
+ * threshold, or if the threshold is not set. Otherwise returns false.
+ */
+ public function isAsSevereAsThreshold($level) {
+ if($this->threshold === null) {
+ return true;
+ }
+ return $level->isGreaterOrEqual($this->getThreshold());
+ }
+
+ /**
+ * Prepares the appender for logging.
+ *
+ * Derived appenders should override this method if option structure
+ * requires it.
+ */
+ public function activateOptions() {
+ $this->closed = false;
+ }
+
+ /**
+ * Forwards the logging event to the destination.
+ *
+ * Derived appenders should implement this method to perform actual logging.
+ *
+ * @param LoggingEvent $event
+ */
+ abstract protected function append(LoggingEvent $event);
+
+ /**
+ * Releases any resources allocated by the appender.
+ *
+ * Derived appenders should override this method to perform proper closing
+ * procedures.
+ */
+ public function close() {
+ $this->closed = true;
+ }
+
+ /** Triggers a warning for this logger with the given message. */
+ protected function warn($message) {
+ $id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
+ trigger_error("log4php: [$id]: $message", E_USER_WARNING);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/ConsoleAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/ConsoleAppender.php b/src/Appenders/ConsoleAppender.php
new file mode 100644
index 0000000..def5230
--- /dev/null
+++ b/src/Appenders/ConsoleAppender.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * ConsoleAppender appends log events either to the standard output
+ * stream (php://stdout) or the standard error stream (php://stderr).
+ *
+ * **Note**: Use this Appender with command-line php scripts. On web scripts
+ * this appender has no effects.
+ *
+ * This appender uses a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **target** - the target stream: "stdout" or "stderr"
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/console.html Appender documentation
+ */
+ class ConsoleAppender extends AbstractAppender {
+
+ /** The standard otuput stream. */
+ const STDOUT = 'php://stdout';
+
+ /** The standard error stream.*/
+ const STDERR = 'php://stderr';
+
+ /** The 'target' parameter. */
+ protected $target = self::STDOUT;
+
+ /**
+ * Stream resource for the target stream.
+ * @var resource
+ */
+ protected $fp = null;
+
+ public function activateOptions() {
+ $this->fp = fopen($this->target, 'w');
+ if(is_resource($this->fp) && $this->layout !== null) {
+ fwrite($this->fp, $this->layout->getHeader());
+ }
+ $this->closed = (bool)is_resource($this->fp) === false;
+ }
+
+
+ public function close() {
+ if($this->closed != true) {
+ if (is_resource($this->fp) && $this->layout !== null) {
+ fwrite($this->fp, $this->layout->getFooter());
+ fclose($this->fp);
+ }
+ $this->closed = true;
+ }
+ }
+
+ public function append(LoggingEvent $event) {
+ if (is_resource($this->fp) && $this->layout !== null) {
+ fwrite($this->fp, $this->layout->format($event));
+ }
+ }
+
+ /**
+ * Sets the 'target' parameter.
+ * @param string $target
+ */
+ public function setTarget($target) {
+ $value = trim($target);
+ if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
+ $this->target = self::STDOUT;
+ } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
+ $this->target = self::STDERR;
+ } else {
+ $target = var_export($target);
+ $this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
+ }
+ }
+
+ /**
+ * Returns the value of the 'target' parameter.
+ * @return string
+ */
+ public function getTarget() {
+ return $this->target;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/DailyFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/DailyFileAppender.php b/src/Appenders/DailyFileAppender.php
new file mode 100644
index 0000000..7ca1cc7
--- /dev/null
+++ b/src/Appenders/DailyFileAppender.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * An Appender that automatically creates a new logfile each day.
+ *
+ * The file is rolled over once a day. That means, for each day a new file
+ * is created. A formatted version of the date pattern is used as to create
+ * the file name using the {@link PHP_MANUAL#sprintf} function.
+ *
+ * This appender uses a layout.
+ *
+ * ##Configurable parameters:##
+ *
+ * - **datePattern** - Format for the date in the file path, follows formatting
+ * rules used by the PHP date() function. Default value: "Ymd".
+ * - **file** - Path to the target file. Should contain a %s which gets
+ * substituted by the date.
+ * - **append** - If set to true, the appender will append to the file,
+ * otherwise the file contents will be overwritten. Defaults to true.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/daily-file.html Appender documentation
+ */
+class DailyFileAppender extends FileAppender {
+
+ /**
+ * The 'datePattern' parameter.
+ * Determines how date will be formatted in file name.
+ * @var string
+ */
+ protected $datePattern = "Ymd";
+
+ /**
+ * Current date which was used when opening a file.
+ * Used to determine if a rollover is needed when the date changes.
+ * @var string
+ */
+ protected $currentDate;
+
+ /** Additional validation for the date pattern. */
+ public function activateOptions() {
+ parent::activateOptions();
+
+ if (empty($this->datePattern)) {
+ $this->warn("Required parameter 'datePattern' not set. Closing appender.");
+ $this->closed = true;
+ return;
+ }
+ }
+
+ /**
+ * 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(LoggingEvent $event) {
+ $eventDate = $this->getDate($event->getTimestamp());
+
+ // Initial setting of current date
+ if (!isset($this->currentDate)) {
+ $this->currentDate = $eventDate;
+ }
+
+ // Check if rollover is needed
+ 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;
+ }
+
+ parent::append($event);
+ }
+
+ /** Renders the date using the configured <var>datePattern<var>. */
+ protected function getDate($timestamp = null) {
+ return date($this->datePattern, $timestamp);
+ }
+
+ /**
+ * Determines target file. Replaces %s in file path with a date.
+ */
+ protected function getTargetFile() {
+ return str_replace('%s', $this->currentDate, $this->file);
+ }
+
+ /**
+ * Sets the 'datePattern' parameter.
+ * @param string $datePattern
+ */
+ public function setDatePattern($datePattern) {
+ $this->setString('datePattern', $datePattern);
+ }
+
+ /**
+ * Returns the 'datePattern' parameter.
+ * @return string
+ */
+ public function getDatePattern() {
+ return $this->datePattern;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/EchoAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/EchoAppender.php b/src/Appenders/EchoAppender.php
new file mode 100644
index 0000000..1b47ff9
--- /dev/null
+++ b/src/Appenders/EchoAppender.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * EchoAppender uses the PHP echo() function to output events.
+ *
+ * This appender uses a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **htmlLineBreaks** - If set to true, a <br /> element will be inserted
+ * before each line break in the logged message. Default is false.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/echo.html Appender documentation
+ */
+class EchoAppender extends AbstractAppender
+{
+ /**
+ * Used to mark first append. Set to false after first append.
+ * @var boolean
+ */
+ protected $firstAppend = true;
+
+ /**
+ * If set to true, a <br /> element will be inserted before each line
+ * break in the logged message. Default value is false. @var boolean
+ */
+ protected $htmlLineBreaks = false;
+
+ public function close() {
+ if($this->closed != true) {
+ if(!$this->firstAppend) {
+ echo $this->layout->getFooter();
+ }
+ }
+ $this->closed = true;
+ }
+
+ public function append(LoggingEvent $event) {
+ if($this->layout !== null) {
+ if($this->firstAppend) {
+ echo $this->layout->getHeader();
+ $this->firstAppend = false;
+ }
+ $text = $this->layout->format($event);
+
+ if ($this->htmlLineBreaks) {
+ $text = nl2br($text);
+ }
+ echo $text;
+ }
+ }
+
+ /**
+ * Sets the 'htmlLineBreaks' parameter.
+ * @param boolean $value
+ */
+ public function setHtmlLineBreaks($value) {
+ $this->setBoolean('htmlLineBreaks', $value);
+ }
+
+ /**
+ * Returns the 'htmlLineBreaks' parameter.
+ * @returns boolean
+ */
+ public function getHtmlLineBreaks() {
+ return $this->htmlLineBreaks;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/FileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/FileAppender.php b/src/Appenders/FileAppender.php
new file mode 100644
index 0000000..5f0cfd4
--- /dev/null
+++ b/src/Appenders/FileAppender.php
@@ -0,0 +1,225 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * FileAppender appends log events to a file.
+ *
+ * This appender uses a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **file** - Path to the target file. Relative paths are resolved based on
+ * the working directory.
+ * - **append** - If set to true, the appender will append to the file,
+ * otherwise the file contents will be overwritten.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/file.html Appender documentation
+ */
+class FileAppender extends AbstractAppender {
+
+ /**
+ * If set to true, the file is locked before appending. This allows
+ * concurrent access. However, appending without locking is faster so
+ * it should be used where appropriate.
+ *
+ * TODO: make this a configurable parameter
+ *
+ * @var boolean
+ */
+ protected $locking = true;
+
+ /**
+ * If set to true, appends to file. Otherwise overwrites it.
+ * @var boolean
+ */
+ protected $append = true;
+
+ /**
+ * Path to the target file.
+ * @var string
+ */
+ protected $file;
+
+ /**
+ * The file resource.
+ * @var resource
+ */
+ protected $fp;
+
+ /**
+ * Helper function which can be easily overriden by daily file appender.
+ */
+ protected function getTargetFile() {
+ return $this->file;
+ }
+
+ /**
+ * Acquires the target file resource, creates the destination folder if
+ * necessary. Writes layout header to file.
+ *
+ * @return boolean FALSE if opening failed
+ */
+ protected function openFile() {
+ $file = $this->getTargetFile();
+
+ // Create the target folder if needed
+ if(!is_file($file)) {
+ $dir = dirname($file);
+
+ if(!is_dir($dir)) {
+ $success = mkdir($dir, 0777, true);
+ if ($success === false) {
+ $this->warn("Failed creating target directory [$dir]. Closing appender.");
+ $this->closed = true;
+ return false;
+ }
+ }
+ }
+
+ $mode = $this->append ? 'a' : 'w';
+ $this->fp = fopen($file, $mode);
+ if ($this->fp === false) {
+ $this->warn("Failed opening target file. Closing appender.");
+ $this->fp = null;
+ $this->closed = true;
+ return false;
+ }
+
+ // Required when appending with concurrent access
+ if($this->append) {
+ fseek($this->fp, 0, SEEK_END);
+ }
+
+ // Write the header
+ $this->write($this->layout->getHeader());
+ }
+
+ /**
+ * Writes a string to the target file. Opens file if not already open.
+ * @param string $string Data to write.
+ */
+ protected function write($string) {
+ // Lazy file open
+ if(!isset($this->fp)) {
+ if ($this->openFile() === false) {
+ return; // Do not write if file open failed.
+ }
+ }
+
+ if ($this->locking) {
+ $this->writeWithLocking($string);
+ } else {
+ $this->writeWithoutLocking($string);
+ }
+ }
+
+ protected function writeWithLocking($string) {
+ if(flock($this->fp, LOCK_EX)) {
+ if(fwrite($this->fp, $string) === false) {
+ $this->warn("Failed writing to file. Closing appender.");
+ $this->closed = true;
+ }
+ flock($this->fp, LOCK_UN);
+ } else {
+ $this->warn("Failed locking file for writing. Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ protected function writeWithoutLocking($string) {
+ if(fwrite($this->fp, $string) === false) {
+ $this->warn("Failed writing to file. Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ public function activateOptions() {
+ if (empty($this->file)) {
+ $this->warn("Required parameter 'file' not set. Closing appender.");
+ $this->closed = true;
+ return;
+ }
+ }
+
+ public function close() {
+ if (is_resource($this->fp)) {
+ $this->write($this->layout->getFooter());
+ fclose($this->fp);
+ }
+ $this->fp = null;
+ $this->closed = true;
+ }
+
+ public function append(LoggingEvent $event) {
+ $this->write($this->layout->format($event));
+ }
+
+ /**
+ * Sets the 'file' parameter.
+ * @param string $file
+ */
+ public function setFile($file) {
+ $this->setString('file', $file);
+ }
+
+ /**
+ * Returns the 'file' parameter.
+ * @return string
+ */
+ public function getFile() {
+ return $this->file;
+ }
+
+ /**
+ * Returns the 'append' parameter.
+ * @return boolean
+ */
+ public function getAppend() {
+ return $this->append;
+ }
+
+ /**
+ * Sets the 'append' parameter.
+ * @param boolean $append
+ */
+ public function setAppend($append) {
+ $this->setBoolean('append', $append);
+ }
+
+ /**
+ * Sets the 'file' parmeter. Left for legacy reasons.
+ * @param string $fileName
+ * @deprecated Use setFile() instead.
+ */
+ public function setFileName($fileName) {
+ $this->setFile($fileName);
+ }
+
+ /**
+ * Returns the 'file' parmeter. Left for legacy reasons.
+ * @return string
+ * @deprecated Use getFile() instead.
+ */
+ public function getFileName() {
+ return $this->getFile();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/MailAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MailAppender.php b/src/Appenders/MailAppender.php
new file mode 100644
index 0000000..796167e
--- /dev/null
+++ b/src/Appenders/MailAppender.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * MailAppender appends log events via email.
+ *
+ * This appender does not send individual emails for each logging requests but
+ * will collect them in a buffer and send them all in a single email once the
+ * appender is closed (i.e. when the script exists). Because of this, it may
+ * not appropriate for long running scripts, in which case
+ * MailEventAppender might be a better choice.
+ *
+ * This appender uses a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **to** - Email address(es) to which the log will be sent. Multiple email
+ * addresses may be specified by separating them with a comma.
+ * - **from** - Email address which will be used in the From field.
+ * - **subject** - Subject of the email message.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/mail.html Appender documentation
+ */
+class MailAppender extends AbstractAppender {
+
+ /**
+ * Email address to put in From field of the email.
+ * @var string
+ */
+ protected $from = null;
+
+ /**
+ * The subject of the email.
+ * @var string
+ */
+ protected $subject = 'Log4php Report';
+
+ /**
+ * One or more comma separated email addresses to which to send the email.
+ * @var string
+ */
+ protected $to = null;
+
+ /**
+ * Indiciates whether this appender should run in dry mode.
+ * @deprecated
+ * @var boolean
+ */
+ protected $dry = false;
+
+ /**
+ * Buffer which holds the email contents before it is sent.
+ * @var string
+ */
+ protected $body = '';
+
+ public function append(LoggingEvent $event) {
+ if($this->layout !== null) {
+ $this->body .= $this->layout->format($event);
+ }
+ }
+
+ public function close() {
+ if($this->closed != true) {
+ $from = $this->from;
+ $to = $this->to;
+
+ if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
+ $subject = $this->subject;
+ if(!$this->dry) {
+ mail(
+ $to, $subject,
+ $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
+ "From: {$from}\r\n");
+ } else {
+ echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
+ }
+ }
+ $this->closed = true;
+ }
+ }
+
+ /** Sets the 'subject' parameter. */
+ public function setSubject($subject) {
+ $this->setString('subject', $subject);
+ }
+
+ /** Returns the 'subject' parameter. */
+ public function getSubject() {
+ return $this->subject;
+ }
+
+ /** Sets the 'to' parameter. */
+ public function setTo($to) {
+ $this->setString('to', $to);
+ }
+
+ /** Returns the 'to' parameter. */
+ public function getTo() {
+ return $this->to;
+ }
+
+ /** Sets the 'from' parameter. */
+ public function setFrom($from) {
+ $this->setString('from', $from);
+ }
+
+ /** Returns the 'from' parameter. */
+ public function getFrom() {
+ return $this->from;
+ }
+
+ /** Enables or disables dry mode. */
+ public function setDry($dry) {
+ $this->setBoolean('dry', $dry);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/MailEventAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MailEventAppender.php b/src/Appenders/MailEventAppender.php
new file mode 100644
index 0000000..c49ba12
--- /dev/null
+++ b/src/Appenders/MailEventAppender.php
@@ -0,0 +1,180 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * MailEventAppender appends individual log events via email.
+ *
+ * This appender is similar to MailAppender, except that it sends each
+ * each log event in an individual email message at the time when it occurs.
+ *
+ * This appender uses a layout.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **to** - Email address(es) to which the log will be sent. Multiple email
+ * addresses may be specified by separating them with a comma.
+ * - **from** - Email address which will be used in the From field.
+ * - **subject** - Subject of the email message.
+ * - **smtpHost** - Used to override the SMTP server. Only works on Windows.
+ * - **port** - Used to override the default SMTP server port. Only works on
+ * Windows.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/mail-event.html Appender documentation
+ */
+class MailEventAppender extends AbstractAppender {
+
+ /**
+ * Email address to put in From field of the email.
+ * @var string
+ */
+ protected $from;
+
+ /**
+ * Mail server port (widnows only).
+ * @var integer
+ */
+ protected $port = 25;
+
+ /**
+ * Mail server hostname (windows only).
+ * @var string
+ */
+ protected $smtpHost;
+
+ /**
+ * The subject of the email.
+ * @var string
+ */
+ protected $subject = 'Log4php Report';
+
+ /**
+ * One or more comma separated email addresses to which to send the email.
+ * @var string
+ */
+ protected $to = null;
+
+ /**
+ * Indiciates whether this appender should run in dry mode.
+ * @deprecated
+ * @var boolean
+ */
+ protected $dry = false;
+
+ public function activateOptions() {
+ if (empty($this->to)) {
+ $this->warn("Required parameter 'to' not set. Closing appender.");
+ $this->close = true;
+ return;
+ }
+
+ $sendmail_from = ini_get('sendmail_from');
+ if (empty($this->from) and empty($sendmail_from)) {
+ $this->warn("Required parameter 'from' not set. Closing appender.");
+ $this->close = true;
+ return;
+ }
+
+ $this->closed = false;
+ }
+
+ public function append(LoggingEvent $event) {
+ $smtpHost = $this->smtpHost;
+ $prevSmtpHost = ini_get('SMTP');
+ if(!empty($smtpHost)) {
+ ini_set('SMTP', $smtpHost);
+ }
+
+ $smtpPort = $this->port;
+ $prevSmtpPort= ini_get('smtp_port');
+ if($smtpPort > 0 and $smtpPort < 65535) {
+ ini_set('smtp_port', $smtpPort);
+ }
+
+ // On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
+
+ $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
+
+ if(!$this->dry) {
+ $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
+ } else {
+ echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
+ }
+
+ ini_set('SMTP', $prevSmtpHost);
+ ini_set('smtp_port', $prevSmtpPort);
+ }
+
+ /** Sets the 'from' parameter. */
+ public function setFrom($from) {
+ $this->setString('from', $from);
+ }
+
+ /** Returns the 'from' parameter. */
+ public function getFrom() {
+ return $this->from;
+ }
+
+ /** Sets the 'port' parameter. */
+ public function setPort($port) {
+ $this->setPositiveInteger('port', $port);
+ }
+
+ /** Returns the 'port' parameter. */
+ public function getPort() {
+ return $this->port;
+ }
+
+ /** Sets the 'smtpHost' parameter. */
+ public function setSmtpHost($smtpHost) {
+ $this->setString('smtpHost', $smtpHost);
+ }
+
+ /** Returns the 'smtpHost' parameter. */
+ public function getSmtpHost() {
+ return $this->smtpHost;
+ }
+
+ /** Sets the 'subject' parameter. */
+ public function setSubject($subject) {
+ $this->setString('subject', $subject);
+ }
+
+ /** Returns the 'subject' parameter. */
+ public function getSubject() {
+ return $this->subject;
+ }
+
+ /** Sets the 'to' parameter. */
+ public function setTo($to) {
+ $this->setString('to', $to);
+ }
+
+ /** Returns the 'to' parameter. */
+ public function getTo() {
+ return $this->to;
+ }
+
+ /** Enables or disables dry mode. */
+ public function setDry($dry) {
+ $this->setBoolean('dry', $dry);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/MongoDBAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MongoDBAppender.php b/src/Appenders/MongoDBAppender.php
new file mode 100644
index 0000000..38d7dca
--- /dev/null
+++ b/src/Appenders/MongoDBAppender.php
@@ -0,0 +1,366 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+use Exception;
+
+use Mongo;
+use MongoCollection;
+use MongoDate;
+
+/**
+ * Appender for writing to MongoDB.
+ *
+ * This class was originally contributed by Vladimir Gorej.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - **host** - Server on which mongodb instance is located.
+ * - **port** - Port on which the instance is bound.
+ * - **databaseName** - Name of the database to which to log.
+ * - **collectionName** - Name of the target collection within the given database.
+ * - **username** - Username used to connect to the database.
+ * - **password** - Password used to connect to the database.
+ * - **timeout** - For how long the driver should try to connect to the database (in milliseconds).
+ * @since 2.1
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/mongodb.html Appender documentation
+ * @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
+ * @link http://www.mongodb.org/ MongoDB website.
+ */
+class MongoDBAppender extends AbstractAppender {
+
+ // ******************************************
+ // ** Constants **
+ // ******************************************
+
+ /** Default prefix for the {@link $host}. */
+ const DEFAULT_MONGO_URL_PREFIX = 'mongodb://';
+
+ /** Default value for {@link $host}, without a prefix. */
+ const DEFAULT_MONGO_HOST = 'localhost';
+
+ /** Default value for {@link $port} */
+ const DEFAULT_MONGO_PORT = 27017;
+
+ /** Default value for {@link $databaseName} */
+ const DEFAULT_DB_NAME = 'log4php_mongodb';
+
+ /** Default value for {@link $collectionName} */
+ const DEFAULT_COLLECTION_NAME = 'logs';
+
+ /** Default value for {@link $timeout} */
+ const DEFAULT_TIMEOUT_VALUE = 3000;
+
+ // ******************************************
+ // ** Configurable parameters **
+ // ******************************************
+
+ /** Server on which mongodb instance is located. */
+ protected $host;
+
+ /** Port on which the instance is bound. */
+ protected $port;
+
+ /** Name of the database to which to log. */
+ protected $databaseName;
+
+ /** Name of the collection within the given database. */
+ protected $collectionName;
+
+ /** Username used to connect to the database. */
+ protected $userName;
+
+ /** Password used to connect to the database. */
+ protected $password;
+
+ /** Timeout value used when connecting to the database (in milliseconds). */
+ protected $timeout;
+
+ // ******************************************
+ // ** Member variables **
+ // ******************************************
+
+ /**
+ * Connection to the MongoDB instance.
+ * @var Mongo
+ */
+ protected $connection;
+
+ /**
+ * The collection to which log is written.
+ * @var MongoCollection
+ */
+ protected $collection;
+
+ public function __construct($name = '') {
+ parent::__construct($name);
+ $this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
+ $this->port = self::DEFAULT_MONGO_PORT;
+ $this->databaseName = self::DEFAULT_DB_NAME;
+ $this->collectionName = self::DEFAULT_COLLECTION_NAME;
+ $this->timeout = self::DEFAULT_TIMEOUT_VALUE;
+ $this->requiresLayout = false;
+ }
+
+ /**
+ * Setup db connection.
+ * Based on defined options, this method connects to the database and
+ * creates a {@link $collection}.
+ */
+ public function activateOptions() {
+ try {
+ $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
+ $db = $this->connection->selectDB($this->databaseName);
+ if ($this->userName !== null && $this->password !== null) {
+ $authResult = $db->authenticate($this->userName, $this->password);
+ if ($authResult['ok'] == floatval(0)) {
+ throw new Exception($authResult['errmsg'], $authResult['ok']);
+ }
+ }
+ $this->collection = $db->selectCollection($this->collectionName);
+ } catch (\MongoConnectionException $ex) {
+ $this->closed = true;
+ $this->warn(sprintf('Failed to connect to mongo deamon: %s', $ex->getMessage()));
+ } catch (\InvalidArgumentException $ex) {
+ $this->closed = true;
+ $this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
+ } catch (\Exception $ex) {
+ $this->closed = true;
+ $this->warn('Invalid credentials for mongo database authentication');
+ }
+ }
+
+ /**
+ * Appends a new event to the mongo database.
+ *
+ * @param LoggingEvent $event
+ */
+ public function append(LoggingEvent $event) {
+ try {
+ if ($this->collection != null) {
+ $this->collection->insert($this->format($event));
+ }
+ } catch (\MongoCursorException $ex) {
+ $this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
+ }
+ }
+
+ /**
+ * Converts the logging event into an array which can be logged to mongodb.
+ *
+ * @param LoggingEvent $event
+ * @return array The array representation of the logging event.
+ */
+ protected function format(LoggingEvent $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;
+ }
+
+ /**
+ * Converts an Exception into an array which can be logged to mongodb.
+ *
+ * Supports innner exceptions (PHP >= 5.3)
+ *
+ * @param Exception $ex
+ * @return array
+ */
+ protected function formatThrowable(Exception $ex) {
+ $array = array(
+ 'message' => $ex->getMessage(),
+ 'code' => $ex->getCode(),
+ 'stackTrace' => $ex->getTraceAsString(),
+ );
+
+ if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
+ $array['innerException'] = $this->formatThrowable($ex->getPrevious());
+ }
+
+ return $array;
+ }
+
+ /**
+ * Closes the connection to the logging database
+ */
+ public function close() {
+ if($this->closed != true) {
+ $this->collection = null;
+ if ($this->connection !== null) {
+ $this->connection->close();
+ $this->connection = null;
+ }
+ $this->closed = true;
+ }
+ }
+
+ /**
+ * Sets the value of {@link $host} parameter.
+ * @param string $host
+ */
+ public function setHost($host) {
+ if (!preg_match('/^mongodb\:\/\//', $host)) {
+ $host = self::DEFAULT_MONGO_URL_PREFIX . $host;
+ }
+ $this->host = $host;
+ }
+
+ /**
+ * Returns the value of {@link $host} parameter.
+ * @return string
+ */
+ public function getHost() {
+ return $this->host;
+ }
+
+ /**
+ * Sets the value of {@link $port} parameter.
+ * @param int $port
+ */
+ public function setPort($port) {
+ $this->setPositiveInteger('port', $port);
+ }
+
+ /**
+ * Returns the value of {@link $port} parameter.
+ * @return int
+ */
+ public function getPort() {
+ return $this->port;
+ }
+
+ /**
+ * Sets the value of {@link $databaseName} parameter.
+ * @param string $databaseName
+ */
+ public function setDatabaseName($databaseName) {
+ $this->setString('databaseName', $databaseName);
+ }
+
+ /**
+ * Returns the value of {@link $databaseName} parameter.
+ * @return string
+ */
+ public function getDatabaseName() {
+ return $this->databaseName;
+ }
+
+ /**
+ * Sets the value of {@link $collectionName} parameter.
+ * @param string $collectionName
+ */
+ public function setCollectionName($collectionName) {
+ $this->setString('collectionName', $collectionName);
+ }
+
+ /**
+ * Returns the value of {@link $collectionName} parameter.
+ * @return string
+ */
+ public function getCollectionName() {
+ return $this->collectionName;
+ }
+
+ /**
+ * Sets the value of {@link $userName} parameter.
+ * @param string $userName
+ */
+ public function setUserName($userName) {
+ $this->setString('userName', $userName, true);
+ }
+
+ /**
+ * Returns the value of {@link $userName} parameter.
+ * @return string
+ */
+ public function getUserName() {
+ return $this->userName;
+ }
+
+ /**
+ * Sets the value of {@link $password} parameter.
+ * @param string $password
+ */
+ public function setPassword($password) {
+ $this->setString('password', $password, true);
+ }
+
+ /**
+ * Returns the value of {@link $password} parameter.
+ * @return string
+ */
+ public function getPassword() {
+ return $this->password;
+ }
+
+ /**
+ * Sets the value of {@link $timeout} parameter.
+ * @param int $timeout
+ */
+ public function setTimeout($timeout) {
+ $this->setPositiveInteger('timeout', $timeout);
+ }
+
+ /**
+ * Returns the value of {@link $timeout} parameter.
+ * @return int
+ */
+ public function getTimeout() {
+ return $this->timeout;
+ }
+ /**
+ * Returns the mongodb connection.
+ * @return Mongo
+ */
+ public function getConnection() {
+ return $this->connection;
+ }
+
+ /**
+ * Returns the active mongodb collection.
+ * @return MongoCollection
+ */
+ public function getCollection() {
+ return $this->collection;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/NullAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/NullAppender.php b/src/Appenders/NullAppender.php
new file mode 100644
index 0000000..e599013
--- /dev/null
+++ b/src/Appenders/NullAppender.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * A NullAppender merely exists, it never outputs a message to any device.
+ *
+ * This appender has no configurable parameters.
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/null.html Appender documentation
+ */
+class NullAppender extends AbstractAppender {
+
+ /**
+ * This appender does not require a layout.
+ */
+ protected $requiresLayout = false;
+
+ /**
+ * Do nothing.
+ *
+ * @param LoggingEvent $event
+ */
+ public function append(LoggingEvent $event) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Appenders/PdoAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/PdoAppender.php b/src/Appenders/PdoAppender.php
new file mode 100644
index 0000000..87c81bf
--- /dev/null
+++ b/src/Appenders/PdoAppender.php
@@ -0,0 +1,287 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Appenders;
+
+use Apache\Log4php\Layouts\PatternLayout;
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Helpers\PatternParser;
+
+use PDO;
+use PDOException;
+
+/**
+ * PDOAppender appender logs to a database using the PHP's PDO extension.
+ *
+ * ## Configurable parameters: ##
+ *
+ * - dsn - The Data Source Name (DSN) used to connect to the database.
+ * - user - Username used to connect to the database.
+ * - password - Password used to connect to the database.
+ * - table - Name of the table to which log entries are be inserted.
+ * - insertSQL - Sets the insert statement for a logging event. Defaults
+ * to the correct one - change only if you are sure what you are doing.
+ * - insertPattern - The conversion pattern to use in conjuction with insert
+ * SQL. Must contain the same number of comma separated
+ * conversion patterns as there are question marks in the
+ * insertSQL.
+ * @since 2.0
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/pdo.html Appender documentation
+ */
+class PDOAppender extends AbstractAppender {
+
+ // ******************************************
+ // *** Configurable parameters ***
+ // ******************************************
+
+ /**
+ * DSN string used to connect to the database.
+ * @see http://www.php.net/manual/en/pdo.construct.php
+ */
+ protected $dsn;
+
+ /** Database user name. */
+ protected $user;
+
+ /** Database password. */
+ protected $password;
+
+ /**
+ * The insert query.
+ *
+ * The __TABLE__ placeholder will be replaced by the table name from
+ * {@link $table}.
+ *
+ * The questionmarks are part of the prepared statement, and they must
+ * match the number of conversion specifiers in {@link insertPattern}.
+ */
+ protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
+
+ /**
+ * A comma separated list of {@link LoggerPatternLayout} format strings
+ * which replace the "?" in {@link $insertSQL}.
+ *
+ * Must contain the same number of comma separated conversion patterns as
+ * there are question marks in {@link insertSQL}.
+ *
+ * @see LoggerPatternLayout For conversion patterns.
+ */
+ protected $insertPattern = "%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line";
+
+ /** Name of the table to which to append log events. */
+ protected $table = 'log4php_log';
+
+ /** The number of recconect attempts to make on failed append. */
+ protected $reconnectAttempts = 3;
+
+
+ // ******************************************
+ // *** Private memebers ***
+ // ******************************************
+
+ /**
+ * The PDO instance.
+ * @var PDO
+ */
+ protected $db;
+
+ /**
+ * Prepared statement for the insert query.
+ * @var PDOStatement
+ */
+ protected $preparedInsert;
+
+ /** This appender does not require a layout. */
+ protected $requiresLayout = false;
+
+
+ // ******************************************
+ // *** Appender methods ***
+ // ******************************************
+
+ /**
+ * 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 = PatternLayout::getDefaultConverterMap();
+ foreach($pieces as $pattern) {
+ $parser = new PatternParser($pattern, $converterMap);
+ $this->converters[] = $parser->parse();
+ }
+
+ $this->closed = false;
+ }
+
+ /**
+ * Connects to the database, and prepares the insert query.
+ * @throws PDOException If connect or prepare fails.
+ */
+ protected function establishConnection() {
+ // Acquire database connection
+ $this->db = new PDO($this->dsn, $this->user, $this->password);
+ $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ // Prepare the insert statement
+ $insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
+ $this->preparedInsert = $this->db->prepare($insertSQL);
+ }
+
+ /**
+ * Appends a new event to the database.
+ *
+ * If writing to database fails, it will retry by re-establishing the
+ * connection up to $reconnectAttempts times. If writing still fails,
+ * the appender will close.
+ */
+ public function append(LoggingEvent $event) {
+
+ for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
+ try {
+ // Attempt to write to database
+ $this->preparedInsert->execute($this->format($event));
+ $this->preparedInsert->closeCursor();
+ break;
+ } catch (PDOException $e) {
+ $this->warn("Failed writing to database: ". $e->getMessage());
+
+ // Close the appender if it's the last attempt
+ if ($attempt > $this->reconnectAttempts) {
+ $this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
+ $this->close();
+ // Otherwise reconnect and try to write again
+ } else {
+ $this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
+ $this->establishConnection();
+ }
+ }
+ }
+ }
+
+ /**
+ * Converts the logging event to a series of database parameters by using
+ * the converter chain which was set up on activation.
+ */
+ protected function format(LoggingEvent $event) {
+ $params = array();
+ foreach($this->converters as $converter) {
+ $buffer = '';
+ while ($converter !== null) {
+ $converter->format($buffer, $event);
+ $converter = $converter->next;
+ }
+ $params[] = $buffer;
+ }
+ return $params;
+ }
+
+ /**
+ * Closes the connection to the logging database
+ */
+ public function close() {
+ // Close the connection (if any)
+ $this->db = null;
+
+ // Close the appender
+ $this->closed = true;
+ }
+
+ // ******************************************
+ // *** Accessor methods ***
+ // ******************************************
+
+ /**
+ * Returns the active database handle or null if not established.
+ * @return PDO
+ */
+ public function getDatabaseHandle() {
+ return $this->db;
+ }
+
+ /** Sets the username. */
+ public function setUser($user) {
+ $this->setString('user', $user);
+ }
+
+ /** Returns the username. */
+ public function getUser($user) {
+ return $this->user;
+ }
+
+ /** Sets the password. */
+ public function setPassword($password) {
+ $this->setString('password', $password);
+ }
+
+ /** Returns the password. */
+ public function getPassword($password) {
+ return $this->password;
+ }
+
+ /** Sets the insert SQL. */
+ public function setInsertSQL($sql) {
+ $this->setString('insertSQL', $sql);
+ }
+
+ /** Returns the insert SQL. */
+ public function getInsertSQL($sql) {
+ return $this->insertSQL;
+ }
+
+ /** Sets the insert pattern. */
+ public function setInsertPattern($pattern) {
+ $this->setString('insertPattern', $pattern);
+ }
+
+ /** Returns the insert pattern. */
+ public function getInsertPattern($pattern) {
+ return $this->insertPattern;
+ }
+
+ /** Sets the table name. */
+ public function setTable($table) {
+ $this->setString('table', $table);
+ }
+
+ /** Returns the table name. */
+ public function getTable($table) {
+ return $this->table;
+ }
+
+ /** Sets the DSN string. */
+ public function setDSN($dsn) {
+ $this->setString('dsn', $dsn);
+ }
+
+ /** Returns the DSN string. */
+ public function getDSN($dsn) {
+ return $this->setString('dsn', $dsn);
+ }
+}
[34/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Level.php
----------------------------------------------------------------------
diff --git a/src/Level.php b/src/Level.php
index f17f0fc..78f8642 100644
--- a/src/Level.php
+++ b/src/Level.php
@@ -28,226 +28,250 @@ namespace Apache\Log4php;
* level set.</p>
* @since 0.5
*/
-class Level {
-
- const OFF = 2147483647;
- const FATAL = 50000;
- const ERROR = 40000;
- const WARN = 30000;
- const INFO = 20000;
- const DEBUG = 10000;
- const TRACE = 5000;
- const ALL = -2147483647;
-
- /** Integer level value. */
- private $level;
-
- /** Contains a list of instantiated levels. */
- private static $levelMap;
-
- /** String representation of the level. */
- private $levelStr;
-
- /**
- * Equivalent syslog level.
- * @var integer
- */
- private $syslogEquivalent;
-
- /**
- * Constructor
- *
- * @param integer $level
- * @param string $levelStr
- * @param integer $syslogEquivalent
- */
- private function __construct($level, $levelStr, $syslogEquivalent) {
- $this->level = $level;
- $this->levelStr = $levelStr;
- $this->syslogEquivalent = $syslogEquivalent;
- }
-
- /**
- * Compares two logger levels.
- *
- * @param Level $other
- * @return boolean
- */
- public function equals($other) {
- if($other instanceof Level) {
- if($this->level == $other->level) {
- return true;
- }
- } else {
- return false;
- }
- }
-
- /**
- * Returns an Off Level
- * @return Level
- */
- public static function getLevelOff() {
- if(!isset(self::$levelMap[Level::OFF])) {
- self::$levelMap[Level::OFF] = new Level(Level::OFF, 'OFF', LOG_ALERT);
- }
- return self::$levelMap[Level::OFF];
- }
-
- /**
- * Returns a Fatal Level
- * @return Level
- */
- public static function getLevelFatal() {
- if(!isset(self::$levelMap[Level::FATAL])) {
- self::$levelMap[Level::FATAL] = new Level(Level::FATAL, 'FATAL', LOG_ALERT);
- }
- return self::$levelMap[Level::FATAL];
- }
-
- /**
- * Returns an Error Level
- * @return Level
- */
- public static function getLevelError() {
- if(!isset(self::$levelMap[Level::ERROR])) {
- self::$levelMap[Level::ERROR] = new Level(Level::ERROR, 'ERROR', LOG_ERR);
- }
- return self::$levelMap[Level::ERROR];
- }
-
- /**
- * Returns a Warn Level
- * @return Level
- */
- public static function getLevelWarn() {
- if(!isset(self::$levelMap[Level::WARN])) {
- self::$levelMap[Level::WARN] = new Level(Level::WARN, 'WARN', LOG_WARNING);
- }
- return self::$levelMap[Level::WARN];
- }
-
- /**
- * Returns an Info Level
- * @return Level
- */
- public static function getLevelInfo() {
- if(!isset(self::$levelMap[Level::INFO])) {
- self::$levelMap[Level::INFO] = new Level(Level::INFO, 'INFO', LOG_INFO);
- }
- return self::$levelMap[Level::INFO];
- }
-
- /**
- * Returns a Debug Level
- * @return Level
- */
- public static function getLevelDebug() {
- if(!isset(self::$levelMap[Level::DEBUG])) {
- self::$levelMap[Level::DEBUG] = new Level(Level::DEBUG, 'DEBUG', LOG_DEBUG);
- }
- return self::$levelMap[Level::DEBUG];
- }
-
- /**
- * Returns a Trace Level
- * @return Level
- */
- public static function getLevelTrace() {
- if(!isset(self::$levelMap[Level::TRACE])) {
- self::$levelMap[Level::TRACE] = new Level(Level::TRACE, 'TRACE', LOG_DEBUG);
- }
- return self::$levelMap[Level::TRACE];
- }
-
- /**
- * Returns an All Level
- * @return Level
- */
- public static function getLevelAll() {
- if(!isset(self::$levelMap[Level::ALL])) {
- self::$levelMap[Level::ALL] = new Level(Level::ALL, 'ALL', LOG_DEBUG);
- }
- return self::$levelMap[Level::ALL];
- }
-
- /**
- * Return the syslog equivalent of this level as an integer.
- * @return integer
- */
- public function getSyslogEquivalent() {
- return $this->syslogEquivalent;
- }
-
- /**
- * Returns <i>true</i> if this level has a higher or equal
- * level than the level passed as argument, <i>false</i>
- * otherwise.
- *
- * @param Level $other
- * @return boolean
- */
- public function isGreaterOrEqual($other) {
- return $this->level >= $other->level;
- }
-
- /**
- * Returns the string representation of this level.
- * @return string
- */
- public function toString() {
- return $this->levelStr;
- }
-
- /**
- * Returns the string representation of this level.
- * @return string
- */
- public function __toString() {
- return $this->toString();
- }
-
- /**
- * Returns the integer representation of this level.
- * @return integer
- */
- public function toInt() {
- return $this->level;
- }
-
- /**
- * Convert the input argument to a level. If the conversion fails, then
- * this method returns the provided default level.
- *
- * @param mixed $arg The value to convert to level.
- * @param Level $default Value to return if conversion is not possible.
- * @return Level
- */
- public static function toLevel($arg, $defaultLevel = null) {
- if(is_int($arg)) {
- switch($arg) {
- case self::ALL: return self::getLevelAll();
- case self::TRACE: return self::getLevelTrace();
- case self::DEBUG: return self::getLevelDebug();
- case self::INFO: return self::getLevelInfo();
- case self::WARN: return self::getLevelWarn();
- case self::ERROR: return self::getLevelError();
- case self::FATAL: return self::getLevelFatal();
- case self::OFF: return self::getLevelOff();
- default: return $defaultLevel;
- }
- } else {
- switch(strtoupper($arg)) {
- case 'ALL': return self::getLevelAll();
- case 'TRACE': return self::getLevelTrace();
- case 'DEBUG': return self::getLevelDebug();
- case 'INFO': return self::getLevelInfo();
- case 'WARN': return self::getLevelWarn();
- case 'ERROR': return self::getLevelError();
- case 'FATAL': return self::getLevelFatal();
- case 'OFF': return self::getLevelOff();
- default: return $defaultLevel;
- }
- }
- }
+class Level
+{
+ const OFF = 2147483647;
+ const FATAL = 50000;
+ const ERROR = 40000;
+ const WARN = 30000;
+ const INFO = 20000;
+ const DEBUG = 10000;
+ const TRACE = 5000;
+ const ALL = -2147483647;
+
+ /** Integer level value. */
+ private $level;
+
+ /** Contains a list of instantiated levels. */
+ private static $levelMap;
+
+ /** String representation of the level. */
+ private $levelStr;
+
+ /**
+ * Equivalent syslog level.
+ * @var integer
+ */
+ private $syslogEquivalent;
+
+ /**
+ * Constructor
+ *
+ * @param integer $level
+ * @param string $levelStr
+ * @param integer $syslogEquivalent
+ */
+ private function __construct($level, $levelStr, $syslogEquivalent)
+ {
+ $this->level = $level;
+ $this->levelStr = $levelStr;
+ $this->syslogEquivalent = $syslogEquivalent;
+ }
+
+ /**
+ * Compares two logger levels.
+ *
+ * @param Level $other
+ * @return boolean
+ */
+ public function equals($other)
+ {
+ if ($other instanceof Level) {
+ if ($this->level == $other->level) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns an Off Level
+ * @return Level
+ */
+ public static function getLevelOff()
+ {
+ if (!isset(self::$levelMap[Level::OFF])) {
+ self::$levelMap[Level::OFF] = new Level(Level::OFF, 'OFF', LOG_ALERT);
+ }
+
+ return self::$levelMap[Level::OFF];
+ }
+
+ /**
+ * Returns a Fatal Level
+ * @return Level
+ */
+ public static function getLevelFatal()
+ {
+ if (!isset(self::$levelMap[Level::FATAL])) {
+ self::$levelMap[Level::FATAL] = new Level(Level::FATAL, 'FATAL', LOG_ALERT);
+ }
+
+ return self::$levelMap[Level::FATAL];
+ }
+
+ /**
+ * Returns an Error Level
+ * @return Level
+ */
+ public static function getLevelError()
+ {
+ if (!isset(self::$levelMap[Level::ERROR])) {
+ self::$levelMap[Level::ERROR] = new Level(Level::ERROR, 'ERROR', LOG_ERR);
+ }
+
+ return self::$levelMap[Level::ERROR];
+ }
+
+ /**
+ * Returns a Warn Level
+ * @return Level
+ */
+ public static function getLevelWarn()
+ {
+ if (!isset(self::$levelMap[Level::WARN])) {
+ self::$levelMap[Level::WARN] = new Level(Level::WARN, 'WARN', LOG_WARNING);
+ }
+
+ return self::$levelMap[Level::WARN];
+ }
+
+ /**
+ * Returns an Info Level
+ * @return Level
+ */
+ public static function getLevelInfo()
+ {
+ if (!isset(self::$levelMap[Level::INFO])) {
+ self::$levelMap[Level::INFO] = new Level(Level::INFO, 'INFO', LOG_INFO);
+ }
+
+ return self::$levelMap[Level::INFO];
+ }
+
+ /**
+ * Returns a Debug Level
+ * @return Level
+ */
+ public static function getLevelDebug()
+ {
+ if (!isset(self::$levelMap[Level::DEBUG])) {
+ self::$levelMap[Level::DEBUG] = new Level(Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ }
+
+ return self::$levelMap[Level::DEBUG];
+ }
+
+ /**
+ * Returns a Trace Level
+ * @return Level
+ */
+ public static function getLevelTrace()
+ {
+ if (!isset(self::$levelMap[Level::TRACE])) {
+ self::$levelMap[Level::TRACE] = new Level(Level::TRACE, 'TRACE', LOG_DEBUG);
+ }
+
+ return self::$levelMap[Level::TRACE];
+ }
+
+ /**
+ * Returns an All Level
+ * @return Level
+ */
+ public static function getLevelAll()
+ {
+ if (!isset(self::$levelMap[Level::ALL])) {
+ self::$levelMap[Level::ALL] = new Level(Level::ALL, 'ALL', LOG_DEBUG);
+ }
+
+ return self::$levelMap[Level::ALL];
+ }
+
+ /**
+ * Return the syslog equivalent of this level as an integer.
+ * @return integer
+ */
+ public function getSyslogEquivalent()
+ {
+ return $this->syslogEquivalent;
+ }
+
+ /**
+ * Returns <i>true</i> if this level has a higher or equal
+ * level than the level passed as argument, <i>false</i>
+ * otherwise.
+ *
+ * @param Level $other
+ * @return boolean
+ */
+ public function isGreaterOrEqual($other)
+ {
+ return $this->level >= $other->level;
+ }
+
+ /**
+ * Returns the string representation of this level.
+ * @return string
+ */
+ public function toString()
+ {
+ return $this->levelStr;
+ }
+
+ /**
+ * Returns the string representation of this level.
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Returns the integer representation of this level.
+ * @return integer
+ */
+ public function toInt()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Convert the input argument to a level. If the conversion fails, then
+ * this method returns the provided default level.
+ *
+ * @param mixed $arg The value to convert to level.
+ * @param Level $default Value to return if conversion is not possible.
+ * @return Level
+ */
+ public static function toLevel($arg, $defaultLevel = null)
+ {
+ if (is_int($arg)) {
+ switch ($arg) {
+ case self::ALL: return self::getLevelAll();
+ case self::TRACE: return self::getLevelTrace();
+ case self::DEBUG: return self::getLevelDebug();
+ case self::INFO: return self::getLevelInfo();
+ case self::WARN: return self::getLevelWarn();
+ case self::ERROR: return self::getLevelError();
+ case self::FATAL: return self::getLevelFatal();
+ case self::OFF: return self::getLevelOff();
+ default: return $defaultLevel;
+ }
+ } else {
+ switch (strtoupper($arg)) {
+ case 'ALL': return self::getLevelAll();
+ case 'TRACE': return self::getLevelTrace();
+ case 'DEBUG': return self::getLevelDebug();
+ case 'INFO': return self::getLevelInfo();
+ case 'WARN': return self::getLevelWarn();
+ case 'ERROR': return self::getLevelError();
+ case 'FATAL': return self::getLevelFatal();
+ case 'OFF': return self::getLevelOff();
+ default: return $defaultLevel;
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/LocationInfo.php
----------------------------------------------------------------------
diff --git a/src/LocationInfo.php b/src/LocationInfo.php
index 4615962..bbb9fd9 100644
--- a/src/LocationInfo.php
+++ b/src/LocationInfo.php
@@ -22,79 +22,85 @@ namespace Apache\Log4php;
* The internal representation of caller location information.
* @since 0.3
*/
-class LocationInfo {
+class LocationInfo
+{
+ /** The value to return when the location information is not available. */
+ const LOCATION_INFO_NA = 'NA';
- /** The value to return when the location information is not available. */
- const LOCATION_INFO_NA = 'NA';
+ /**
+ * Caller line number.
+ * @var integer
+ */
+ protected $lineNumber;
- /**
- * Caller line number.
- * @var integer
- */
- protected $lineNumber;
+ /**
+ * Caller file name.
+ * @var string
+ */
+ protected $fileName;
- /**
- * Caller file name.
- * @var string
- */
- protected $fileName;
+ /**
+ * Caller class name.
+ * @var string
+ */
+ protected $className;
- /**
- * Caller class name.
- * @var string
- */
- protected $className;
+ /**
+ * Caller method name.
+ * @var string
+ */
+ protected $methodName;
- /**
- * Caller method name.
- * @var string
- */
- protected $methodName;
+ /**
+ * All the information combined.
+ * @var string
+ */
+ protected $fullInfo;
- /**
- * All the information combined.
- * @var string
- */
- protected $fullInfo;
+ /**
+ * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
+ *
+ * @param array $trace
+ * @param mixed $caller
+ */
+ public function __construct($trace, $fqcn = null)
+ {
+ $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
+ $this->fileName = isset($trace['file']) ? $trace['file'] : null;
+ $this->className = isset($trace['class']) ? $trace['class'] : null;
+ $this->methodName = isset($trace['function']) ? $trace['function'] : null;
+ $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
+ '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
+ }
- /**
- * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
- *
- * @param array $trace
- * @param mixed $caller
- */
- public function __construct($trace, $fqcn = null) {
- $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
- $this->fileName = isset($trace['file']) ? $trace['file'] : null;
- $this->className = isset($trace['class']) ? $trace['class'] : null;
- $this->methodName = isset($trace['function']) ? $trace['function'] : null;
- $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
- '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
- }
+ /** Returns the caller class name. */
+ public function getClassName()
+ {
+ return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
+ }
- /** Returns the caller class name. */
- public function getClassName() {
- return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
- }
+ /** Returns the caller file name. */
+ public function getFileName()
+ {
+ return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
+ }
- /** Returns the caller file name. */
- public function getFileName() {
- return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
- }
+ /** Returns the caller line number. */
+ public function getLineNumber()
+ {
+ return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
+ }
- /** Returns the caller line number. */
- public function getLineNumber() {
- return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
- }
+ /** Returns the caller method name. */
+ public function getMethodName()
+ {
+ return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
+ }
- /** Returns the caller method name. */
- public function getMethodName() {
- return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
- }
-
- /** Returns the full information of the caller. */
- public function getFullInfo() {
- return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
- }
+ /** Returns the full information of the caller. */
+ public function getFullInfo()
+ {
+ return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Logger.php
----------------------------------------------------------------------
diff --git a/src/Logger.php b/src/Logger.php
index 27eca1c..055cd34 100644
--- a/src/Logger.php
+++ b/src/Logger.php
@@ -35,558 +35,609 @@ namespace Apache\Log4php;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php
*/
-class Logger {
-
- /**
- * Logger additivity. If set to true then child loggers will inherit
- * the appenders of their ancestors by default.
- * @var boolean
- */
- private $additive = true;
-
- /**
- * The Logger's fully qualified class name.
- * TODO: Determine if this is useful.
- */
- private $fqcn = 'Logger';
-
- /** The assigned Logger level. */
- private $level;
-
- /** The name of this Logger instance. */
- private $name;
-
- /** The parent logger. Set to null if this is the root logger. */
- private $parent;
-
- /** A collection of appenders linked to this logger. */
- private $appenders = array();
-
- /**
- * Constructor.
- * @param string $name Name of the logger.
- */
- public function __construct($name) {
- $this->name = $name;
- }
-
- /**
- * Returns the logger name.
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Returns the parent Logger. Can be null if this is the root logger.
- * @return Logger
- */
- public function getParent() {
- return $this->parent;
- }
-
- // ******************************************
- // *** Logging methods ***
- // ******************************************
-
- /**
- * Log a message object with the TRACE level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function trace($message, $throwable = null) {
- $this->log(Level::getLevelTrace(), $message, $throwable);
- }
-
- /**
- * Log a message object with the DEBUG level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function debug($message, $throwable = null) {
- $this->log(Level::getLevelDebug(), $message, $throwable);
- }
-
- /**
- * Log a message object with the INFO Level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function info($message, $throwable = null) {
- $this->log(Level::getLevelInfo(), $message, $throwable);
- }
-
- /**
- * Log a message with the WARN level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function warn($message, $throwable = null) {
- $this->log(Level::getLevelWarn(), $message, $throwable);
- }
-
- /**
- * Log a message object with the ERROR level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function error($message, $throwable = null) {
- $this->log(Level::getLevelError(), $message, $throwable);
- }
-
- /**
- * Log a message object with the FATAL level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function fatal($message, $throwable = null) {
- $this->log(Level::getLevelFatal(), $message, $throwable);
- }
-
- /**
- * Log a message using the provided logging level.
- *
- * @param Level $level The logging level.
- * @param mixed $message Message to log.
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function log(Level $level, $message, $throwable = null) {
- if($this->isEnabledFor($level)) {
- $event = new LoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
- $this->callAppenders($event);
- }
-
- // Forward the event upstream if additivity is turned on
- if(isset($this->parent) && $this->getAdditivity()) {
-
- // Use the event if already created
- if (isset($event)) {
- $this->parent->logEvent($event);
- } else {
- $this->parent->log($level, $message, $throwable);
- }
- }
- }
-
- /**
- * Logs an already prepared logging event object.
- * @param LoggingEvent $event
- */
- public function logEvent(LoggingEvent $event) {
- if($this->isEnabledFor($event->getLevel())) {
- $this->callAppenders($event);
- }
-
- // Forward the event upstream if additivity is turned on
- if(isset($this->parent) && $this->getAdditivity()) {
- $this->parent->logEvent($event);
- }
- }
-
- /**
- * If assertion parameter evaluates as false, then logs the message
- * using the ERROR level.
- *
- * @param bool $assertion
- * @param string $msg message to log
- */
- public function assertLog($assertion = true, $msg = '') {
- if($assertion == false) {
- $this->error($msg);
- }
- }
-
- /**
- * This method creates a new logging event and logs the event without
- * further checks.
- *
- * It should not be called directly. Use {@link trace()}, {@link debug()},
- * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
- * wrappers.
- *
- * @param string $fqcn Fully qualified class name of the Logger
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- * @param Level $level log level
- * @param mixed $message message to log
- */
- public function forcedLog($fqcn, $throwable, Level $level, $message) {
- $event = new LoggingEvent($fqcn, $this, $level, $message, null, $throwable);
- $this->callAppenders($event);
-
- // Forward the event upstream if additivity is turned on
- if(isset($this->parent) && $this->getAdditivity()) {
- $this->parent->logEvent($event);
- }
- }
-
- /**
- * Forwards the given logging event to all linked appenders.
- * @param LoggingEvent $event
- */
- public function callAppenders($event) {
- foreach($this->appenders as $appender) {
- $appender->doAppend($event);
- }
- }
-
- // ******************************************
- // *** Checker methods ***
- // ******************************************
-
- /**
- * Check whether this Logger is enabled for a given Level passed as parameter.
- *
- * @param Level level
- * @return boolean
- */
- public function isEnabledFor(Level $level) {
- return $level->isGreaterOrEqual($this->getEffectiveLevel());
- }
-
- /**
- * Check whether this Logger is enabled for the TRACE Level.
- * @return boolean
- */
- public function isTraceEnabled() {
- return $this->isEnabledFor(Level::getLevelTrace());
- }
-
- /**
- * Check whether this Logger is enabled for the DEBUG Level.
- * @return boolean
- */
- public function isDebugEnabled() {
- return $this->isEnabledFor(Level::getLevelDebug());
- }
-
- /**
- * Check whether this Logger is enabled for the INFO Level.
- * @return boolean
- */
- public function isInfoEnabled() {
- return $this->isEnabledFor(Level::getLevelInfo());
- }
-
- /**
- * Check whether this Logger is enabled for the WARN Level.
- * @return boolean
- */
- public function isWarnEnabled() {
- return $this->isEnabledFor(Level::getLevelWarn());
- }
-
- /**
- * Check whether this Logger is enabled for the ERROR Level.
- * @return boolean
- */
- public function isErrorEnabled() {
- return $this->isEnabledFor(Level::getLevelError());
- }
-
- /**
- * Check whether this Logger is enabled for the FATAL Level.
- * @return boolean
- */
- public function isFatalEnabled() {
- return $this->isEnabledFor(Level::getLevelFatal());
- }
-
- // ******************************************
- // *** Configuration methods ***
- // ******************************************
-
- /**
- * Adds a new appender to the Logger.
- * @param Appender $appender The appender to add.
- */
- public function addAppender($appender) {
- $appenderName = $appender->getName();
- $this->appenders[$appenderName] = $appender;
- }
-
- /** Removes all appenders from the Logger. */
- public function removeAllAppenders() {
- foreach($this->appenders as $name => $appender) {
- $this->removeAppender($name);
- }
- }
-
- /**
- * Remove the appender passed as parameter form the Logger.
- * @param mixed $appender an appender name or a {@link Appender} instance.
- */
- public function removeAppender($appender) {
- if($appender instanceof Appender) {
- $appender->close();
- unset($this->appenders[$appender->getName()]);
- } else if (is_string($appender) and isset($this->appenders[$appender])) {
- $this->appenders[$appender]->close();
- unset($this->appenders[$appender]);
- }
- }
-
- /**
- * Returns the appenders linked to this logger as an array.
- * @return array collection of appender names
- */
- public function getAllAppenders() {
- return $this->appenders;
- }
-
- /**
- * Returns a linked appender by name.
- * @return Appender
- */
- public function getAppender($name) {
- return $this->appenders[$name];
- }
-
- /**
- * Sets the additivity flag.
- * @param boolean $additive
- */
- public function setAdditivity($additive) {
- $this->additive = (bool)$additive;
- }
-
- /**
- * Returns the additivity flag.
- * @return boolean
- */
- public function getAdditivity() {
- return $this->additive;
- }
-
- /**
- * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
- * @see Level
- * @return Level or null
- */
- public function getEffectiveLevel() {
- for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
- if($logger->getLevel() !== null) {
- return $logger->getLevel();
- }
- }
- }
-
- /**
- * Get the assigned Logger level.
- * @return Level The assigned level or null if none is assigned.
- */
- public function getLevel() {
- return $this->level;
- }
-
- /**
- * Set the Logger level.
- *
- * Use Level::getLevelXXX() methods to get a Level object, e.g.
- * <code>$logger->setLevel(Level::getLevelInfo());</code>
- *
- * @param Level $level The level to set, or NULL to clear the logger level.
- */
- public function setLevel(Level $level = null) {
- $this->level = $level;
- }
-
- /**
- * Checks whether an appender is attached to this logger instance.
- *
- * @param Appender $appender
- * @return boolean
- */
- public function isAttached(Appender $appender) {
- return isset($this->appenders[$appender->getName()]);
- }
-
- /**
- * Sets the parent logger.
- * @param Logger $logger
- */
- public function setParent(Logger $logger) {
- $this->parent = $logger;
- }
-
- // ******************************************
- // *** Static methods and properties ***
- // ******************************************
-
- /** The logger hierarchy used by log4php. */
- private static $hierarchy;
-
- /** Inidicates if log4php has been initialized */
- private static $initialized = false;
-
- /**
- * Returns the hierarchy used by this Logger.
- *
- * Caution: do not use this hierarchy unless you have called initialize().
- * To get Loggers, use the Logger::getLogger and Logger::getRootLogger
- * methods instead of operating on on the hierarchy directly.
- *
- * @return Hierarchy
- */
- public static function getHierarchy() {
- if(!isset(self::$hierarchy)) {
- self::$hierarchy = new Hierarchy(new RootLogger());
- }
- return self::$hierarchy;
- }
-
- /**
- * Returns a Logger by name. If it does not exist, it will be created.
- *
- * @param string $name The logger name
- * @return Logger
- */
- public static function getLogger($name) {
- if(!self::isInitialized()) {
- self::configure();
- }
- return self::getHierarchy()->getLogger($name);
- }
-
- /**
- * Returns the Root Logger.
- * @return RootLogger
- */
- public static function getRootLogger() {
- if(!self::isInitialized()) {
- self::configure();
- }
- return self::getHierarchy()->getRootLogger();
- }
-
- /**
- * Clears all Logger definitions from the logger hierarchy.
- * @return boolean
- */
- public static function clear() {
- return self::getHierarchy()->clear();
- }
-
- /**
- * Destroy configurations for logger definitions
- */
- public static function resetConfiguration() {
- self::getHierarchy()->resetConfiguration();
- self::getHierarchy()->clear(); // TODO: clear or not?
- self::$initialized = false;
- }
-
- /**
- * Safely close all appenders.
- * @deprecated This is no longer necessary due the appenders shutdown via
- * destructors.
- */
- public static function shutdown() {
- return self::getHierarchy()->shutdown();
- }
-
- /**
- * check if a given logger exists.
- *
- * @param string $name logger name
- * @return boolean
- */
- public static function exists($name) {
- return self::getHierarchy()->exists($name);
- }
-
- /**
- * Returns an array this whole Logger instances.
- * @see Logger
- * @return array
- */
- public static function getCurrentLoggers() {
- return self::getHierarchy()->getCurrentLoggers();
- }
-
- /**
- * Configures log4php.
- *
- * This method needs to be called before the first logging event has
- * occured. If this method is not called before then the default
- * configuration will be used.
- *
- * @param string|array $configuration Either a path to the configuration
- * file, or a configuration array.
- *
- * @param string|Configurator $configurator A custom
- * configurator class: either a class name (string), or an object which
- * implements the Configurator interface. If left empty, the default
- * configurator implementation will be used.
- */
- public static function configure($configuration = null, $configurator = null) {
- self::resetConfiguration();
- $configurator = self::getConfigurator($configurator);
- $configurator->configure(self::getHierarchy(), $configuration);
- self::$initialized = true;
- }
-
- /**
- * Creates a logger configurator instance based on the provided
- * configurator class. If no class is given, returns an instance of
- * the default configurator.
- *
- * @param string|Configurator $configurator The configurator class
- * or Configurator instance.
- */
- private static function getConfigurator($configurator = null) {
- if ($configurator === null) {
- return new Configuration\DefaultConfigurator();
- }
-
- if (is_object($configurator)) {
- if ($configurator instanceof Configurator) {
- return $configurator;
- } else {
- trigger_error("log4php: Given configurator object [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
- return new Configuration\DefaultConfigurator();
- }
- }
-
- if (is_string($configurator)) {
- if (!class_exists($configurator)) {
- trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
- return new Configuration\DefaultConfigurator();
- }
-
- $instance = new $configurator();
-
- if (!($instance instanceof Configurator)) {
- trigger_error("log4php: Specified configurator class [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
- return new Configuration\DefaultConfigurator();
- }
-
- return $instance;
- }
-
- trigger_error("log4php: Invalid configurator specified. Expected either a string or a Configurator instance. Reverting to default configurator.", E_USER_WARNING);
- return new Configuration\DefaultConfigurator();
- }
-
- /**
- * Returns true if the log4php framework has been initialized.
- * @return boolean
- */
- private static function isInitialized() {
- return self::$initialized;
- }
+class Logger
+{
+ /**
+ * Logger additivity. If set to true then child loggers will inherit
+ * the appenders of their ancestors by default.
+ * @var boolean
+ */
+ private $additive = true;
+
+ /**
+ * The Logger's fully qualified class name.
+ * TODO: Determine if this is useful.
+ */
+ private $fqcn = 'Logger';
+
+ /** The assigned Logger level. */
+ private $level;
+
+ /** The name of this Logger instance. */
+ private $name;
+
+ /** The parent logger. Set to null if this is the root logger. */
+ private $parent;
+
+ /** A collection of appenders linked to this logger. */
+ private $appenders = array();
+
+ /**
+ * Constructor.
+ * @param string $name Name of the logger.
+ */
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Returns the logger name.
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Returns the parent Logger. Can be null if this is the root logger.
+ * @return Logger
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ // ******************************************
+ // *** Logging methods ***
+ // ******************************************
+
+ /**
+ * Log a message object with the TRACE level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function trace($message, $throwable = null)
+ {
+ $this->log(Level::getLevelTrace(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the DEBUG level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function debug($message, $throwable = null)
+ {
+ $this->log(Level::getLevelDebug(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the INFO Level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function info($message, $throwable = null)
+ {
+ $this->log(Level::getLevelInfo(), $message, $throwable);
+ }
+
+ /**
+ * Log a message with the WARN level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function warn($message, $throwable = null)
+ {
+ $this->log(Level::getLevelWarn(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the ERROR level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function error($message, $throwable = null)
+ {
+ $this->log(Level::getLevelError(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the FATAL level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function fatal($message, $throwable = null)
+ {
+ $this->log(Level::getLevelFatal(), $message, $throwable);
+ }
+
+ /**
+ * Log a message using the provided logging level.
+ *
+ * @param Level $level The logging level.
+ * @param mixed $message Message to log.
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function log(Level $level, $message, $throwable = null)
+ {
+ if ($this->isEnabledFor($level)) {
+ $event = new LoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
+ $this->callAppenders($event);
+ }
+
+ // Forward the event upstream if additivity is turned on
+ if (isset($this->parent) && $this->getAdditivity()) {
+
+ // Use the event if already created
+ if (isset($event)) {
+ $this->parent->logEvent($event);
+ } else {
+ $this->parent->log($level, $message, $throwable);
+ }
+ }
+ }
+
+ /**
+ * Logs an already prepared logging event object.
+ * @param LoggingEvent $event
+ */
+ public function logEvent(LoggingEvent $event)
+ {
+ if ($this->isEnabledFor($event->getLevel())) {
+ $this->callAppenders($event);
+ }
+
+ // Forward the event upstream if additivity is turned on
+ if (isset($this->parent) && $this->getAdditivity()) {
+ $this->parent->logEvent($event);
+ }
+ }
+
+ /**
+ * If assertion parameter evaluates as false, then logs the message
+ * using the ERROR level.
+ *
+ * @param bool $assertion
+ * @param string $msg message to log
+ */
+ public function assertLog($assertion = true, $msg = '')
+ {
+ if ($assertion == false) {
+ $this->error($msg);
+ }
+ }
+
+ /**
+ * This method creates a new logging event and logs the event without
+ * further checks.
+ *
+ * It should not be called directly. Use {@link trace()}, {@link debug()},
+ * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
+ * wrappers.
+ *
+ * @param string $fqcn Fully qualified class name of the Logger
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ * @param Level $level log level
+ * @param mixed $message message to log
+ */
+ public function forcedLog($fqcn, $throwable, Level $level, $message)
+ {
+ $event = new LoggingEvent($fqcn, $this, $level, $message, null, $throwable);
+ $this->callAppenders($event);
+
+ // Forward the event upstream if additivity is turned on
+ if (isset($this->parent) && $this->getAdditivity()) {
+ $this->parent->logEvent($event);
+ }
+ }
+
+ /**
+ * Forwards the given logging event to all linked appenders.
+ * @param LoggingEvent $event
+ */
+ public function callAppenders($event)
+ {
+ foreach ($this->appenders as $appender) {
+ $appender->doAppend($event);
+ }
+ }
+
+ // ******************************************
+ // *** Checker methods ***
+ // ******************************************
+
+ /**
+ * Check whether this Logger is enabled for a given Level passed as parameter.
+ *
+ * @param Level level
+ * @return boolean
+ */
+ public function isEnabledFor(Level $level)
+ {
+ return $level->isGreaterOrEqual($this->getEffectiveLevel());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the TRACE Level.
+ * @return boolean
+ */
+ public function isTraceEnabled()
+ {
+ return $this->isEnabledFor(Level::getLevelTrace());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the DEBUG Level.
+ * @return boolean
+ */
+ public function isDebugEnabled()
+ {
+ return $this->isEnabledFor(Level::getLevelDebug());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the INFO Level.
+ * @return boolean
+ */
+ public function isInfoEnabled()
+ {
+ return $this->isEnabledFor(Level::getLevelInfo());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the WARN Level.
+ * @return boolean
+ */
+ public function isWarnEnabled()
+ {
+ return $this->isEnabledFor(Level::getLevelWarn());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the ERROR Level.
+ * @return boolean
+ */
+ public function isErrorEnabled()
+ {
+ return $this->isEnabledFor(Level::getLevelError());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the FATAL Level.
+ * @return boolean
+ */
+ public function isFatalEnabled()
+ {
+ return $this->isEnabledFor(Level::getLevelFatal());
+ }
+
+ // ******************************************
+ // *** Configuration methods ***
+ // ******************************************
+
+ /**
+ * Adds a new appender to the Logger.
+ * @param Appender $appender The appender to add.
+ */
+ public function addAppender($appender)
+ {
+ $appenderName = $appender->getName();
+ $this->appenders[$appenderName] = $appender;
+ }
+
+ /** Removes all appenders from the Logger. */
+ public function removeAllAppenders()
+ {
+ foreach ($this->appenders as $name => $appender) {
+ $this->removeAppender($name);
+ }
+ }
+
+ /**
+ * Remove the appender passed as parameter form the Logger.
+ * @param mixed $appender an appender name or a {@link Appender} instance.
+ */
+ public function removeAppender($appender)
+ {
+ if ($appender instanceof Appender) {
+ $appender->close();
+ unset($this->appenders[$appender->getName()]);
+ } elseif (is_string($appender) and isset($this->appenders[$appender])) {
+ $this->appenders[$appender]->close();
+ unset($this->appenders[$appender]);
+ }
+ }
+
+ /**
+ * Returns the appenders linked to this logger as an array.
+ * @return array collection of appender names
+ */
+ public function getAllAppenders()
+ {
+ return $this->appenders;
+ }
+
+ /**
+ * Returns a linked appender by name.
+ * @return Appender
+ */
+ public function getAppender($name)
+ {
+ return $this->appenders[$name];
+ }
+
+ /**
+ * Sets the additivity flag.
+ * @param boolean $additive
+ */
+ public function setAdditivity($additive)
+ {
+ $this->additive = (bool) $additive;
+ }
+
+ /**
+ * Returns the additivity flag.
+ * @return boolean
+ */
+ public function getAdditivity()
+ {
+ return $this->additive;
+ }
+
+ /**
+ * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
+ * @see Level
+ * @return Level or null
+ */
+ public function getEffectiveLevel()
+ {
+ for ($logger = $this; $logger !== null; $logger = $logger->getParent()) {
+ if ($logger->getLevel() !== null) {
+ return $logger->getLevel();
+ }
+ }
+ }
+
+ /**
+ * Get the assigned Logger level.
+ * @return Level The assigned level or null if none is assigned.
+ */
+ public function getLevel()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Set the Logger level.
+ *
+ * Use Level::getLevelXXX() methods to get a Level object, e.g.
+ * <code>$logger->setLevel(Level::getLevelInfo());</code>
+ *
+ * @param Level $level The level to set, or NULL to clear the logger level.
+ */
+ public function setLevel(Level $level = null)
+ {
+ $this->level = $level;
+ }
+
+ /**
+ * Checks whether an appender is attached to this logger instance.
+ *
+ * @param Appender $appender
+ * @return boolean
+ */
+ public function isAttached(Appender $appender)
+ {
+ return isset($this->appenders[$appender->getName()]);
+ }
+
+ /**
+ * Sets the parent logger.
+ * @param Logger $logger
+ */
+ public function setParent(Logger $logger)
+ {
+ $this->parent = $logger;
+ }
+
+ // ******************************************
+ // *** Static methods and properties ***
+ // ******************************************
+
+ /** The logger hierarchy used by log4php. */
+ private static $hierarchy;
+
+ /** Inidicates if log4php has been initialized */
+ private static $initialized = false;
+
+ /**
+ * Returns the hierarchy used by this Logger.
+ *
+ * Caution: do not use this hierarchy unless you have called initialize().
+ * To get Loggers, use the Logger::getLogger and Logger::getRootLogger
+ * methods instead of operating on on the hierarchy directly.
+ *
+ * @return Hierarchy
+ */
+ public static function getHierarchy()
+ {
+ if (!isset(self::$hierarchy)) {
+ self::$hierarchy = new Hierarchy(new RootLogger());
+ }
+
+ return self::$hierarchy;
+ }
+
+ /**
+ * Returns a Logger by name. If it does not exist, it will be created.
+ *
+ * @param string $name The logger name
+ * @return Logger
+ */
+ public static function getLogger($name)
+ {
+ if (!self::isInitialized()) {
+ self::configure();
+ }
+
+ return self::getHierarchy()->getLogger($name);
+ }
+
+ /**
+ * Returns the Root Logger.
+ * @return RootLogger
+ */
+ public static function getRootLogger()
+ {
+ if (!self::isInitialized()) {
+ self::configure();
+ }
+
+ return self::getHierarchy()->getRootLogger();
+ }
+
+ /**
+ * Clears all Logger definitions from the logger hierarchy.
+ * @return boolean
+ */
+ public static function clear()
+ {
+ return self::getHierarchy()->clear();
+ }
+
+ /**
+ * Destroy configurations for logger definitions
+ */
+ public static function resetConfiguration()
+ {
+ self::getHierarchy()->resetConfiguration();
+ self::getHierarchy()->clear(); // TODO: clear or not?
+ self::$initialized = false;
+ }
+
+ /**
+ * Safely close all appenders.
+ * @deprecated This is no longer necessary due the appenders shutdown via
+ * destructors.
+ */
+ public static function shutdown()
+ {
+ return self::getHierarchy()->shutdown();
+ }
+
+ /**
+ * check if a given logger exists.
+ *
+ * @param string $name logger name
+ * @return boolean
+ */
+ public static function exists($name)
+ {
+ return self::getHierarchy()->exists($name);
+ }
+
+ /**
+ * Returns an array this whole Logger instances.
+ * @see Logger
+ * @return array
+ */
+ public static function getCurrentLoggers()
+ {
+ return self::getHierarchy()->getCurrentLoggers();
+ }
+
+ /**
+ * Configures log4php.
+ *
+ * This method needs to be called before the first logging event has
+ * occured. If this method is not called before then the default
+ * configuration will be used.
+ *
+ * @param string|array $configuration Either a path to the configuration
+ * file, or a configuration array.
+ *
+ * @param string|Configurator $configurator A custom
+ * configurator class: either a class name (string) , or an object which
+ * implements the Configurator interface. If left empty, the default
+ * configurator implementation will be used.
+ */
+ public static function configure($configuration = null, $configurator = null)
+ {
+ self::resetConfiguration();
+ $configurator = self::getConfigurator($configurator);
+ $configurator->configure(self::getHierarchy(), $configuration);
+ self::$initialized = true;
+ }
+
+ /**
+ * Creates a logger configurator instance based on the provided
+ * configurator class. If no class is given, returns an instance of
+ * the default configurator.
+ *
+ * @param string|Configurator $configurator The configurator class
+ * or Configurator instance.
+ */
+ private static function getConfigurator($configurator = null)
+ {
+ if ($configurator === null) {
+ return new Configuration\DefaultConfigurator();
+ }
+
+ if (is_object($configurator)) {
+ if ($configurator instanceof Configurator) {
+ return $configurator;
+ } else {
+ trigger_error("log4php: Given configurator object [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
+
+ return new Configuration\DefaultConfigurator();
+ }
+ }
+
+ if (is_string($configurator)) {
+ if (!class_exists($configurator)) {
+ trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
+
+ return new Configuration\DefaultConfigurator();
+ }
+
+ $instance = new $configurator();
+
+ if (!($instance instanceof Configurator)) {
+ trigger_error("log4php: Specified configurator class [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
+
+ return new Configuration\DefaultConfigurator();
+ }
+
+ return $instance;
+ }
+
+ trigger_error("log4php: Invalid configurator specified. Expected either a string or a Configurator instance. Reverting to default configurator.", E_USER_WARNING);
+
+ return new Configuration\DefaultConfigurator();
+ }
+
+ /**
+ * Returns true if the log4php framework has been initialized.
+ * @return boolean
+ */
+ private static function isInitialized()
+ {
+ return self::$initialized;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/LoggerException.php
----------------------------------------------------------------------
diff --git a/src/LoggerException.php b/src/LoggerException.php
index 103c532..3641e90 100644
--- a/src/LoggerException.php
+++ b/src/LoggerException.php
@@ -21,5 +21,6 @@ namespace Apache\Log4php;
/**
* LoggerException class
*/
-class LoggerException extends \Exception {
+class LoggerException extends \Exception
+{
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/LoggingEvent.php
----------------------------------------------------------------------
diff --git a/src/LoggingEvent.php b/src/LoggingEvent.php
index f0fd7e3..0167c6a 100644
--- a/src/LoggingEvent.php
+++ b/src/LoggingEvent.php
@@ -21,345 +21,370 @@ namespace Apache\Log4php;
/**
* The internal representation of logging event.
*/
-class LoggingEvent {
-
- private static $startTime;
-
- /**
- * @var string Fully Qualified Class Name of the calling category class.
- */
- private $fqcn;
-
- /**
- * @var Logger reference
- */
- private $logger;
-
- /**
- * The category (logger) name.
- * This field will be marked as private in future
- * releases. Please do not access it directly.
- * Use the {@link getLoggerName()} method instead.
- * @deprecated
- */
- private $categoryName;
-
- /**
- * Level of the logging event.
- * @var Level
- */
- protected $level;
-
- /**
- * The nested diagnostic context (NDC) of logging event.
- * @var string
- */
- private $ndc;
-
- /**
- * Have we tried to do an NDC lookup? If we did, there is no need
- * to do it again. Note that its value is always false when
- * serialized. Thus, a receiving SocketNode will never use it's own
- * (incorrect) NDC. See also writeObject method.
- * @var boolean
- */
- private $ndcLookupRequired = true;
-
- /**
- * @var mixed The application supplied message of logging event.
- */
- private $message;
-
- /**
- * The application supplied message rendered through the log4php
- * objet rendering mechanism. At present renderedMessage == message.
- * @var string
- */
- private $renderedMessage;
-
- /**
- * The name of thread in which this logging event was generated.
- * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
- * @var mixed
- */
- private $threadName;
-
- /**
- * The number of seconds elapsed from 1/1/1970 until logging event
- * was created plus microseconds if available.
- * @var float
- */
- public $timeStamp;
-
- /**
- * @var LocationInfo Location information for the caller.
- */
- private $locationInfo;
-
- /**
- * @var ThrowableInformation log4php internal representation of throwable
- */
- private $throwableInfo;
-
- /**
- * Instantiate a LoggingEvent from the supplied parameters.
- *
- * Except {@link $timeStamp} all the other fields of
- * LoggingEvent are filled when actually needed.
- *
- * @param string $fqcn name of the caller class.
- * @param mixed $logger The {@link Logger} category of this event or the logger name.
- * @param Level $level The level of this event.
- * @param mixed $message The message of this event.
- * @param integer $timeStamp the timestamp of this logging event.
- * @param Exception $throwable The throwable associated with logging event
- */
- public function __construct($fqcn, $logger, Level $level, $message, $timeStamp = null, $throwable = null) {
- $this->fqcn = $fqcn;
- if($logger instanceof Logger) {
- $this->logger = $logger;
- $this->categoryName = $logger->getName();
- } else {
- $this->categoryName = strval($logger);
- }
- $this->level = $level;
- $this->message = $message;
- if($timeStamp !== null && is_numeric($timeStamp)) {
- $this->timeStamp = $timeStamp;
- } else {
- $this->timeStamp = microtime(true);
- }
-
- if (isset($throwable) && $throwable instanceof \Exception) {
- $this->throwableInfo = new ThrowableInformation($throwable);
- }
- }
-
- /**
- * Returns the full qualified classname.
- * TODO: PHP does contain namespaces in 5.3. Those should be returned too,
- */
- public function getFullQualifiedClassname() {
- return $this->fqcn;
- }
-
- /**
- * Set the location information for this logging event. The collected
- * information is cached for future use.
- *
- * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
- * to collect informations about caller.</p>
- * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
- * @return LocationInfo
- */
- public function getLocationInformation() {
- if($this->locationInfo === null) {
-
- $locationInfo = array();
- $trace = debug_backtrace();
- $prevHop = null;
-
- // make a downsearch to identify the caller
- $hop = array_pop($trace);
- while($hop !== null) {
- if(isset($hop['class'])) {
- $className = $hop['class'];
-
- if($className === "Apache\\Log4php\\Logger" ||
- $className === "Apache\\Log4php\\RootLogger") {
- $locationInfo['line'] = $hop['line'];
- $locationInfo['file'] = $hop['file'];
- break;
- }
- }
- $prevHop = $hop;
- $hop = array_pop($trace);
- }
- $locationInfo['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') {
-
- $locationInfo['function'] = $prevHop['function'];
- } else {
- $locationInfo['function'] = 'main';
- }
-
- $this->locationInfo = new LocationInfo($locationInfo, $this->fqcn);
- }
- return $this->locationInfo;
- }
-
- /**
- * Return the level of this event. Use this form instead of directly
- * accessing the {@link $level} field.
- * @return Level
- */
- public function getLevel() {
- return $this->level;
- }
-
- /**
- * Returns the logger which created the event.
- * @return Logger
- */
- public function getLogger() {
- return $this->logger;
- }
-
- /**
- * Return the name of the logger. Use this form instead of directly
- * accessing the {@link $categoryName} field.
- * @return string
- */
- public function getLoggerName() {
- return $this->categoryName;
- }
-
- /**
- * Return the message for this logging event.
- * @return mixed
- */
- public function getMessage() {
- return $this->message;
- }
-
- /**
- * This method returns the NDC for this event. It will return the
- * correct content even if the event was generated in a different
- * thread or even on a different machine. The {@link NDC::get()} method
- * should <b>never</b> be called directly.
- * @return string
- */
- public function getNDC() {
- if($this->ndcLookupRequired) {
- $this->ndcLookupRequired = false;
- $this->ndc = NDC::get();
- }
- return $this->ndc;
- }
-
- /**
- * Returns the the context corresponding to the <code>key</code>
- * parameter.
- * @return string
- */
- public function getMDC($key) {
- return MDC::get($key);
- }
-
- /**
- * Returns the entire MDC context.
- * @return array
- */
- public function getMDCMap () {
- return MDC::getMap();
- }
-
- /**
- * Render message.
- * @return string
- */
- public function getRenderedMessage() {
- if($this->renderedMessage === null and $this->message !== null) {
- if(is_string($this->message)) {
- $this->renderedMessage = $this->message;
- } else {
- $rendererMap = Logger::getHierarchy()->getRendererMap();
- $this->renderedMessage= $rendererMap->findAndRender($this->message);
- }
- }
- return $this->renderedMessage;
- }
-
- /**
- * Returns the time when the application started, as a UNIX timestamp
- * with microseconds.
- * @return float
- */
- public static function getStartTime() {
- if(!isset(self::$startTime)) {
- self::$startTime = microtime(true);
- }
- return self::$startTime;
- }
-
- /**
- * @return float
- */
- public function getTimeStamp() {
- return $this->timeStamp;
- }
-
- /**
- * Returns the time in seconds passed from the beginning of execution to
- * the time the event was constructed.
- *
- * @return float Seconds with microseconds in decimals.
- */
- public function getRelativeTime() {
- return $this->timeStamp - self::$startTime;
- }
-
- /**
- * Returns the time in milliseconds passed from the beginning of execution
- * to the time the event was constructed.
- *
- * @deprecated This method has been replaced by getRelativeTime which
- * does not perform unneccesary multiplication and formatting.
- *
- * @return integer
- */
- public function getTime() {
- $eventTime = $this->getTimeStamp();
- $eventStartTime = LoggingEvent::getStartTime();
- return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
- }
-
- /**
- * @return mixed
- */
- public function getThreadName() {
- if ($this->threadName === null) {
- $this->threadName = (string)getmypid();
- }
- return $this->threadName;
- }
-
- /**
- * @return mixed ThrowableInformation
- */
- public function getThrowableInformation() {
- return $this->throwableInfo;
- }
-
- /**
- * Serialize this object
- * @return string
- */
- public function toString() {
- serialize($this);
- }
-
- /**
- * Avoid serialization of the {@link $logger} object
- */
- public function __sleep() {
- return array(
- 'fqcn',
- 'categoryName',
- 'level',
- 'ndc',
- 'ndcLookupRequired',
- 'message',
- 'renderedMessage',
- 'threadName',
- 'timeStamp',
- 'locationInfo',
- );
- }
+class LoggingEvent
+{
+ private static $startTime;
+
+ /**
+ * @var string Fully Qualified Class Name of the calling category class.
+ */
+ private $fqcn;
+
+ /**
+ * @var Logger reference
+ */
+ private $logger;
+
+ /**
+ * The category (logger) name.
+ * This field will be marked as private in future
+ * releases. Please do not access it directly.
+ * Use the {@link getLoggerName()} method instead.
+ * @deprecated
+ */
+ private $categoryName;
+
+ /**
+ * Level of the logging event.
+ * @var Level
+ */
+ protected $level;
+
+ /**
+ * The nested diagnostic context (NDC) of logging event.
+ * @var string
+ */
+ private $ndc;
+
+ /**
+ * Have we tried to do an NDC lookup? If we did, there is no need
+ * to do it again. Note that its value is always false when
+ * serialized. Thus, a receiving SocketNode will never use it's own
+ * (incorrect) NDC. See also writeObject method.
+ * @var boolean
+ */
+ private $ndcLookupRequired = true;
+
+ /**
+ * @var mixed The application supplied message of logging event.
+ */
+ private $message;
+
+ /**
+ * The application supplied message rendered through the log4php
+ * objet rendering mechanism. At present renderedMessage == message.
+ * @var string
+ */
+ private $renderedMessage;
+
+ /**
+ * The name of thread in which this logging event was generated.
+ * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
+ * @var mixed
+ */
+ private $threadName;
+
+ /**
+ * The number of seconds elapsed from 1/1/1970 until logging event
+ * was created plus microseconds if available.
+ * @var float
+ */
+ public $timeStamp;
+
+ /**
+ * @var LocationInfo Location information for the caller.
+ */
+ private $locationInfo;
+
+ /**
+ * @var ThrowableInformation log4php internal representation of throwable
+ */
+ private $throwableInfo;
+
+ /**
+ * Instantiate a LoggingEvent from the supplied parameters.
+ *
+ * Except {@link $timeStamp} all the other fields of
+ * LoggingEvent are filled when actually needed.
+ *
+ * @param string $fqcn name of the caller class.
+ * @param mixed $logger The {@link Logger} category of this event or the logger name.
+ * @param Level $level The level of this event.
+ * @param mixed $message The message of this event.
+ * @param integer $timeStamp the timestamp of this logging event.
+ * @param Exception $throwable The throwable associated with logging event
+ */
+ public function __construct($fqcn, $logger, Level $level, $message, $timeStamp = null, $throwable = null)
+ {
+ $this->fqcn = $fqcn;
+ if ($logger instanceof Logger) {
+ $this->logger = $logger;
+ $this->categoryName = $logger->getName();
+ } else {
+ $this->categoryName = strval($logger);
+ }
+ $this->level = $level;
+ $this->message = $message;
+ if ($timeStamp !== null && is_numeric($timeStamp)) {
+ $this->timeStamp = $timeStamp;
+ } else {
+ $this->timeStamp = microtime(true);
+ }
+
+ if (isset($throwable) && $throwable instanceof \Exception) {
+ $this->throwableInfo = new ThrowableInformation($throwable);
+ }
+ }
+
+ /**
+ * Returns the full qualified classname.
+ * TODO: PHP does contain namespaces in 5.3. Those should be returned too,
+ */
+ public function getFullQualifiedClassname()
+ {
+ return $this->fqcn;
+ }
+
+ /**
+ * Set the location information for this logging event. The collected
+ * information is cached for future use.
+ *
+ * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
+ * to collect informations about caller.</p>
+ * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
+ * @return LocationInfo
+ */
+ public function getLocationInformation()
+ {
+ if ($this->locationInfo === null) {
+
+ $locationInfo = array();
+ $trace = debug_backtrace();
+ $prevHop = null;
+
+ // make a downsearch to identify the caller
+ $hop = array_pop($trace);
+ while ($hop !== null) {
+ if (isset($hop['class'])) {
+ $className = $hop['class'];
+
+ if ($className === "Apache\\Log4php\\Logger" ||
+ $className === "Apache\\Log4php\\RootLogger") {
+ $locationInfo['line'] = $hop['line'];
+ $locationInfo['file'] = $hop['file'];
+ break;
+ }
+ }
+ $prevHop = $hop;
+ $hop = array_pop($trace);
+ }
+ $locationInfo['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') {
+
+ $locationInfo['function'] = $prevHop['function'];
+ } else {
+ $locationInfo['function'] = 'main';
+ }
+
+ $this->locationInfo = new LocationInfo($locationInfo, $this->fqcn);
+ }
+
+ return $this->locationInfo;
+ }
+
+ /**
+ * Return the level of this event. Use this form instead of directly
+ * accessing the {@link $level} field.
+ * @return Level
+ */
+ public function getLevel()
+ {
+ return $this->level;
+ }
+
+ /**
+ * Returns the logger which created the event.
+ * @return Logger
+ */
+ public function getLogger()
+ {
+ return $this->logger;
+ }
+
+ /**
+ * Return the name of the logger. Use this form instead of directly
+ * accessing the {@link $categoryName} field.
+ * @return string
+ */
+ public function getLoggerName()
+ {
+ return $this->categoryName;
+ }
+
+ /**
+ * Return the message for this logging event.
+ * @return mixed
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * This method returns the NDC for this event. It will return the
+ * correct content even if the event was generated in a different
+ * thread or even on a different machine. The {@link NDC::get()} method
+ * should <b>never</b> be called directly.
+ * @return string
+ */
+ public function getNDC()
+ {
+ if ($this->ndcLookupRequired) {
+ $this->ndcLookupRequired = false;
+ $this->ndc = NDC::get();
+ }
+
+ return $this->ndc;
+ }
+
+ /**
+ * Returns the the context corresponding to the <code>key</code>
+ * parameter.
+ * @return string
+ */
+ public function getMDC($key)
+ {
+ return MDC::get($key);
+ }
+
+ /**
+ * Returns the entire MDC context.
+ * @return array
+ */
+ public function getMDCMap()
+ {
+ return MDC::getMap();
+ }
+
+ /**
+ * Render message.
+ * @return string
+ */
+ public function getRenderedMessage()
+ {
+ if ($this->renderedMessage === null and $this->message !== null) {
+ if (is_string($this->message)) {
+ $this->renderedMessage = $this->message;
+ } else {
+ $rendererMap = Logger::getHierarchy()->getRendererMap();
+ $this->renderedMessage= $rendererMap->findAndRender($this->message);
+ }
+ }
+
+ return $this->renderedMessage;
+ }
+
+ /**
+ * Returns the time when the application started, as a UNIX timestamp
+ * with microseconds.
+ * @return float
+ */
+ public static function getStartTime()
+ {
+ if (!isset(self::$startTime)) {
+ self::$startTime = microtime(true);
+ }
+
+ return self::$startTime;
+ }
+
+ /**
+ * @return float
+ */
+ public function getTimeStamp()
+ {
+ return $this->timeStamp;
+ }
+
+ /**
+ * Returns the time in seconds passed from the beginning of execution to
+ * the time the event was constructed.
+ *
+ * @return float Seconds with microseconds in decimals.
+ */
+ public function getRelativeTime()
+ {
+ return $this->timeStamp - self::$startTime;
+ }
+
+ /**
+ * Returns the time in milliseconds passed from the beginning of execution
+ * to the time the event was constructed.
+ *
+ * @deprecated This method has been replaced by getRelativeTime which
+ * does not perform unneccesary multiplication and formatting.
+ *
+ * @return integer
+ */
+ public function getTime()
+ {
+ $eventTime = $this->getTimeStamp();
+ $eventStartTime = LoggingEvent::getStartTime();
+
+ return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getThreadName()
+ {
+ if ($this->threadName === null) {
+ $this->threadName = (string) getmypid();
+ }
+
+ return $this->threadName;
+ }
+
+ /**
+ * @return mixed ThrowableInformation
+ */
+ public function getThrowableInformation()
+ {
+ return $this->throwableInfo;
+ }
+
+ /**
+ * Serialize this object
+ * @return string
+ */
+ public function toString()
+ {
+ serialize($this);
+ }
+
+ /**
+ * Avoid serialization of the {@link $logger} object
+ */
+ public function __sleep()
+ {
+ return array(
+ 'fqcn',
+ 'categoryName',
+ 'level',
+ 'ndc',
+ 'ndcLookupRequired',
+ 'message',
+ 'renderedMessage',
+ 'threadName',
+ 'timeStamp',
+ 'locationInfo',
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/MDC.php
----------------------------------------------------------------------
diff --git a/src/MDC.php b/src/MDC.php
index 9f911c6..6e7f008 100644
--- a/src/MDC.php
+++ b/src/MDC.php
@@ -32,56 +32,61 @@ namespace Apache\Log4php;
* @since 0.3
*
*/
-class MDC {
+class MDC
+{
+ /** Holds the context map. */
+ private static $map = array();
- /** Holds the context map. */
- private static $map = array();
+ /**
+ * Stores a context value as identified with the key parameter into the
+ * context map.
+ *
+ * @param string $key the key
+ * @param string $value the value
+ */
+ public static function put($key, $value)
+ {
+ self::$map[$key] = $value;
+ }
- /**
- * Stores a context value as identified with the key parameter into the
- * context map.
- *
- * @param string $key the key
- * @param string $value the value
- */
- public static function put($key, $value) {
- self::$map[$key] = $value;
- }
+ /**
+ * Returns the context value identified by the key parameter.
+ *
+ * @param string $key The key.
+ * @return string The context or an empty string if no context found
+ * for given key.
+ */
+ public static function get($key)
+ {
+ return isset(self::$map[$key]) ? self::$map[$key] : '';
+ }
- /**
- * Returns the context value identified by the key parameter.
- *
- * @param string $key The key.
- * @return string The context or an empty string if no context found
- * for given key.
- */
- public static function get($key) {
- return isset(self::$map[$key]) ? self::$map[$key] : '';
- }
+ /**
+ * Returns the contex map as an array.
+ * @return array The MDC context map.
+ */
+ public static function getMap()
+ {
+ return self::$map;
+ }
- /**
- * Returns the contex map as an array.
- * @return array The MDC context map.
- */
- public static function getMap() {
- return self::$map;
- }
+ /**
+ * Removes the the context identified by the key parameter.
+ *
+ * Only affects user mappings, not $_ENV or $_SERVER.
+ *
+ * @param string $key The key to be removed.
+ */
+ public static function remove($key)
+ {
+ unset(self::$map[$key]);
+ }
- /**
- * Removes the the context identified by the key parameter.
- *
- * Only affects user mappings, not $_ENV or $_SERVER.
- *
- * @param string $key The key to be removed.
- */
- public static function remove($key) {
- unset(self::$map[$key]);
- }
-
- /**
- * Clears the mapped diagnostic context.
- */
- public static function clear() {
- self::$map = array();
- }
+ /**
+ * Clears the mapped diagnostic context.
+ */
+ public static function clear()
+ {
+ self::$map = array();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/NDC.php
----------------------------------------------------------------------
diff --git a/src/NDC.php b/src/NDC.php
index b3de74a..c81c233 100644
--- a/src/NDC.php
+++ b/src/NDC.php
@@ -74,111 +74,119 @@ namespace Apache\Log4php;
*
* @since 0.3
*/
-class NDC {
+class NDC
+{
+ /** This is the repository of NDC stack */
+ private static $stack = array();
- /** This is the repository of NDC stack */
- private static $stack = array();
+ /**
+ * Clear any nested diagnostic information if any. This method is
+ * useful in cases where the same thread can be potentially used
+ * over and over in different unrelated contexts.
+ *
+ * <p>This method is equivalent to calling the {@link setMaxDepth()}
+ * method with a zero <var>maxDepth</var> argument.
+ */
+ public static function clear()
+ {
+ self::$stack = array();
+ }
- /**
- * Clear any nested diagnostic information if any. This method is
- * useful in cases where the same thread can be potentially used
- * over and over in different unrelated contexts.
- *
- * <p>This method is equivalent to calling the {@link setMaxDepth()}
- * method with a zero <var>maxDepth</var> argument.
- */
- public static function clear() {
- self::$stack = array();
- }
+ /**
+ * Never use this method directly, use the {@link LoggingEvent::getNDC()} method instead.
+ * @return array
+ */
+ public static function get()
+ {
+ return implode(' ', self::$stack);
+ }
- /**
- * Never use this method directly, use the {@link LoggingEvent::getNDC()} method instead.
- * @return array
- */
- public static function get() {
- return implode(' ', self::$stack);
- }
+ /**
+ * Get the current nesting depth of this diagnostic context.
+ *
+ * @see setMaxDepth()
+ * @return integer
+ */
+ public static function getDepth()
+ {
+ return count(self::$stack);
+ }
- /**
- * Get the current nesting depth of this diagnostic context.
- *
- * @see setMaxDepth()
- * @return integer
- */
- public static function getDepth() {
- return count(self::$stack);
- }
+ /**
+ * Clients should call this method before leaving a diagnostic
+ * context.
+ *
+ * <p>The returned value is the value that was pushed last. If no
+ * context is available, then the empty string "" is returned.</p>
+ *
+ * @return string The innermost diagnostic context.
+ */
+ public static function pop()
+ {
+ if (count(self::$stack) > 0) {
+ return array_pop(self::$stack);
+ } else {
+ return '';
+ }
+ }
- /**
- * Clients should call this method before leaving a diagnostic
- * context.
- *
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.</p>
- *
- * @return string The innermost diagnostic context.
- */
- public static function pop() {
- if(count(self::$stack) > 0) {
- return array_pop(self::$stack);
- } else {
- return '';
- }
- }
+ /**
+ * Looks at the last diagnostic context at the top of this NDC
+ * without removing it.
+ *
+ * <p>The returned value is the value that was pushed last. If no
+ * context is available, then the empty string "" is returned.</p>
+ * @return string The innermost diagnostic context.
+ */
+ public static function peek()
+ {
+ if (count(self::$stack) > 0) {
+ return end(self::$stack);
+ } else {
+ return '';
+ }
+ }
- /**
- * Looks at the last diagnostic context at the top of this NDC
- * without removing it.
- *
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.</p>
- * @return string The innermost diagnostic context.
- */
- public static function peek() {
- if(count(self::$stack) > 0) {
- return end(self::$stack);
- } else {
- return '';
- }
- }
+ /**
+ * Push new diagnostic context information for the current thread.
+ *
+ * <p>The contents of the <var>message</var> parameter is
+ * determined solely by the client.
+ *
+ * @param string $message The new diagnostic context information.
+ */
+ public static function push($message)
+ {
+ array_push(self::$stack, (string) $message);
+ }
- /**
- * Push new diagnostic context information for the current thread.
- *
- * <p>The contents of the <var>message</var> parameter is
- * determined solely by the client.
- *
- * @param string $message The new diagnostic context information.
- */
- public static function push($message) {
- array_push(self::$stack, (string)$message);
- }
+ /**
+ * Remove the diagnostic context for this thread.
+ */
+ public static function remove()
+ {
+ NDC::clear();
+ }
- /**
- * Remove the diagnostic context for this thread.
- */
- public static function remove() {
- NDC::clear();
- }
-
- /**
- * 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()
- */
- public static function setMaxDepth($maxDepth) {
- $maxDepth = (int)$maxDepth;
- if(NDC::getDepth() > $maxDepth) {
- self::$stack = array_slice(self::$stack, 0, $maxDepth);
- }
- }
+ /**
+ * 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()
+ */
+ public static function setMaxDepth($maxDepth)
+ {
+ $maxDepth = (int) $maxDepth;
+ if (NDC::getDepth() > $maxDepth) {
+ self::$stack = array_slice(self::$stack, 0, $maxDepth);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/AbstractConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/AbstractConverter.php b/src/Pattern/AbstractConverter.php
index dc13f4b..57c6dfc 100644
--- a/src/Pattern/AbstractConverter.php
+++ b/src/Pattern/AbstractConverter.php
@@ -30,101 +30,105 @@ use Apache\Log4php\LoggingEvent;
* converting a logging event in a converter specific manner.</p>
* @since 0.3
*/
-abstract class AbstractConverter {
-
- /**
- * Next converter in the converter chain.
- * @var AbstractConverter
- */
- public $next = null;
-
- /**
- * Formatting information, parsed from pattern modifiers.
- * @var FormattingInfo
- */
- protected $formattingInfo;
-
- /**
- * Converter-specific formatting options.
- * @var array
- */
- protected $option;
-
- /**
- * Constructor
- * @param FormattingInfo $formattingInfo
- * @param array $option
- */
- public function __construct(FormattingInfo $formattingInfo = null, $option = null) {
- $this->formattingInfo = $formattingInfo;
- $this->option = $option;
- $this->activateOptions();
- }
-
- /**
- * Called in constructor. Converters which need to process the options
- * can override this method.
- */
- public function activateOptions() { }
-
- /**
- * Converts the logging event to the desired format. Derived pattern
- * converters must implement this method.
- *
- * @param LoggingEvent $event
- */
- abstract public function convert(LoggingEvent $event);
-
- /**
- * Converts the event and formats it according to setting in the
- * Formatting information object.
- *
- * @param string &$sbuf string buffer to write to
- * @param LoggingEvent $event Event to be formatted.
- */
- public function format(&$sbuf, $event) {
- $string = $this->convert($event);
-
- if (!isset($this->formattingInfo)) {
- $sbuf .= $string;
- return;
- }
-
- $fi = $this->formattingInfo;
-
- // Empty string
- if($string === '' || is_null($string)) {
- if($fi->min > 0) {
- $sbuf .= str_repeat(' ', $fi->min);
- }
- return;
- }
-
- $len = strlen($string);
-
- // Trim the string if needed
- if($len > $fi->max) {
- if ($fi->trimLeft) {
- $sbuf .= substr($string, $len - $fi->max, $fi->max);
- } else {
- $sbuf .= substr($string , 0, $fi->max);
- }
- }
-
- // Add padding if needed
- else if($len < $fi->min) {
- if($fi->padLeft) {
- $sbuf .= str_repeat(' ', $fi->min - $len);
- $sbuf .= $string;
- } else {
- $sbuf .= $string;
- $sbuf .= str_repeat(' ', $fi->min - $len);
- }
- }
-
- // No action needed
- else {
- $sbuf .= $string;
- }
- }
+abstract class AbstractConverter
+{
+ /**
+ * Next converter in the converter chain.
+ * @var AbstractConverter
+ */
+ public $next = null;
+
+ /**
+ * Formatting information, parsed from pattern modifiers.
+ * @var FormattingInfo
+ */
+ protected $formattingInfo;
+
+ /**
+ * Converter-specific formatting options.
+ * @var array
+ */
+ protected $option;
+
+ /**
+ * Constructor
+ * @param FormattingInfo $formattingInfo
+ * @param array $option
+ */
+ public function __construct(FormattingInfo $formattingInfo = null, $option = null)
+ {
+ $this->formattingInfo = $formattingInfo;
+ $this->option = $option;
+ $this->activateOptions();
+ }
+
+ /**
+ * Called in constructor. Converters which need to process the options
+ * can override this method.
+ */
+ public function activateOptions() { }
+
+ /**
+ * Converts the logging event to the desired format. Derived pattern
+ * converters must implement this method.
+ *
+ * @param LoggingEvent $event
+ */
+ abstract public function convert(LoggingEvent $event);
+
+ /**
+ * Converts the event and formats it according to setting in the
+ * Formatting information object.
+ *
+ * @param string &$sbuf string buffer to write to
+ * @param LoggingEvent $event Event to be formatted.
+ */
+ public function format(&$sbuf, $event)
+ {
+ $string = $this->convert($event);
+
+ if (!isset($this->formattingInfo)) {
+ $sbuf .= $string;
+
+ return;
+ }
+
+ $fi = $this->formattingInfo;
+
+ // Empty string
+ if ($string === '' || is_null($string)) {
+ if ($fi->min > 0) {
+ $sbuf .= str_repeat(' ', $fi->min);
+ }
+
+ return;
+ }
+
+ $len = strlen($string);
+
+ // Trim the string if needed
+ if ($len > $fi->max) {
+ if ($fi->trimLeft) {
+ $sbuf .= substr($string, $len - $fi->max, $fi->max);
+ } else {
+ $sbuf .= substr($string , 0, $fi->max);
+ }
+ }
+
+ // Add padding if needed
+ else if ($len < $fi->min) {
+ if ($fi->padLeft) {
+ $sbuf .= str_repeat(' ', $fi->min - $len);
+ $sbuf .= $string;
+ } else {
+ $sbuf .= $string;
+ $sbuf .= str_repeat(' ', $fi->min - $len);
+ }
+ }
+
+ // No action needed
+ else {
+ $sbuf .= $string;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/ClassConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ClassConverter.php b/src/Pattern/ClassConverter.php
index b5e658c..09b87da 100644
--- a/src/Pattern/ClassConverter.php
+++ b/src/Pattern/ClassConverter.php
@@ -26,37 +26,39 @@ use Apache\Log4php\LoggingEvent;
* request was issued.
* @since 2.3
*/
-class ClassConverter extends AbstractConverter {
+class ClassConverter extends AbstractConverter
+{
+ /** Length to which to shorten the class name. */
+ private $length;
- /** Length to which to shorten the class name. */
- private $length;
+ /** Holds processed class names. */
+ private $cache = array();
- /** Holds processed class names. */
- private $cache = array();
+ public function activateOptions()
+ {
+ // Parse the option (desired output length)
+ if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
+ $this->length = (integer) $this->option;
+ }
+ }
- public function activateOptions() {
- // Parse the option (desired output length)
- if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
- $this->length = (integer) $this->option;
- }
- }
+ public function convert(LoggingEvent $event)
+ {
+ $name = $event->getLocationInformation()->getClassName();
- public function convert(LoggingEvent $event) {
- $name = $event->getLocationInformation()->getClassName();
+ if (!isset($this->cache[$name])) {
- if (!isset($this->cache[$name])) {
+ // If length is set return shortened class name
+ if (isset($this->length)) {
+ $this->cache[$name] = Utils::shortenClassName($name, $this->length);
+ }
- // If length is set return shortened class name
- if (isset($this->length)) {
- $this->cache[$name] = Utils::shortenClassName($name, $this->length);
- }
+ // If no length is specified return the full class name
+ else {
+ $this->cache[$name] = $name;
+ }
+ }
- // If no length is specified return the full class name
- else {
- $this->cache[$name] = $name;
- }
- }
-
- return $this->cache[$name];
- }
+ return $this->cache[$name];
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/CookieConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/CookieConverter.php b/src/Pattern/CookieConverter.php
index 69b5738..245c11d 100644
--- a/src/Pattern/CookieConverter.php
+++ b/src/Pattern/CookieConverter.php
@@ -27,6 +27,7 @@ namespace Apache\Log4php\Pattern;
*
* @since 2.3
*/
-class CookieConverter extends SuperglobalConverter {
- protected $name = '_COOKIE';
-}
\ No newline at end of file
+class CookieConverter extends SuperglobalConverter
+{
+ protected $name = '_COOKIE';
+}
[10/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/site.vm
----------------------------------------------------------------------
diff --git a/src/site/site.vm b/src/site/site.vm
deleted file mode 100644
index a7cd26b..0000000
--- a/src/site/site.vm
+++ /dev/null
@@ -1,485 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!-- Generated by Apache Maven Doxia at $dateFormat.format( $currentDate ) -->
-#macro ( link $href $name $target $img $position $alt $border $width $height )
- #set ( $linkTitle = ' title="' + $name + '"' )
- #if( $target )
- #set ( $linkTarget = ' target="' + $target + '"' )
- #else
- #set ( $linkTarget = "" )
- #end
- #if ( $href.toLowerCase().startsWith("http:/") || $href.toLowerCase().startsWith("https:/") ||
- $href.toLowerCase().startsWith("ftp:/") || $href.toLowerCase().startsWith("mailto:/") ||
- $href.toLowerCase().startsWith("file:/") || ($href.toLowerCase().indexOf("://") != -1) )
- #set ( $linkClass = ' class="external" target="_blank"' )
-
- #if ( $linkTarget )
- #else
- #set ( $linkTarget = "_blank" )
- #end
-
- #else
- #set ( $linkClass = "" )
- #end
- #if ( $img )
- #if ( $position == "left" )
- <a href="$href"$linkClass$linkTarget$linkTitle>#image($img $alt $border $width $height)$name</a>
- #else
- <a href="$href"$linkClass$linkTarget$linkTitle>$name #image($img $alt $border $width $height)</a>
- #end
- #else
- <a href="$href"$linkClass$linkTarget$linkTitle>$name</a>
- #end
-#end
-##
-#macro ( image $img $alt $border $width $height )
- #if( $img )
- #if ( ! ( $img.toLowerCase().startsWith("http:/") || $img.toLowerCase().startsWith("https:/") ||
- $img.toLowerCase().startsWith("ftp:/") || $img.toLowerCase().startsWith("mailto:/") ||
- $img.toLowerCase().startsWith("file:/") || ($img.toLowerCase().indexOf("://") != -1) ) )
- #set ( $imgSrc = $PathTool.calculateLink( $img, $relativePath ) )
- #set ( $imgSrc = $imgSrc.replaceAll( '\\', '/' ) )
- #set ( $imgSrc = ' src="' + $imgSrc + '"' )
- #else
- #set ( $imgSrc = ' src="' + $img + '"' )
- #end
- #if( $alt )
- #set ( $imgAlt = ' alt="' + $alt + '"' )
- #else
- #set ( $imgAlt = ' alt=""' )
- #end
- #if( $border )
- #set ( $imgBorder = ' border="' + $border + '"' )
- #else
- #set ( $imgBorder = "" )
- #end
- #if( $width )
- #set ( $imgWidth = ' width="' + $width + '"' )
- #else
- #set ( $imgWidth = "" )
- #end
- #if( $height )
- #set ( $imgHeight = ' height="' + $height + '"' )
- #else
- #set ( $imgHeight = "" )
- #end
- <img class="imageLink"$imgSrc$imgAlt$imgBorder$imgWidth$imgHeight/>
- #end
-#end
-#macro ( banner $banner $id )
- #if ( $banner )
- #if( $banner.href )
- #set ( $hrf = $banner.href )
- #if ( ! ( $hrf.toLowerCase().startsWith("http:/") || $hrf.toLowerCase().startsWith("https:/") ||
- $hrf.toLowerCase().startsWith("ftp:/") || $hrf.toLowerCase().startsWith("mailto:/") ||
- $hrf.toLowerCase().startsWith("file:/") || ($hrf.toLowerCase().indexOf("://") != -1) ) )
- #set ( $hrf = $PathTool.calculateLink( $hrf, $relativePath ) )
- #set ( $hrf = $hrf.replaceAll( '\\', '/' ) )
- #if ( ( $hrf == '' ) )
- #set ( $hrf = './' )
- #end
- #end
- <a href="$hrf" id="$id"#if( $banner.alt ) title="$banner.alt"#end>
- #else
- <div id="$id">
- #end
-##
- #if( $banner.src )
- #set ( $src = $banner.src )
- #if ( ! ( $src.toLowerCase().startsWith("http:/") || $src.toLowerCase().startsWith("https:/") ||
- $src.toLowerCase().startsWith("ftp:/") || $src.toLowerCase().startsWith("mailto:/") ||
- $src.toLowerCase().startsWith("file:/") || ($src.toLowerCase().indexOf("://") != -1) ) )
- #set ( $src = $PathTool.calculateLink( $src, $relativePath ) )
- #set ( $src = $src.replaceAll( '\\', '/' ) )
- #end
- #if ( $banner.alt )
- #set ( $alt = $banner.alt )
- #else
- #set ( $alt = $banner.name )
- #end
- <img src="$src" alt="$alt" />
- #else
- $banner.name
- #end
-##
- #if( $banner.href )
- </a>
- #else
- </div>
- #end
- #end
-#end
-##
-#macro ( links $links )
- <ul class="nav">
- #set ( $counter = 0 )
- #foreach( $item in $links )
- #set ( $counter = $counter + 1 )
- #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $currentItemHref = $currentItemHref.replaceAll( '\\', '/' ) )
- #set ( $activeClass = "" )
- #if ( $alignedFileName == $currentItemHref)
- #set ( $activeClass = ' class="active"' )
- #end
- <li$activeClass>
- #link( $currentItemHref $item.name $item.target $item.img $item.position $item.alt $item.border $item.width $item.height )
- </li>
- #end
- </ul>
-#end
-##
-#macro ( breadcrumbs $breadcrumbs )
- #foreach( $item in $breadcrumbs )
- #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $currentItemHref = $currentItemHref.replaceAll( '\\', '/' ) )
- #if ( ( $currentItemHref == '' ) )
- #set ( $currentItemHref = './' )
- #end
-##
- #link( $currentItemHref $item.name $item.target $item.img $item.position $item.alt $item.border $item.width $item.height )
- <span class="divider">></span>
- #end
- $title
-#end
-##
-#macro ( displayTree $display $item )
- #if ( $item && $item.items && $item.items.size() > 0 )
- #foreach( $subitem in $item.items )
- #set ( $subitemHref = $PathTool.calculateLink( $subitem.href, $relativePath ) )
- #set ( $subitemHref = $subitemHref.replaceAll( '\\', '/' ) )
-##
- #if ( $alignedFileName == $subitemHref )
- #set ( $display = true )
- #end
-##
- #displayTree( $display $subitem )
- #end
- #end
-#end
-##
-#macro ( menuItem $item )
- #set ( $collapse = "none" )
- #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $currentItemHref = $currentItemHref.replaceAll( '\\', '/' ) )
-##
- #if ( $item && $item.items && $item.items.size() > 0 )
- #if ( $item.collapse == false )
- #set ( $collapse = "expanded" )
- #else
- ## By default collapsed
- #set ( $collapse = "collapsed" )
- #end
-##
- #set ( $display = false )
- #displayTree( $display $item )
-##
- #if ( $alignedFileName == $currentItemHref || $display )
- #set ( $collapse = "expanded" )
- #end
- #end
- #set ( $active = "" )
- #if ( $alignedFileName == $currentItemHref )
- #set ($active = " active")
- #end
- <li class="$collapse$active">
- #link($currentItemHref $item.name $item.target $item.img $item.position $item.alt $item.border $item.width $item.height )
- #if ( $item && $item.items && $item.items.size() > 0 )
- #if ( $collapse == "expanded" )
- <ul>
- #foreach( $subitem in $item.items )
- #menuItem( $subitem )
- #end
- </ul>
- #end
- #end
- </li>
-#end
-##
-#macro ( mainMenu $menus )
- #foreach( $menu in $menus )
- <ul class="nav nav-list">
- #if ( $menu.name )
- #if ( $menu.img )
- <li class="nav-header"><i class="$menu.img"></i>$menu.name</li>
- #else
- <li class="nav-header">$menu.name</li>
- #end
- #end
- #if ( $menu.items && $menu.items.size() > 0 )
- #foreach( $item in $menu.items )
- #menuItem( $item )
- #end
- #end
- </ul>
- #end
-#end
-##
-#macro ( copyright )
- #if ( $project )
- #if ( ${project.organization} && ${project.organization.name} )
- #set ( $period = "" )
- #else
- #set ( $period = "." )
- #end
-##
- #set ( $currentYear = ${currentDate.year} + 1900 )
-##
- #if ( ${project.inceptionYear} && ( ${project.inceptionYear} != ${currentYear.toString()} ) )
- ${project.inceptionYear}-${currentYear}${period}
- #else
- ${currentYear}${period}
- #end
-##
- #if ( ${project.organization} )
- #if ( ${project.organization.name} && ${project.organization.url} )
- <a href="$project.organization.url">${project.organization.name}</a>.
- #elseif ( ${project.organization.name} )
- ${project.organization.name}.
- #end
- #end
- #end
-#end
-##
-#macro ( publishDate $position $publishDate $version )
- #if ( $publishDate && $publishDate.format )
- #set ( $format = $publishDate.format )
- #else
- #set ( $format = "yyyy-MM-dd" )
- #end
-##
- $dateFormat.applyPattern( $format )
-##
- #set ( $dateToday = $dateFormat.format( $currentDate ) )
-##
- #if ( $publishDate && $publishDate.position )
- #set ( $datePosition = $publishDate.position )
- #else
- #set ( $datePosition = "left" )
- #end
-##
- #if ( $version )
- #if ( $version.position )
- #set ( $versionPosition = $version.position )
- #else
- #set ( $versionPosition = "left" )
- #end
- #else
- #set ( $version = "" )
- #set ( $versionPosition = "left" )
- #end
-##
- #set ( $breadcrumbs = $decoration.body.breadcrumbs )
- #set ( $links = $decoration.body.links )
-
- #if ( $datePosition.equalsIgnoreCase( $position ) )
- #if ( ( $datePosition.equalsIgnoreCase( "right" ) ) || ( $datePosition.equalsIgnoreCase( "bottom" ) ) )
- <span id="publishDate">$i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday</span>
- #if ( $versionPosition.equalsIgnoreCase( $position ) )
- <span class="divider">|</span> <span id="projectVersion">$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}</span>
- #end
- #elseif ( ( $datePosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $datePosition.equalsIgnoreCase( "navigation-top" ) ) )
- <div id="lastPublished">
- <span id="publishDate">$i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday</span>
- #if ( $versionPosition.equalsIgnoreCase( $position ) )
- <span class="divider">|</span> <span id="projectVersion">$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}</span>
- #end
- </div>
- #elseif ( $datePosition.equalsIgnoreCase("left") )
- <div class="pull-left">
- <span id="publishDate">$i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday</span>
- #if ( $versionPosition.equalsIgnoreCase( $position ) )
- <span class="divider">|</span> <span id="projectVersion">$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}</span>
- #end
- #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
- <span class="divider">|</span> #breadcrumbs( $breadcrumbs )
- #end
- </div>
- #end
- #elseif ( $versionPosition.equalsIgnoreCase( $position ) )
- #if ( ( $versionPosition.equalsIgnoreCase( "right" ) ) || ( $versionPosition.equalsIgnoreCase( "bottom" ) ) )
- $prefix <span id="projectVersion">$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}</span>
- #elseif ( ( $versionPosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $versionPosition.equalsIgnoreCase( "navigation-top" ) ) )
- <div id="lastPublished">
- <span id="projectVersion">$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}</span>
- </div>
- #elseif ( $versionPosition.equalsIgnoreCase("left") )
- <div class="pull-left">
- <span id="projectVersion">$i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}</span>
- #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
- <span class="divider">|</span> #breadcrumbs( $breadcrumbs )
- #end
- </div>
- #end
- #elseif ( $position.equalsIgnoreCase( "left" ) )
- #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
- <div class="pull-left">
- #breadcrumbs( $breadcrumbs )
- </div>
- #end
- #end
-#end
-##
-#macro ( poweredByLogo $poweredBy )
- #if( $poweredBy )
- #foreach ($item in $poweredBy)
- #if( $item.href )
- #set ( $href = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $href = $href.replaceAll( '\\', '/' ) )
- #else
- #set ( $href="http://maven.apache.org/" )
- #end
-##
- #if( $item.name )
- #set ( $name = $item.name )
- #else
- #set ( $name = $i18n.getString( "site-renderer", $locale, "template.builtby" ) )
- #set ( $name = "${name} Maven" )
- #end
-##
- #if( $item.img )
- #set ( $img = $item.img )
- #else
- #set ( $img = "images/logos/maven-feather.png" )
- #end
-##
- #if ( ! ( $img.toLowerCase().startsWith("http:/") || $img.toLowerCase().startsWith("https:/") ||
- $img.toLowerCase().startsWith("ftp:/") || $img.toLowerCase().startsWith("mailto:/") ||
- $img.toLowerCase().startsWith("file:/") || ($img.toLowerCase().indexOf("://") != -1) ) )
- #set ( $img = $PathTool.calculateLink( $img, $relativePath ) )
- #set ( $img = $img.replaceAll( '\\', '/' ) )
- #end
-##
- #if( $item.alt )
- #set ( $alt = ' alt="' + $item.alt + '"' )
- #else
- #set ( $alt = ' alt="' + $name + '"' )
- #end
-##
- #if( $item.border )
- #set ( $border = ' border="' + $item.border + '"' )
- #else
- #set ( $border = "" )
- #end
-##
- #if( $item.width )
- #set ( $width = ' width="' + $item.width + '"' )
- #else
- #set ( $width = "" )
- #end
- #if( $item.height )
- #set ( $height = ' height="' + $item.height + '"' )
- #else
- #set ( $height = "" )
- #end
-##
- <a href="$href" title="$name" class="poweredBy">
- <img class="poweredBy" $alt src="$img" $border $width $height />
- </a>
- #end
- #if( $poweredBy.isEmpty() )
- <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven" class="poweredBy">
- <img class="poweredBy" alt="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven" src="$relativePath/images/logos/maven-feather.png" />
- </a>
- #end
- #else
- <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven" class="poweredBy">
- <img class="poweredBy" alt="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven" src="$relativePath/images/logos/maven-feather.png" />
- </a>
- #end
-#end
-##
-#macro ( googleAnalytics $accountId )
- #if( $accountId && $accountId != "" )
- <!-- Google Analytics -->
- <script type="text/javascript">
-
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', '$accountId']);
- _gaq.push (['_gat._anonymizeIp']);
- _gaq.push(['_trackPageview']);
-
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
-
- </script>
- #end
-#end
-##
-<html xmlns="http://www.w3.org/1999/xhtml"#if ( $locale ) xml:lang="$locale.language" lang="$locale.language"#end>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
- <title>$title - $project.name</title>
- <link rel="stylesheet" href="$relativePath/css/bootstrap.min.css" type="text/css" />
- <link rel="stylesheet" href="$relativePath/css/site.css" type="text/css" />
- <script type="text/javascript" src="$relativePath/js/jquery.min.js"></script>
- <script type="text/javascript" src="$relativePath/js/bootstrap.min.js"></script>
- <script type="text/javascript" src="$relativePath/js/prettify.min.js"></script>
- <script type="text/javascript" src="$relativePath/js/site.js"></script>
-#foreach( $author in $authors )
- <meta name="author" content="$author" />
-#end
-#if ( $dateCreation )
- <meta name="Date-Creation-yyyymmdd" content="$dateCreation" />
-#end
-#if ( $dateRevision )
- <meta name="Date-Revision-yyyymmdd" content="$dateRevision" />
-#end
-#if ( $locale )
- <meta http-equiv="Content-Language" content="$locale.language" />
-#end
- $headContent
- #googleAnalytics( $decoration.googleAnalyticsAccountId )
- </head>
- <body class="composite">
-
- <div class="navbar">
- <div class="navbar-inner">
- <div class="container-fluid">
- <a class="brand" href="$project.url">$project.name ™</a>
- #links( $decoration.body.links )
-
- <!-- Twitter link -->
- <ul class="nav pull-right">
- <li><a href="http://twitter.com/log4php/" class="external">Follow <strong>@log4php</strong></a></li>
- </ul>
-
- <!-- Google CSE Search Box -->
- <form class="navbar-search pull-right" id="cref" action="http://www.google.com/cse">
- <input type="hidden" name="cref" value="$project.url/cse.xml" />
- <input class="search-query pull-left" type="text" name="q" size="40" placeholder="Search" />
- </form>
- </div>
- </div>
- </div>
-
- <div class="container-fluid">
- <table class="layout-table">
- <tr>
- <td class="sidebar">
- <div class="well sidebar-nav">
- #mainMenu( $decoration.body.menus )
- </div>
- <div id="poweredBy">
- #poweredByLogo( $decoration.poweredBy )
- </div>
- </td>
- <td class="content">
- $bodyContent
- </td>
- </tr>
- </table>
- </div>
-
- <div class="footer">
- <p>Copyright ©#copyright()All Rights Reserved.#publishDate( "bottom" $decoration.publishDate $decoration.version )
- Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache Software License, Version 2.0</a>.
- Please read the <a href="$relativePath/privacy.html">Privacy policy</a></p>
- <p>Apache log4php, Apache, log4php, the Apache feather logo, the Apache Logging Services project logo and the Built by
- Maven logo are trademarks of The Apache Software Foundation.</p>
- <p>Site powered by <a class="external" href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>. Icons from
- <a class="external" href="http://glyphicons.com/">Glyphicons Free</a>.</p>
- </div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
deleted file mode 100644
index a4b3d06..0000000
--- a/src/site/site.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Apache log4php"
- xmlns="http://maven.apache.org/DECORATION/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd">
-
- <googleAnalyticsAccountId>UA-26177991-1</googleAnalyticsAccountId>
-
- <body>
- <links>
- <item name="About" href="/index.html" />
- <item name="Download" href="/download.html" />
- <item name="Install" href="/install.html" />
- <item name="Quick start" href="/quickstart.html" />
- </links>
-
- <menu name="Apache log4phpâ„¢" img="icon-home">
- <item name="About" href="/index.html" />
- <item name="Download" href="/download.html" />
- <item name="Install" href="/install.html" />
- <item name="Changelog" href="/changelog.html" />
- </menu>
-
- <menu name="Documentation" img="icon-book">
- <item name="Quick start" href="/quickstart.html" />
- <item name="Introduction" href="/docs/introduction.html" />
- <item name="Configuration" href="/docs/configuration.html" />
- <item name="Loggers" href="/docs/loggers.html" />
- <item name="Appenders" href="/docs/appenders.html" collapse="true">
- <item name="LoggerAppenderConsole" href="/docs/appenders/console.html" />
- <item name="LoggerAppenderDailyFile" href="/docs/appenders/daily-file.html" />
- <item name="LoggerAppenderEcho" href="/docs/appenders/echo.html" />
- <item name="LoggerAppenderFile" href="/docs/appenders/file.html" />
- <item name="LoggerAppenderFirePHP" href="/docs/appenders/firephp.html" />
- <item name="LoggerAppenderMail" href="/docs/appenders/mail.html" />
- <item name="LoggerAppenderMailEvent" href="/docs/appenders/mail-event.html" />
- <item name="LoggerAppenderMongoDB" href="/docs/appenders/mongodb.html" />
- <item name="LoggerAppenderNull" href="/docs/appenders/null.html" />
- <item name="LoggerAppenderPDO" href="/docs/appenders/pdo.html" />
- <item name="LoggerAppenderPHP" href="/docs/appenders/php.html" />
- <item name="LoggerAppenderRollingFile" href="/docs/appenders/rolling-file.html" />
- <item name="LoggerAppenderSocket" href="/docs/appenders/socket.html" />
- <item name="LoggerAppenderSyslog" href="/docs/appenders/syslog.html" />
- </item>
- <item name="Layouts" href="/docs/layouts.html" collapse="true">
- <item name="LoggerLayoutHtml" href="/docs/layouts/html.html" />
- <item name="LoggerLayoutPattern" href="/docs/layouts/pattern.html" />
- <item name="LoggerLayoutSerialized" href="/docs/layouts/serialized.html" />
- <item name="LoggerLayoutSimple" href="/docs/layouts/simple.html" />
- <item name="LoggerLayoutTTCC" href="/docs/layouts/ttcc.html" />
- <item name="LoggerLayoutXml" href="/docs/layouts/xml.html" />
- </item>
- <item name="Filters" href="/docs/filters.html" />
- <item name="Renderers" href="/docs/renderers.html" />
- <item name="API documentation" href="/apidocs/index.html" />
- </menu>
-
- <menu name="Community" img="icon-user">
- <item name="Volunteering" href="/volunteering.html" />
- <item name="Contributing Patches" href="/contributingpatches.html" />
- <item name="Wiki" href="http://wiki.apache.org/logging-log4php" />
- <item name="Blog" href="http://blogs.apache.org/logging/" />
- </menu>
-
- <menu name="Project Information" img="icon-info-sign">
- <item name="Continuous Integration" href="/integration.html" />
- <item name="Source Repository" href="/source-repository.html" />
- <item name="Dependencies" href="/dependencies.html" />
- <item name="Project License" href="/license.html" />
- <item name="Project Team" href="/team-list.html" />
- <item name="Issue Tracking" href="/issue-tracking.html" />
- <item name="Mailing Lists" href="/mail-lists.html" />
- </menu>
-
- <menu name="Project Reports" img="icon-cog">
- <item name="Changes Report" href="/changes-report.html" />
- <item name="Surefire Report" href="/surefire-report.html" />
- <item name="RAT Report" href="/rat-report.html" />
- <item name="Code Coverage" href="/coverage-report/index.html" />
- </menu>
-
- <menu name="Apache" img="icon-heart">
- <item name="Home" href="http://www.apache.org" />
- <item name="Sponsorship" href="http://www.apache.org/foundation/sponsorship.html" />
- <item name="License" href="http://www.apache.org/licenses/" />
- <item name="Thanks" href="http://www.apache.org/foundation/thanks.html" />
- <item name="Conferences" href="http://www.apachecon.com" />
- <item name="Security" href="http://www.apache.org/security/" />
- </menu>
- </body>
-</project>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/changelog.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/changelog.xml b/src/site/xdoc/changelog.xml
deleted file mode 100644
index 272709f..0000000
--- a/src/site/xdoc/changelog.xml
+++ /dev/null
@@ -1,182 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Releases</title>
- </properties>
-
- <body>
- <section name="Releases">
-
- <macro name="toc">
- <param name="fromDepth" value="2"/>
- </macro>
-
- <subsection name="Apache log4php v2.3.0" id="Apache_log4php_v2.3.0">
- <p>Release date: TBA</p>
- <p><a href="changes-report.html#a2.3.0">JIRA change log</a></p>
- <p>This release introduces various new features and improvements</p>
-
- <p><strong>New features:</strong></p>
- <ul>
- <li>Ability to <a href="docs/renderers.html#Overriding_the_default_renderer">override the default
- renderer</a>.</li>
- <li>New appender: <a href="docs/appenders/firephp.html">FirePHP</a> (thanks to Bruce Ingalls).
- Still in experimental phase.</li>
- </ul>
-
- <p><strong>Improvements:</strong></p>
- <ul>
- <li><a href="docs/layouts/pattern.html">LoggerLayoutPatern</a> has been greatly improved:
- <ul>
- <li>supports longer conversion words such as <code>%date</code> instead of <code>%d</code>,
- <code>%message</code> instead of <code>%m</code>, etc.</li>
- <li>added many new conversion words; check out the docs for the full list</li>
- <li>changed the default conversion pattern to be more verbose</li>
- </ul>
- </li>
- <li><a href="docs/appenders/pdo.html">LoggerAppenderPDO</a> will attempt to reconnect a couple of
- times if logging fails. This solves the problem with the connection expiring in long running
- scripts.</li>
- <li><a href="docs/appenders/daily-file.html">LoggerAppenderDailyFile</a> will rollover even in
- long running scripts.</li>
- <li><a href="docs/appenders/mongodb.html">LoggerAppenderMongoDB</a> has improved error reporting
- </li>
- </ul>
-
- <p><strong>Bugfixes:</strong></p>
- <ul>
- <li>Fixed a bug where upstream loggers would log events regardless of their level.</li>
- <li>Re-enabled usage of PHP constants in config parameters.</li>
- </ul>
-
- <p><strong>Breaking changes:</strong></p>
- <ul>
- <li><a href="docs/layouts/ttcc.html">LoggerLayoutTTCC</a> has been made deprecated. Please switch
- to <a href="docs/layouts/pattern.html">LoggerLayoutPatern</a>.</li>
- <li>Several changes to <a href="docs/appenders/pdo.html">LoggerAppenderPDO</a>:
- <ul>
- <li>a database table for logging will no longer be created by the appender; the user must
- create this table manually.</li>
- <li>the default date pattern does not include milliseconds (this is faster)</li>
- </ul>
- </li>
- <li>In <a href="docs/layouts/pattern.html">LoggerLayoutPattern</a>, it is no longer possible to
- access $_SERVER and $_ENV values using <code>%X{server.*}</code> and <code>%X{env.*}</code>
- conversion words; use the new words <code>%server{*}</code> and <code>%env{*}</code> instead.
- </li>
- <li>Custom renderer classes should implement the <code>LoggerRenderer</code> interface instead of
- <code>LoggerRendererObject</code>.</li>
- </ul>
-
- <p>Please review the documentation and make any necessary changes to your configuration.</p>
-
- </subsection>
-
- <subsection name="Apache log4php v2.2.1" id="Apache_log4php_v2.2.1">
- <p>Release date: 18.02.2012.</p>
- <p><a href="changes-report.html#a2.2.1">JIRA change log</a></p>
-
- <p>A bugfix release fixing several critical bugs found since the 2.2.0 release.</p>
-
- <p><strong>Bugfixes:</strong></p>
- <ul>
- <li>Fixed a bug which prevented configuration by passing a LoggerConfigurator instance.</li>
- <li>Fixed a bug which prevented parsing of INI configuration files when using PHP 5.2.x.</li>
- </ul>
-
- <p><strong>New features:</strong></p>
- <ul>
- <li>Added connection timeout parameter to the <a href="docs/appenders/mongodb.html">MongoDB appender</a>.</li>
- </ul>
- </subsection>
-
- <subsection name="Apache log4php v2.2.0" id="Apache_log4php_v2.2.0">
-
- <p>Release date: 20.12.2011.</p>
- <p><a href="changes-report.html#a2.2.0">JIRA change log</a></p>
-
- <p><strong>New features:</strong></p>
- <ul>
- <li>A new layout: <a href="docs/layouts/serialized.html">serialized</a></li>
- </ul>
-
- <p><strong>Improvements:</strong></p>
- <ul>
- <li>Full rewrite of the <a href="docs/configuration.html">configuration logic</a>. Makes inline
- PHP configuration possible.</li>
- <li>Improved error reporting. Warnings will be triggered if problems are detected. This makes
- locating errors in configuration easier.</li>
- <li>Appenders will use a default layout if no layout is specified in configuration.</li>
- <li>The <a href="docs/layouts/xml.html">XML layout</a> has been extended to include MDC data.</li>
- <li>Improved documentation to include more XML and PHP configuration examples.</li>
- <li>New web site appearance (powered by the <a class="external"
- href="http://twitter.github.com/bootstrap/">Bootstrap toolkit</a>).</li>
- </ul>
-
- <p><strong>Breaking changes:</strong></p>
- <ul>
- <li>The <a href="docs/appenders/socket.html">socket appender</a> has been rewritten to use a layout.
- By default it will use the <a href="docs/layouts/serialized.html">serialized layout</a>.</li>
- <li>The <a href="docs/appenders/syslog.html">syslog appender</a> has been rewritten and the
- interpretation of parameters has changed.</li>
- </ul>
- <p>Please review the documentation and make any necessary changes to your configuration.</p>
- </subsection>
-
- <subsection name="Apache log4php v2.1.0" id="Apache_log4php_v2.1.0">
-
- <p>Release date: 13.07.2011.</p>
- <p><a href="changes-report.html#a2.1.0">JIRA change log</a></p>
-
- <p><strong>New features:</strong></p>
- <ul>
- <li>New logging level: TRACE</li>
- <li>New appender: MongoDB (thanks to Vladimir Gorej)</li>
- </ul>
-
- <p><strong>Improvements:</strong></p>
- <ul>
- <li>A lot of bugfixes</li>
- <li>Most of the documentation has been rewritten</li>
- </ul>
- </subsection>
-
- <subsection name="Apache log4php v2.0.0" id="Apache_log4php_v2.0.0">
-
- <p>Release date: 12.12.2009.</p>
- <p><a href="changes-report.html#a2.0.0">JIRA change log</a></p>
-
- <p>Apache log4php 2.0 is not compatible with the previous versions. Please have the following in mind
- when upgrading to log4php 2.0 in your project:</p>
-
- <ul>
- <li>PHP 5.2+ is required</li>
- <li>LoggerManager class has been removed. Use Logger instead.</li>
- <li>LoggerHierarchy is not a singleton anymore by default.</li>
- <li>logs to STDOUT by default</li>
- <li>LOG4PHP_CONFIGURATION constant is no longer used. Please use Logger::configure() to configure
- log4php.</li>
- </ul>
- </subsection>
-
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders.xml b/src/site/xdoc/docs/appenders.xml
deleted file mode 100644
index 8b88e13..0000000
--- a/src/site/xdoc/docs/appenders.xml
+++ /dev/null
@@ -1,191 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Appenders</title>
- </properties>
-
- <body>
- <section name="Appenders">
-
- <p>Logging requests can be sent to multiple destinations, such as files, databases, syslog and others.
- Such destinations are called appenders. Appenders are attached to <a href="loggers.html">loggers</a>
- and each logger can have multiple attached appenders.</p>
-
- <subsection name="Appender reference" id="Appender_reference">
-
- <p>The following appender classes are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Destination</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><a href="appenders/console.html">LoggerAppenderConsole</a></td>
- <td>Console, directly to the stdout or stderr stream.</td>
- </tr>
- <tr>
- <td><a href="appenders/echo.html">LoggerAppenderEcho</a></td>
- <td>Console, using the PHP <code>echo</code> command.</td>
- </tr>
- <tr>
- <td><a href="appenders/file.html">LoggerAppenderFile</a></td>
- <td>A file.</td>
- </tr>
- <tr>
- <td><a href="appenders/daily-file.html">LoggerAppenderDailyFile</a></td>
- <td>A file (new file each day).</td>
- </tr>
- <tr>
- <td><a href="appenders/rolling-file.html">LoggerAppenderRollingFile</a></td>
- <td>A file (new file when a specified size has been reached). </td>
- </tr>
- <tr>
- <td><a href="appenders/mail.html">LoggerAppenderMail</a></td>
- <td>Sends the log via email. The entire log is sent in one email.</td>
- </tr>
- <tr>
- <td><a href="appenders/mail-event.html">LoggerAppenderMailEvent</a></td>
- <td>Sends the log via email. Each log entry is sent in individual emails.</td>
- </tr>
- <tr>
- <td><a href="appenders/mongodb.html">LoggerAppenderMongoDB</a></td>
- <td>MongoDB.</td>
- </tr>
- <tr>
- <td><a href="appenders/null.html">LoggerAppenderNull</a></td>
- <td>Ignores all log events.</td>
- </tr>
- <tr>
- <td><a href="appenders/pdo.html">LoggerAppenderPDO</a></td>
- <td>Database.</td>
- </tr>
- <tr>
- <td><a href="appenders/php.html">LoggerAppenderPhp</a></td>
- <td>Creates a PHP user-level message using the PHP <code>trigger_error()</code> function.</td>
- </tr>
- <tr>
- <td><a href="appenders/socket.html">LoggerAppenderSocket</a></td>
- <td>A network socket.</td>
- </tr>
- <tr>
- <td><a href="appenders/syslog.html">LoggerAppenderSyslog</a></td>
- <td>Syslog.</td>
- </tr>
-
- </tbody>
- </table>
-
- </subsection>
-
-
- <subsection name="Configuring appenders" id="Configuring_appenders">
-
- <p>The following configuration shows how to configure an appender which logs to a file:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderFile">
- <layout class="LoggerLayoutSimple" />
- <param name="file" value="/var/log/my.log" />
- <param name="append" value="true" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
-
- <p>From the configuration you can see that an appender has the following properties:</p>
-
- <ul>
- <li>A <strong>name</strong> which uniquely identifies it, in this case <em>default</em>.</li>
- <li>A <strong>class</strong> which specifies which appender class will be used to handle the
- requests. Since we wish to log to a file, <code>LoggerAppenderFile</code> is used in this case.</li>
- <li>A <strong>layout</strong> which transforms the logging events to string which can be logged.
- A layout is required by most appenders, but some do not require it, such as the database appender.
- If a layout is not defined, the appenders will use a default layout.</li>
- <li>Zero or more <strong>parameters</strong> which configure the appender
- behaviour. In this example, the <em>file</em> parameter governs the path to the file which will be
- used for logging, and <em>append</em> defines that log messages should be appended to the file,
- instead of truncating it.</li>
- </ul>
-
- </subsection>
-
- <subsection name="Linking appenders to loggers">
-
- <p>A logger can be linked to one or more appenders. Also, multiple loggers can share the same
- appender.</p>
-
- <p>Consider the following configuration:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/">
- <appender name="primus" class="LoggerAppenderConsole" />
- <appender name="secundus" class="LoggerAppenderFile">
- <param name="file" value="/var/log/my.log" />
- </appender>
- <logger name="main">
- <appender_ref ref="primus" />
- <appender_ref ref="secundus" />
- </logger>
- <logger name="alternative">
- <appender_ref ref="primus" />
- </logger>
-</log4php:configuration>
-]]></pre>
-
- <p>This configures two appenders, called <em>primus</em> and <em>secundus</em>, and two loggers named
- <em>main</em> and <em>alternative</em>. The logger <em>main</em> is linked to <em>primus</em> and
- <em>secundus</em> and will therefore forward logging events to both of them. In other words,
- it will log both to console and to a file. Logger <em>alternative</em> is only linked to appender
- <em>primus</em> and will therefore only log to the console.</p>
-
- </subsection>
-
-
- <subsection name="Appender threshold">
-
- <p>An appender can be assigned a threshold level. All logging requests with level lower than this threshold
- will be ignored.</p>
-
- <p>For example, if you set <code>WARN</code> as a threshold, then <code>INFO</code>, <code>DEBUG</code>
- and <code>TRACE</code> level events recieved by the appender will not be logged, but <code>WARN</code>,
- <code>ERROR</code> and <code>FATAL</code> will.</p>
-
- <p>An example of setting an appender threshold:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho" threshold="WARN" />
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/console.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/console.xml b/src/site/xdoc/docs/appenders/console.xml
deleted file mode 100644
index 92eefa2..0000000
--- a/src/site/xdoc/docs/appenders/console.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderConsole</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderConsole">
-
- <p><code>LoggerAppenderConsole</code> writes logging events to the <code>php://stdout</code> or
- the <code>php://stderr</code> stream, the former being the default target.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>target</td>
- <td>string</td>
- <td>No</td>
- <td>stdout</td>
- <td>The stream to write to; either "stdout" or "stderr".</td>
- </tr>
- </tbody>
- </table>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>This example shows how to configure <code>LoggerAppenderConsole</code>.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content">
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderConsole">
- <layout class="LoggerLayoutSimple" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
-
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderConsole',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/daily-file.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/daily-file.xml b/src/site/xdoc/docs/appenders/daily-file.xml
deleted file mode 100644
index 4f5d352..0000000
--- a/src/site/xdoc/docs/appenders/daily-file.xml
+++ /dev/null
@@ -1,169 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderDailyFile</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderDailyFile">
-
- <p><code>LoggerAppenderDailyFile</code> writes logging events to a file which is rolled over depending on
- the date/time of the logging event. By default, the file is rolled over daily, hence the appender name.
- However, the appender can just as easily be configured to roll over once a month, or even every minute
- if desired.</p>
-
- <p>Unlike <code>LoggerAppenderFile</code>, the target file is not static, and can change during script
- execution as the time passes. Destination file is determined by two parameters: <code>file</code> and
- <code>datePattern</code>.</p>
-
- <p>The path specified in the <code>file</code> parameter should contain the string <code>%s</code>.
- Each time an event is logged, this string will be substituted with
- the event's date/time formatted according to <code>datePattern</code> and the event will be logged to
- the resulting file path.</p>
-
- <p>The date/time is formatted according to format string specified in the <code>datePattern</code>
- parameter. The format uses the same rules as the PHP <code><a class="external"
- href="http://php.net/manual/en/function.date.php">date()</a></code> function. Any format string supported
- by <code>date()</code> function may be used as a date pattern.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>file</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Path to the target file. Should contain a <code>%s</code> which gets substituted by the
- date.</td>
- </tr>
- <tr>
- <td>append</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the appender will append to the file, otherwise the file contents will be
- overwritten.</td>
- </tr>
- <tr>
- <td>datePattern</td>
- <td>string</td>
- <td>No</td>
- <td>Ymd</td>
- <td>Format for the date in the file path, follows formatting rules used by the PHP
- <code><a href="http://php.net/manual/en/function.date.php">date()</a></code> function.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
-
- <p>Consider the following configuration:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderDailyFile">
- <layout class="LoggerLayoutSimple" />
- <param name="file" value="file-%s.log" />
- <param name="datePattern" value="Y-m-d" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderDailyFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'datePattern' => 'Y-m-d',
- 'file' => 'file-%s.log',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>In this example, the date pattern is set to <code>Y-m-d</code> (year, month, day) and the target
- file to <code>daily.%s.log</code>.</p>
-
- <p>Each time this appender receives a logging event, it will:</p>
-
- <ol>
- <li>Format the event date/time according to the configured date pattern. Let's say this sample
- is run during 10th of July 2012, then the formatted date is <code>2012-07-10</code></li>
- <li>Replace the <code>%s</code> in the filename with the formated date to get the target file.
- In this case, the target file will be <code>daily.2012-07-10.log</code>.</li>
- <li>Write to the target file.</li>
- </ol>
-
- <p>If you continue logging using the given configuration, the appender will continue to log to
- <code>daily.2012-07-10.log</code>, until the date changes. At that point it will start logging to
- <code>daily.2012-07-11.log</code>.</p>
-
- <p>Similarly, date pattern <code>Y-m</code> will result in filenames like <code>file-2012-07.log</code>,
- which will result in monthly rollover.</p>
-
- <p>Hours, minutes and seconds can also be used. Pattern <code>Y-m-d.H.i.s</code> will result
- in filenames similar to <code>file-2012-07-03.10.37.15.log</code>. In this case, a new file will be
- created each second.</p>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/echo.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/echo.xml b/src/site/xdoc/docs/appenders/echo.xml
deleted file mode 100644
index cd98152..0000000
--- a/src/site/xdoc/docs/appenders/echo.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderEcho</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderEcho">
-
- <p><code>LoggerAppenderEcho</code> writes logging events using PHP's
- <code><a class="external" href="http://php.net/manual/en/function.echo.php">echo()</a></code> function.
- Echo outputs may be buffered.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>htmlLineBreaks</td>
- <td>boolean</td>
- <td>No</td>
- <td>false</td>
- <td>If set to true, a <![CDATA[<br />]]> element will be inserted before each line break in
- the logged message.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
- <p>This example shows how to configure <code>LoggerAppenderEcho</code> using the
- <a href="../layouts/ttcc.html">TTCC layout</a> with <code>htmlLineBreaks</code> turned on.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple" />
- <param name="htmlLineBreaks" value="true" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'htmlLineBreaks' => 'true',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/file.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/file.xml b/src/site/xdoc/docs/appenders/file.xml
deleted file mode 100644
index 0ce3310..0000000
--- a/src/site/xdoc/docs/appenders/file.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderFile</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderFile">
-
- <p><code>LoggerAppenderFile</code> writes logging events to a file.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>file</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Path to the target file. Relative paths are resolved based on the working directory.</td>
- </tr>
- <tr>
- <td>append</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the appender will append to the file, otherwise the file contents will be
- overwritten.</td>
- </tr>
- </tbody>
- </table>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>This example shows how to configure <code>LoggerAppenderFile</code> to write to <code>file.log</code>
- and to overwrite any content present in the file. The target file will be created in the current
- working directory.</p>
-
- <p>It is also possible to specify an absolute path to the target file, such as
- <code>/var/log/file.log</code> or <code>D:/logs/file.log</code></p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderFile">
- <layout class="LoggerLayoutSimple" />
- <param name="file" value="file.log" />
- <param name="append" value="false" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'file' => 'file.log',
- 'append' => false
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/firephp.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/firephp.xml b/src/site/xdoc/docs/appenders/firephp.xml
deleted file mode 100644
index 448dda9..0000000
--- a/src/site/xdoc/docs/appenders/firephp.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderFirePHP</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderFirePHP">
-
- <p><code>LoggerAppenderFirePHP</code> logs events via the
- <a href="http://www.firephp.org/" class="external">FirePHP</a> serverside library. The messages are
- logged in HTTP headers and can be viewed using the <a class="external"
- href="http://developercompanion.com/">Developer compainion</a> plugin for Firefox.</p>
-
- <p>Requires the FirePHP server-side library 1.0 or greater. Download it from <a class="external"
- href="http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Welcome">here</a>.</p>
-
- <div class="alert">
- <strong>Warning!</strong> This appender is still experimental. Behaviour may change in future versions
- without notification.
- </div>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>target</td>
- <td>string</td>
- <td>No</td>
- <td>page</td>
- <td>The target to which messages will be sent. Possible options are 'page' (default),
- 'request', 'package' and 'controller'. For more details, see FirePHP
- documentation.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
- <subsection name="Examples">
- <p>Sample configuration:</p>
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderFirePHP">
- <layout class="LoggerLayoutSimple" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderFirePHP',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/mail-event.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/mail-event.xml b/src/site/xdoc/docs/appenders/mail-event.xml
deleted file mode 100644
index b2adeb8..0000000
--- a/src/site/xdoc/docs/appenders/mail-event.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderMailEvent</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderMailEvent">
-
- <p><code>LoggerAppenderMailEvent</code> appends individual log events via email.</p>
-
- <p>This appender is similar to <code><a href="mail.html">LoggerAppenderMail</a></code>, except that it
- sends each each log event in an individual email message at the time when it occurs.</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>to</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Email address(es) to which the log will be sent. Multiple email addresses may be specified
- by separating them with a comma.</td>
- </tr>
- <tr>
- <td>from</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Email address which will be used in the From field.</td>
- </tr>
- <tr>
- <td>subject</td>
- <td>string</td>
- <td>No</td>
- <td>Log4php Report</td>
- <td>Subject of the email message.</td>
- </tr>
- <tr>
- <td>smtpHost</td>
- <td>string</td>
- <td>No</td>
- <td>ini_get('SMTP')</td>
- <td>Used to override the SMTP server. <strong>Only works on Windows.</strong></td>
- </tr>
- <tr>
- <td>port</td>
- <td>integer</td>
- <td>No</td>
- <td>25</td>
- <td>Used to override the default SMTP server port. <strong>Only works on Windows.</strong></td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
-
- <p>This example shows how to configure <code>LoggerAppenderMailEvent</code> to send the log to two email
- addresses.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderMailEvent">
- <layout class="LoggerLayoutSimple" />
- <param name="to" value="foo@example.com,baz@example.com" />
- <param name="from" value="logger@example.com" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderMailEvent',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'to' => 'foo@example.com,baz@example.com',
- 'from' => 'logger@example.com'
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
-
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/mail.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/mail.xml b/src/site/xdoc/docs/appenders/mail.xml
deleted file mode 100644
index 2eb46f1..0000000
--- a/src/site/xdoc/docs/appenders/mail.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderMail</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderMail">
-
- <p><code>LoggerAppenderMail</code> appends log events via email.</p>
-
- <p>This appender does not send individual emails for each logging requests but will collect them in a
- buffer and send them all in a single email once the appender is closed (i.e. when the script exists).
- Because of this, it may not appropriate for long running scripts, in which case
- <code><a href="mail-event.html">LoggerAppenderMailEvent</a></code> might be a better choice.</p>
-
- <p class="alert alert-warning"><strong>Note:</strong> When working in Windows, make sure that the
- <code>SMTP</code> and <code>smpt_port</code> values in php.ini are set to the correct values for
- your email server (address and port).</p>
-
- <subsection name="Layout">
- <p>This appender requires a layout. If no layout is specified in configuration,
- <code><a href="../layouts/simple.html">LoggerLayoutSimple</a></code> will be used by default.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>to</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Email address(es) to which the log will be sent. Multiple email addresses may be specified
- by separating them with a comma.</td>
- </tr>
- <tr>
- <td>from</td>
- <td>string</td>
- <td><strong>Yes</strong></td>
- <td>-</td>
- <td>Email address which will be used in the From field.</td>
- </tr>
- <tr>
- <td>subject</td>
- <td>string</td>
- <td>No</td>
- <td>Log4php Report</td>
- <td>Subject of the email message.</td>
- </tr>
- </tbody>
- </table>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>This example shows how to configure <code>LoggerAppenderMail</code> to send the log to two email
- addresses.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderMail">
- <layout class="LoggerLayoutSimple" />
- <param name="to" value="foo@example.com,baz@example.com" />
- <param name="from" value="logger@example.com" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderMail',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- 'params' => array(
- 'to' => 'foo@example.com,baz@example.com',
- 'from' => 'logger@example.com'
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/mongodb.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/mongodb.xml b/src/site/xdoc/docs/appenders/mongodb.xml
deleted file mode 100644
index bd327b9..0000000
--- a/src/site/xdoc/docs/appenders/mongodb.xml
+++ /dev/null
@@ -1,169 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderMongoDB</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderMongoDB">
-
- <p><code>LoggerAppenderMongoDB</code> appends log events to a mongoDB instance.</p>
-
- <p><a href="http://www.mongodb.org/" class="external">MongoDB</a> is a scalable,
- high-performance, open source, document-oriented database.</p>
-
- <subsection name="Layout">
- <p>This appender does not require a layout.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>host</td>
- <td>string</td>
- <td>No</td>
- <td>mongodb://localhost</td>
- <td>Server on which mongodb instance is located.</td>
- </tr>
- <tr>
- <td>port</td>
- <td>integer</td>
- <td>No</td>
- <td>27017</td>
- <td>Port on which the instance is bound.</td>
- </tr>
- <tr>
- <td>databaseName</td>
- <td>string</td>
- <td>No</td>
- <td>log4php_mongodb</td>
- <td>Name of the database to which to log.</td>
- </tr>
- <tr>
- <td>collectionName</td>
- <td>string</td>
- <td>No</td>
- <td>logs</td>
- <td>Name of the target collection within the given database.</td>
- </tr>
- <tr>
- <td>username</td>
- <td>string</td>
- <td>No</td>
- <td>-</td>
- <td>Username used to connect to the database.</td>
- </tr>
- <tr>
- <td>password</td>
- <td>string</td>
- <td>No</td>
- <td>-</td>
- <td>Password used to connect to the database.</td>
- </tr>
- <tr>
- <td>timeout</td>
- <td>integer</td>
- <td>No</td>
- <td>3000</td>
- <td>For how long the driver should try to connect to the database (in milliseconds).</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Changelog">
- <table class="table table-striped table-bordered table-not-wide">
- <thead>
- <tr>
- <th>Version</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>2.2.0</code></td>
- <td>Added the <code>timeout</code> parameter.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
- <p>This example shows how to configure <code>LoggerAppenderMongoDB</code> to log to a remote database.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderMongoDB">
- <param name="host" value="mongodb://example.com" />
- <param name="username" value="logger" />
- <param name="password" value="secret" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderMongoDB',
- 'params' => array(
- 'host' => 'mongodb://example.com',
- 'username' => 'logger',
- 'password' => 'secret',
- ),
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/appenders/null.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/appenders/null.xml b/src/site/xdoc/docs/appenders/null.xml
deleted file mode 100644
index d363733..0000000
--- a/src/site/xdoc/docs/appenders/null.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerAppenderNull</title>
- </properties>
-
- <body>
- <section name="LoggerAppenderNull">
-
- <p><code>LoggerAppenderNull</code> ignores all logging requests; it never outputs a message to any
- device.</p>
-
- <subsection name="Layout">
- <p>This appender does not require a layout.</p>
- </subsection>
-
- <subsection name="Parameters">
- <p>This appender does not have any configurable parameters.</p>
- </subsection>
-
- <subsection name="Examples">
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderNull" />
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderNull',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-);
-]]></pre>
- </div>
- </div>
- </div>
-
- </subsection>
- </section>
- </body>
-</document>
[12/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/jquery.min.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/jquery.min.js b/src/site/resources/js/jquery.min.js
deleted file mode 100644
index 198b3ff..0000000
--- a/src/site/resources/js/jquery.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! jQuery v1.7.1 jquery.com | jquery.org/license */
-(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p
;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function cb(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function ca(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bE.test(a)?d(a,e):ca(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e i
n b)ca(a+"["+e+"]",b[e],c,d);else d(a,b)}function b_(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function b$(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bT,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=b$(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=b$(a,c,d,e,"*",g));return l}function bZ(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bP),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bC(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bx:by,g=0,h=e.length;if(d>0){if(c!=="border")for(;g<h;g++)c||(d-=parseFloat(f.css(a,"padding"+e[g]))||0),c==="margin"?d+=parseFloat(f.css(a,c+e[g]))||0:d-=parseFloat(f.css(a,"border"+e[g]+"Width"))||0;return d+"px"}d=bz(a,b,b);if(d<0||d==n
ull)d=a.style[b]||0;d=parseFloat(d)||0;if(c)for(;g<h;g++)d+=parseFloat(f.css(a,"padding"+e[g]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+e[g]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+e[g]))||0);return d+"px"}function bp(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;if(b.nodeType===1){b.clearAttributes&&
b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c+(i[c][d].namespace?".":"")+i[c][d].namespace,i[c][d],i[c][d].data)}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a
,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(O.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parse
Float(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.pro
totype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.
context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].
splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventLis
tener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return nul
l;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)bre
ak;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(H)return H.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([
],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},brows
er:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test("Â ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g={};f.Callbacks=function(a){a=a?g[a]||h(a):{};var c=[],d=[],e,i,j,k,l,m=function(b){var d,e,g,h,i;for(d=0,e=b.length;d<e;d++)g=b[d],h=f.type(g),h==="array"?m(g):h==="function"&&(!a.unique||!o.has(g))&&c.push(g)},n=function(b,f){f=f||[],e=!a.memory||[b,f],i=!0,l=j||0,j=0,k=c.length;for(;c&&l<k;l++)if(c[l].apply(b,f)===!1&&a.stopOnFalse){e=!0;break}i=!1,c&&(a.once?e===!0?o.disable():c=[]:d&&d.length&&(e=d.shift(),o.fireWith(e[0],e[1])))},o={add:function(){if(c){var a=c.lengt
h;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var f=0;f<c.length;f++)if(b[d]===c[f]){i&&f<=k&&(k--,f<=l&&l--),c.splice(f--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){c=[];return this},disable:function(){c=d=e=b;return this},disabled:function(){return!c},lock:function(){d=b,(!e||e===!0)&&o.disable();return this},locked:function(){return!d},fireWith:function(b,c){d&&(i?a.once||d.push([b,c]):(!a.once||!e)&&n(b,c));return this},fire:function(){o.fireWith(this,arguments);return this},fired:function(){return!!e}};return o};var i=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),d=f.Callbacks("memory"),e="pending",g={resolve:b,reject:c,notify:d},h={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,th
en:function(a,b,c){i.done(a).fail(b).progress(c);return this},always:function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()},promise:function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}},i=h.promise({}),j;for(j in g)i[j]=g[j].fire,i[j+"With"]=g[j].fireWith;i.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(i,i);return i},when:function(a){function m(a){return function(b){e[a]=arguments.length>1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(argument
s,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&f.isFunction(b[c].promise)?b[c].promise().then(l(c),j.reject,m(c)):--g;g||j.resolveWith(j,b)}else j!==a&&j.resolveWith(j,d?[a]:[]);return k}}),f.support=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p,q=c.createElement("div"),r=c.documentElement;q.setAttribute("className","t"),q.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.st
yle.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendCh
ild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="<div "+n+"><div></div></div>"+"<table "+n+" cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="<table><tr><td style='padding:0;b
order:0;display:none'></td><td>t</td></tr></table>",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="<div style='width:4px;'></div>",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.rem
oveChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(
b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e<g;e++)delete d[b[e]];if(!(c?m:f.isEmptyObject)(d))return}}if(!c){delete j[k].data;if(!m(j[k]))return}f.support.deleteExpando||!j.setInterval?delete j[k]:j[k]=null,i&&(f.support.deleteExpando?delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d,e,g,h=null;if(typeof a=="undefined"){if(this.length){h=f.data(this[0]);if(this[0].nodeType===1&&!f._data(this[0],"parsedAttrs")){e=this[0].attributes;for(var i=0,j=e.length;i<j;i++)g=e[i].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),l(this[0],g,h[g]));f._data(this[0],"parsedAttrs",!0)}}return h}if(typeof a=="object")return this.each(function(){f.data(this,a)});d=a.split("."
),d[1]=d[1]?"."+d[1]:"";if(c===b){h=this.triggerHandler("getData"+d[1]+"!",[d[0]]),h===b&&this.length&&(h=f.data(this[0],a),h=l(this[0],a,h));return h===b&&d[1]?this.data(d[0]):h}return this.each(function(){var b=f(this),e=[d[0],c];b.triggerHandler("setData"+d[1]+"!",e),f.data(this,a,c),b.triggerHandler("changeData"+d[1]+"!",e)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b
)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f.Callbacks("once memory"),!0))h++,l.add(m);m();return d.promise()}});var o=/[\n\t\r]/g,p=/\s+/,q=/\r/g,r=/^(?:button|input)$/i,s=/^(?:button|input|object|select|textare
a)$/i,t=/^a(?:rea)?$/i,u=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,v=f.support.getSetAttribute,w,x,y;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){
f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(p);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(o," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(p);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(o," ").indexOf(b)>-1)return!0;return
!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c<d;c++){e=i[c];if(e.selected&&(f.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!f.nodeName(e.parentNod
e,"optgroup"))){b=f(e).val();if(j)return b;h.push(b)}}if(j&&!h.length&&i.length)return f(i[g]).val();return h},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h<g;h++)e=d[h],e&&(c=f.propFix[e]||e,f.attr(a,e,""),a.removeAttr
ibute(v?e:c),u.test(e)&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(r.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(w&&f.nodeName(a,"button"))return w.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(w&&f.nodeName(a,"button"))return w.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){h=i!==1||!f.isXMLDoc(a),h&&(c=f.propFix[c]||c,g=f.propHooks[c]);return d!==b?g&&"set"in g&&(e=g.set(a,d,c))!==b?e:a[c]=d:g&&"get"in g&&(e=g.get(a,c))!==null?e:a[c]}},propHooks:{ta
bIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):s.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabindex=f.propHooks.tabIndex,x={get:function(a,c){var d,e=f.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},v||(y={name:!0,id:!0},w=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&(y[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=w.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})}),f.attrHooks.contenteditable={get:w.get,set:function(a,b,c){b===""
&&(b="false"),w.set(a,b,c)}}),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.enctype||(f.propFix.enctype="encoding"),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,
C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};
-f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]||{},m=(g?s.delegateType:s.bindType)||m,s=f.event.special[m]||{},o=f.extend({type:m,origType:l[1],data:e,handler:d,guid:d.guid,selector:g,quick:G(g),namespace:n.join(".")},p),r=j[m];if(!r){r=j[m]=[],r.delegateCount=0;if(!s.setup||s.setup.call(a,e,n,i)===!1)a.addEventListener?a.addEventListener(m,i,!1):a.attachEvent&&a.attachEvent("on"+m,i)}s.add&&(s.add.call(a,o),o.handler.guid||(o.handler.guid=d.guid)),g?r.splice(r.delegateCount++,0,o):r.push(o),f.event.global[m]=!0}a=null}},global:{},remove:function
(a,b,c,d,e){var g=f.hasData(a)&&f._data(a),h,i,j,k,l,m,n,o,p,q,r,s;if(!!g&&!!(o=g.events)){b=f.trim(I(b||"")).split(" ");for(h=0;h<b.length;h++){i=A.exec(b[h])||[],j=k=i[1],l=i[2];if(!j){for(j in o)f.event.remove(a,j+b[h],c,d,!0);continue}p=f.event.special[j]||{},j=(d?p.delegateType:p.bindType)||j,r=o[j]||[],m=r.length,l=l?new RegExp("(^|\\.)"+l.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(n=0;n<r.length;n++)s=r[n],(e||k===s.origType)&&(!c||c.guid===s.guid)&&(!l||l.test(s.namespace))&&(!d||d===s.selector||d==="**"&&s.selector)&&(r.splice(n--,1),s.selector&&r.delegateCount--,p.remove&&p.remove.call(a,s));r.length===0&&m!==r.length&&((!p.teardown||p.teardown.call(a,l)===!1)&&f.removeEvent(a,j,g.handle),delete o[j])}f.isEmptyObject(o)&&(q=g.handle,q&&(q.elem=null),f.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){if(!e||e.nodeType!==3&&e.nodeType!==8){var h=c.type||c,i=[],j,k,l,m,n,o,p,q,r,s;if(E.test(h+
f.event.triggered))return;h.indexOf("!")>=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l<r.length&&!c.isPropagationStopped();l++)m=r[l][0],c.type=r[l][1],q=(f._data(m,"ev
ents")||{})[c.type]&&f._data(m,"handle"),q&&q.apply(m,d),q=o&&m[o],q&&f.acceptData(m)&&q.apply(m,d)===!1&&c.preventDefault();c.type=h,!g&&!c.isDefaultPrevented()&&(!p._default||p._default.apply(e.ownerDocument,d)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)&&o&&e[h]&&(h!=="focus"&&h!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(e)&&(n=e[o],n&&(e[o]=null),f.event.triggered=h,e[h](),f.event.triggered=b,n&&(e[o]=n));return c.result}},dispatch:function(c){c=f.event.fix(c||a.event);var d=(f._data(this,"events")||{})[c.type]||[],e=d.delegateCount,g=[].slice.call(arguments,0),h=!c.exclusive&&!c.namespace,i=[],j,k,l,m,n,o,p,q,r,s,t;g[0]=c,c.delegateTarget=this;if(e&&!c.target.disabled&&(!c.button||c.type!=="click")){m=f(this),m.context=this.ownerDocument||this;for(l=c.target;l!=this;l=l.parentNode||this){o={},q=[],m[0]=l;for(j=0;j<e;j++)r=d[j],s=r.selector,o[s]===b&&(o[s]=r.quick?H(l,r.quick):m.is(s)),o[s]&&q.push(r);q.length&&i.push({elem:l,matches:q})}}d.length>e&&i.push({
elem:this,matches:d.slice(e)});for(j=0;j<i.length&&!c.isPropagationStopped();j++){p=i[j],c.currentTarget=p.elem;for(k=0;k<p.matches.length&&!c.isImmediatePropagationStopped();k++){r=p.matches[k];if(h||!c.namespace&&!r.namespace||c.namespace_re&&c.namespace_re.test(r.namespace))c.data=r.data,c.handleObj=r,n=((f.event.special[r.origType]||{}).handle||r.handler).apply(p.elem,g),n!==b&&(c.result=n,n===!1&&(c.preventDefault(),c.stopPropagation()))}}return c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode);return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,d){var e,f,g,h=d.button,i=d.fromElement;a.pa
geX==null&&d.clientX!=null&&(e=a.target.ownerDocument||c,f=e.documentElement,g=e.body,a.pageX=d.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=d.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?d.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0);return a}},fix:function(a){if(a[f.expando])return a;var d,e,g=a,h=f.event.fixHooks[a.type]||{},i=h.props?this.props.concat(h.props):this.props;a=f.Event(g);for(d=i.length;d;)e=i[--d],a[e]=g[e];a.target||(a.target=g.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey===b&&(a.metaKey=a.ctrlKey);return h.filter?h.filter(a,g):a},special:{ready:{setup:f.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeun
load=null)}}},simulate:function(a,b,c,d){var e=f.extend(new f.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?f.event.trigger(e,null,b):f.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},f.event.handle=f.event.dispatch,f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!(this instanceof f.Event))return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?K:J):this.type=a,b&&f.extend(this,b),this.timeStamp=a&&a.timeStamp||f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=K;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=K;var a=this.originalEvent;!a||(a.stopPropagation&&a.s
topPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=K,this.stopPropagation()},isDefaultPrevented:J,isPropagationStopped:J,isImmediatePropagationStopped:J},f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=this,d=a.relatedTarget,e=a.handleObj,g=e.selector,h;if(!d||d!==c&&!f.contains(c,d))a.type=e.origType,h=e.handler.apply(this,arguments),a.type=b;return h}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(){if(f.nodeName(this,"form"))return!1;f.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=f.nodeName(c,"input")||f.nodeName(c,"button")?c.form:b;d&&!d._submit_attached&&(f.event.add(d,"submit._submit",function(a){this.parentNode&&!a.isTrigger&&f.event.simulate("submit",this.parentNode,a,!0)}),d._submit_attached=!0)})},teardown:function(){if(f.nodeName(this,"form"))return!1;f.event.remove(this,".
_submit")}}),f.support.changeBubbles||(f.event.special.change={setup:function(){if(z.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")f.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),f.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1,f.event.simulate("change",this,a,!0))});return!1}f.event.add(this,"beforeactivate._change",function(a){var b=a.target;z.test(b.nodeName)&&!b._change_attached&&(f.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&f.event.simulate("change",this.parentNode,a,!0)}),b._change_attached=!0)})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){f.event.remove(this,"._change");return z.test(this.nodeName)}}),f.support.focusinBubbles||f.each({focus:"focusi
n",blur:"focusout"},function(a,b){var d=0,e=function(a){f.event.simulate(b,a.target,f.event.fix(a),!0)};f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.fn.extend({on:function(a,c,d,e,g){var h,i;if(typeof a=="object"){typeof c!="string"&&(d=c,c=b);for(i in a)this.on(i,c,d,a[i],g);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=J;else if(!e)return this;g===1&&(h=e,e=function(a){f().off(a);return h.apply(this,arguments)},e.guid=h.guid||(h.guid=f.guid++));return this.each(function(){f.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on.call(this,a,b,c,d,1)},off:function(a,c,d){if(a&&a.preventDefault&&a.handleObj){var e=a.handleObj;f(a.delegateTarget).off(e.namespace?e.type+"."+e.namespace:e.type,e.selector,e.handler);return this}if(typeof a=="object"){for(var g in a)this.off(g,c,a[g]);return this}if(c===!1||typeof c=="function"
)d=c,c=b;d===!1&&(d=J);return this.each(function(){f.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){f(this.context).on(a,this.selector,b,c);return this},die:function(a,b){f(this.context).off(a,this.selector||"**",b);return this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a,c)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f._data(this,"lastToggle"+a.guid)||0)%d;f._data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),f.each("blur focus focusin
focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}if(j.nodeType===1){g||(j[d]=c,j.sizset=h);if(typeof b!="string"){if(j===b){k=!0;break}}else if(m.filter(b,[j]).length>0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}j.nodeType===1&&!g&&(j[d]=c,j.sizset=h);if(j.nodeName.toLowerCase()===b){k=j;break}j=j[a]}e[h]=k}}}var a=/((?:\((?:\([^()]+\)|[^()]
+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n
.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},m.matches=function(a,b){return m(a,null,null,b)},m.matchesSelector=function(a,b){return m(b,null,null,[a]).length>0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break
}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},m.filter=function(a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q)if(g==null)m.error(a);else break;q=a}return s},m.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)};var n=m.getText=function(a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e
+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e},o=m.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!l.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.len
gth,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&m.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&m.filter(b,a,!0)}},"":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("previousSibling",b,f,a,d,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?nu
ll:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(j,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[
3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},
password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b
,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}m.error(e)},CHILD:function(a,b){var c,e,f,g,h,i,j,k=b[1],l=a;switch(k){case"only":case"first":while(l=l.previousSibling)if(l.nodeType===1)return!1;if(k==="first")return!0;l=a;case"last":while(l=l.nextSibling)if(l.nodeType===1)return!1;return!0;case"nth":c=b[2],e=b[3];if(c===1&&e===0)return!0;f=b[0],g=a.parentNode;if(g&&(g[d]!==f||!a.nodeIndex)){i=0;for(l=g.firstChild;l;l=l.nextSibling)l.nodeType===1&&(l.nodeIndex=++i);g[d]=f}j=a.nodeIndex-e;return c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=n
ull?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d
.push(a[c]);return d}}var u,v;c.documentElement.compareDocumentPosition?u=function(a,b){if(a===b){h=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(u=function(a,b){if(a===b){h=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],g=a.parentNode,i=b.parentNode,j=g;if(g===i)return v(a,b);if(!g)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return v(e[k],f[k]);return k===c?v(a,f[k],-1):v(e[k],b,1)},v=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElement
ById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=functi
on(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.
call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.co
ntains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h<i;h++)m(a,g[h],e,c);return m.filter(f,e)};m.attr=f.attr,m.selectors.attrMap={},f.find=m,f.expr=m.selectors,f.expr[":"]=f.expr.filters,f.unique=m.uniqueSort,f.text=m.getText,f.isXMLDoc=m.isXML,f.contains=m.contains}();var L=/Until$/,M=/^(?:parents|prevUntil|prevAll)/,N=/,/,O=/^.[^:#\[\.,]*$/,P=Array.prototype.slice,Q=f.expr.match.POS,R={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i
]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(T(this,a,!1),"not",a)},filter:function(a){return this.pushStack(T(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?Q.test(a)?f(a,this.context).index(this[0])>=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d<a.length;d++)f(g).is(a[d])&&c.push({selector:a[d],elem:g,level:h});g=g.parentNode,h++}return c}var i=Q.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(i?i.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&t
his[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},co
ntents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summar
y|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|style)/i,bb=/<(?:script|object|embed|option|style)/i,bc=new RegExp("<(?:"+V+")","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="obje
ct"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:fun
ction(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function()
-{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach()
);return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bi(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bp)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i,j=a[0
];b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(
a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1></$2>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createText
Node(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bn(k[i]);else bn(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||be.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.event.special,g=f.support.deleteExpando;for(var h=0,i;(i=a[h])!=null;h++){if(i.nodeName&&f.noData[i.nodeName.toLowerCase()])continue;c=i[f.expando];if(c){b=d[c];if(b&&b.events){for(var j in b.events)e[j]?f.event.remove(i,j):f.removeEvent(i,j,b.handle);b.handle&&(b.handle.elem=null)}g?delete i[f.expando]:i.removeAttribute&&i.removeAttribute(f.expando),delete d[c]}}}});var bq=/alpha\([^)]*\
)/i,br=/opacity=([^)]*)/,bs=/([A-Z]|^ms)/g,bt=/^-?\d+(?:px)?$/i,bu=/^-?\d/,bv=/^([\-+])=([\-+.\de]+)/,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Left","Right"],by=["Top","Bottom"],bz,bA,bB;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bz(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bv.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&
&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bz)return bz(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){if(a.offsetWidth!==0)return bC(a,b,d);f.swap(a,bw,function(){e=bC(a,b,d)});return e}},set:function(a,b){if(!bt.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;i
f(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"au
to":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arg
uments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSe
nd".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m)
{if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHead
ers:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("
ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));tr
y{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(
j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&
e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.
readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cv(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style
){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cu("hide",3),a,b,c);var d,e,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(e=f.css(d,"display"),e!=="none"&&!f._data(d,"olddisplay")&&f._data(d,"olddisplay",e));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cu("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){function g(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&
(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(!f.support.inlineBlockNeedsLayout||cv(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new f.fx(this,b,i),h=a[i],cn.test(h)?(o=f._data(this,"toggle"+i)||(h==="toggle"?d?"show":"hide":0),o?(f._data(this,"toggle"+i,o==="show"?"hide":"show"),j[o]()):j[h]()):(k=co.exec(h),l=j.cur(),k?(m=parseFloat(k[2]),n=k[3]||(f.cssNumber[i]?"":"px"),n!=="px"&&(f.style(this,i,(m||1)+n),l=(m||1)/j.cur()*l,f.style(this,i,l+n)),k[1]&&(m=(k[1]==="-="?-1:1)*m+l),j.custom(l,m,n)):j.custom(l,h,""));return!0}var e=f.speed(b,
c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return e.queue===!1?this.each(g):this.queue(e.queue,g)},stop:function(a,c,d){typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]);return this.each(function(){function h(a,b,c){var e=b[c];f.removeData(a,c,!0),e.stop(d)}var b,c=!1,e=f.timers,g=f._data(this);d||f._unmark(!0,this);if(a==null)for(b in g)g[b]&&g[b].stop&&b.indexOf(".run")===b.length-4&&h(this,g,b);else g[b=a+".run"]&&g[b].stop&&h(this,g,b);for(b=e.length;b--;)e[b].elem===this&&(a==null||e[b].queue===a)&&(d?e[b](!0):e[b].saveState(),c=!0,e.splice(b,1));(!d||!c)&&f.dequeue(this,a)})}}),f.each({slideDown:cu("show",1),slideUp:cu("hide",1),slideToggle:cu("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a
,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue?f.dequeue(this,d.queue):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,c,d){function h(a){return e.step(a)}var e=this,g=f.fx;t
his.startTime=cr||cs(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(f.cssNumber[this.prop]?"":"px"),h.queue=this.options.queue,h.elem=this.elem,h.saveState=function(){e.options.hide&&f._data(e.elem,"fxshow"+e.prop)===b&&f._data(e.elem,"fxshow"+e.prop,e.start)},h()&&f.timers.push(h)&&!cp&&(cp=setInterval(g.tick,g.interval))},show:function(){var a=f._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||f.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f._data(this.elem,"fxshow"+this.prop)||f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=cr||cs(),g=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.anim
atedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cp),cp=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.s
<TRUNCATED>
[33/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/DateConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/DateConverter.php b/src/Pattern/DateConverter.php
index 5a1ad4a..d6ddc7e 100644
--- a/src/Pattern/DateConverter.php
+++ b/src/Pattern/DateConverter.php
@@ -30,60 +30,63 @@ use Apache\Log4php\LoggingEvent;
* 'ISO8601', 'ABSOLUTE' and 'DATE'.
* @since 2.3
*/
-class DateConverter extends AbstractConverter {
+class DateConverter extends AbstractConverter
+{
+ const DATE_FORMAT_ISO8601 = 'c';
- const DATE_FORMAT_ISO8601 = 'c';
+ const DATE_FORMAT_ABSOLUTE = 'H:i:s';
- const DATE_FORMAT_ABSOLUTE = 'H:i:s';
+ const DATE_FORMAT_DATE = 'd M Y H:i:s.u';
- const DATE_FORMAT_DATE = 'd M Y H:i:s.u';
+ private $format = self::DATE_FORMAT_ISO8601;
- private $format = self::DATE_FORMAT_ISO8601;
+ private $specials = array(
+ 'ISO8601' => self::DATE_FORMAT_ISO8601,
+ 'ABSOLUTE' => self::DATE_FORMAT_ABSOLUTE,
+ 'DATE' => self::DATE_FORMAT_DATE,
+ );
- private $specials = array(
- 'ISO8601' => self::DATE_FORMAT_ISO8601,
- 'ABSOLUTE' => self::DATE_FORMAT_ABSOLUTE,
- 'DATE' => self::DATE_FORMAT_DATE,
- );
+ private $useLocalDate = false;
- private $useLocalDate = false;
+ public function activateOptions()
+ {
+ // Parse the option (date format)
+ if (!empty($this->option)) {
+ if (isset($this->specials[$this->option])) {
+ $this->format = $this->specials[$this->option];
+ } else {
+ $this->format = $this->option;
+ }
+ }
- public function activateOptions() {
+ // Check whether the pattern contains milliseconds (u)
+ if (preg_match('/(?<!\\\\)u/', $this->format)) {
+ $this->useLocalDate = true;
+ }
+ }
- // Parse the option (date format)
- if (!empty($this->option)) {
- if(isset($this->specials[$this->option])) {
- $this->format = $this->specials[$this->option];
- } else {
- $this->format = $this->option;
- }
- }
+ public function convert(LoggingEvent $event)
+ {
+ if ($this->useLocalDate) {
+ return $this->date($this->format, $event->getTimeStamp());
+ }
- // Check whether the pattern contains milliseconds (u)
- if (preg_match('/(?<!\\\\)u/', $this->format)) {
- $this->useLocalDate = true;
- }
- }
+ return date($this->format, $event->getTimeStamp());
+ }
- public function convert(LoggingEvent $event) {
- if ($this->useLocalDate) {
- return $this->date($this->format, $event->getTimeStamp());
- }
- return date($this->format, $event->getTimeStamp());
- }
+ /**
+ * Currently, PHP date() function always returns zeros for milliseconds (u)
+ * on Windows. This is a replacement function for date() which correctly
+ * displays milliseconds on all platforms.
+ *
+ * It is slower than PHP date() so it should only be used if necessary.
+ */
+ private function date($format, $utimestamp)
+ {
+ $timestamp = floor($utimestamp);
+ $ms = floor(($utimestamp - $timestamp) * 1000);
+ $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
- /**
- * Currently, PHP date() function always returns zeros for milliseconds (u)
- * on Windows. This is a replacement function for date() which correctly
- * displays milliseconds on all platforms.
- *
- * It is slower than PHP date() so it should only be used if necessary.
- */
- private function date($format, $utimestamp) {
- $timestamp = floor($utimestamp);
- $ms = floor(($utimestamp - $timestamp) * 1000);
- $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
-
- return date(preg_replace('`(?<!\\\\)u`', $ms, $format), $timestamp);
- }
+ return date(preg_replace('`(?<!\\\\)u`', $ms, $format), $timestamp);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/EnvironmentConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/EnvironmentConverter.php b/src/Pattern/EnvironmentConverter.php
index 7be0272..6d1afa7 100644
--- a/src/Pattern/EnvironmentConverter.php
+++ b/src/Pattern/EnvironmentConverter.php
@@ -28,6 +28,7 @@ namespace Apache\Log4php\Pattern;
*
* @since 2.3
*/
-class EnvironmentConverter extends SuperglobalConverter {
- protected $name = '_ENV';
+class EnvironmentConverter extends SuperglobalConverter
+{
+ protected $name = '_ENV';
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/FileConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/FileConverter.php b/src/Pattern/FileConverter.php
index 809192d..15ce1ba 100644
--- a/src/Pattern/FileConverter.php
+++ b/src/Pattern/FileConverter.php
@@ -24,9 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns the name of the file from which the logging request was issued.
* @since 2.3
*/
-class FileConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return $event->getLocationInformation()->getFileName();
- }
+class FileConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return $event->getLocationInformation()->getFileName();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/LevelConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LevelConverter.php b/src/Pattern/LevelConverter.php
index 3b42fe0..dabd5c3 100644
--- a/src/Pattern/LevelConverter.php
+++ b/src/Pattern/LevelConverter.php
@@ -24,9 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns the event's level.
* @since 2.3
*/
-class LevelConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return $event->getLevel()->toString();
- }
+class LevelConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return $event->getLevel()->toString();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/LineConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LineConverter.php b/src/Pattern/LineConverter.php
index 659fa11..6a47e2e 100644
--- a/src/Pattern/LineConverter.php
+++ b/src/Pattern/LineConverter.php
@@ -25,9 +25,10 @@ use Apache\Log4php\LoggingEvent;
* issued.
* @since 2.3
*/
-class LineConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return $event->getLocationInformation()->getLineNumber();
- }
+class LineConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return $event->getLocationInformation()->getLineNumber();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/LiteralConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LiteralConverter.php b/src/Pattern/LiteralConverter.php
index 089fa7f..061aed5 100644
--- a/src/Pattern/LiteralConverter.php
+++ b/src/Pattern/LiteralConverter.php
@@ -24,15 +24,17 @@ use Apache\Log4php\LoggingEvent;
* Returns the literal value passed in the constructor, without modifications.
* @since 2.3
*/
-class LiteralConverter extends AbstractConverter {
+class LiteralConverter extends AbstractConverter
+{
+ private $literalValue;
- private $literalValue;
+ public function __construct($literalValue)
+ {
+ $this->literalValue = $literalValue;
+ }
- public function __construct($literalValue) {
- $this->literalValue = $literalValue;
- }
-
- public function convert(LoggingEvent $event) {
- return $this->literalValue;
- }
+ public function convert(LoggingEvent $event)
+ {
+ return $this->literalValue;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/LocationConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LocationConverter.php b/src/Pattern/LocationConverter.php
index 4334ec7..c100807 100644
--- a/src/Pattern/LocationConverter.php
+++ b/src/Pattern/LocationConverter.php
@@ -25,13 +25,14 @@ use Apache\Log4php\LoggingEvent;
* issued.
* @since 2.3
*/
-class LocationConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return
- $event->getLocationInformation()->getClassName() . '.' .
- $event->getLocationInformation()->getMethodName() . '(' .
- $event->getLocationInformation()->getFileName() . ':' .
- $event->getLocationInformation()->getLineNumber() . ')';
- }
+class LocationConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return
+ $event->getLocationInformation()->getClassName() . '.' .
+ $event->getLocationInformation()->getMethodName() . '(' .
+ $event->getLocationInformation()->getFileName() . ':' .
+ $event->getLocationInformation()->getLineNumber() . ')';
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/LoggerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LoggerConverter.php b/src/Pattern/LoggerConverter.php
index 0433659..7c419ac 100644
--- a/src/Pattern/LoggerConverter.php
+++ b/src/Pattern/LoggerConverter.php
@@ -28,37 +28,39 @@ use Apache\Log4php\LoggingEvent;
* name will be shortened to the given length, if possible.
* @since 2.3
*/
-class LoggerConverter extends AbstractConverter {
+class LoggerConverter extends AbstractConverter
+{
+ /** Length to which to shorten the name. */
+ private $length;
- /** Length to which to shorten the name. */
- private $length;
+ /** Holds processed logger names. */
+ private $cache = array();
- /** Holds processed logger names. */
- private $cache = array();
+ public function activateOptions()
+ {
+ // Parse the option (desired output length)
+ if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
+ $this->length = (integer) $this->option;
+ }
+ }
- public function activateOptions() {
- // Parse the option (desired output length)
- if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
- $this->length = (integer) $this->option;
- }
- }
+ public function convert(LoggingEvent $event)
+ {
+ $name = $event->getLoggerName();
- public function convert(LoggingEvent $event) {
- $name = $event->getLoggerName();
+ if (!isset($this->cache[$name])) {
- if (!isset($this->cache[$name])) {
+ // If length is set return shortened logger name
+ if (isset($this->length)) {
+ $this->cache[$name] = Utils::shortenClassName($name, $this->length);
+ }
- // If length is set return shortened logger name
- if (isset($this->length)) {
- $this->cache[$name] = Utils::shortenClassName($name, $this->length);
- }
+ // If no length is specified return full logger name
+ else {
+ $this->cache[$name] = $name;
+ }
+ }
- // If no length is specified return full logger name
- else {
- $this->cache[$name] = $name;
- }
- }
-
- return $this->cache[$name];
- }
+ return $this->cache[$name];
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/MdcConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MdcConverter.php b/src/Pattern/MdcConverter.php
index cb50c8e..6739694 100644
--- a/src/Pattern/MdcConverter.php
+++ b/src/Pattern/MdcConverter.php
@@ -27,26 +27,29 @@ use Apache\Log4php\LoggingEvent;
* [0] the MDC key
* @since 2.3
*/
-class MdcConverter extends AbstractConverter {
+class MdcConverter extends AbstractConverter
+{
+ private $key;
- private $key;
+ public function activateOptions()
+ {
+ if (isset($this->option) && $this->option !== '') {
+ $this->key = $this->option;
+ }
+ }
- public function activateOptions() {
- if (isset($this->option) && $this->option !== '') {
- $this->key = $this->option;
- }
- }
+ public function convert(LoggingEvent $event)
+ {
+ if (isset($this->key)) {
+ return $event->getMDC($this->key);
+ } else {
+ $buff = array();
+ $map = $event->getMDCMap();
+ foreach ($map as $key => $value) {
+ $buff []= "$key=$value";
+ }
- public function convert(LoggingEvent $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);
- }
- }
+ return implode(', ', $buff);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/MessageConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MessageConverter.php b/src/Pattern/MessageConverter.php
index acd53d8..de9004d 100644
--- a/src/Pattern/MessageConverter.php
+++ b/src/Pattern/MessageConverter.php
@@ -24,9 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns the logged message.
* @since 2.3
*/
-class MessageConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return $event->getRenderedMessage();
- }
+class MessageConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return $event->getRenderedMessage();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/MethodConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/MethodConverter.php b/src/Pattern/MethodConverter.php
index d0c29e8..523693b 100644
--- a/src/Pattern/MethodConverter.php
+++ b/src/Pattern/MethodConverter.php
@@ -25,9 +25,10 @@ use Apache\Log4php\LoggingEvent;
* was issued.
* @since 2.3
*/
-class MethodConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return $event->getLocationInformation()->getMethodName();
- }
+class MethodConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return $event->getLocationInformation()->getMethodName();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/NdcConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/NdcConverter.php b/src/Pattern/NdcConverter.php
index fb0027e..12255a4 100644
--- a/src/Pattern/NdcConverter.php
+++ b/src/Pattern/NdcConverter.php
@@ -24,9 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns the full Nested Diagnostic Context.
* @since 2.3
*/
-class NdcConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return $event->getNDC();
- }
+class NdcConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return $event->getNDC();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/NewLineConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/NewLineConverter.php b/src/Pattern/NewLineConverter.php
index 2e3f7e6..8754952 100644
--- a/src/Pattern/NewLineConverter.php
+++ b/src/Pattern/NewLineConverter.php
@@ -24,9 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns platform-specific newline character(s).
* @since 2.3
*/
-class NewLineConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return PHP_EOL;
- }
+class NewLineConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return PHP_EOL;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/ProcessConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ProcessConverter.php b/src/Pattern/ProcessConverter.php
index 4ba2151..e0d87f3 100644
--- a/src/Pattern/ProcessConverter.php
+++ b/src/Pattern/ProcessConverter.php
@@ -24,9 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns the PID of the current process.
* @since 2.3
*/
-class ProcessConverter extends AbstractConverter {
-
- public function convert(LoggingEvent $event) {
- return getmypid();
- }
+class ProcessConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return getmypid();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/RelativeConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/RelativeConverter.php b/src/Pattern/RelativeConverter.php
index d6e3111..02fe940 100644
--- a/src/Pattern/RelativeConverter.php
+++ b/src/Pattern/RelativeConverter.php
@@ -25,10 +25,12 @@ use Apache\Log4php\LoggingEvent;
* application until the creation of the logging event.
* @since 2.3
*/
-class RelativeConverter extends AbstractConverter {
+class RelativeConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ $ts = $event->getRelativeTime();
- public function convert(LoggingEvent $event) {
- $ts = $event->getRelativeTime();
- return number_format($ts, 4);
- }
+ return number_format($ts, 4);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/RequestConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/RequestConverter.php b/src/Pattern/RequestConverter.php
index 5440e75..9c72c33 100644
--- a/src/Pattern/RequestConverter.php
+++ b/src/Pattern/RequestConverter.php
@@ -18,8 +18,6 @@
namespace Apache\Log4php\Pattern;
-use Apache\Log4php\LoggingEvent;
-
/**
* Returns a value from the $_REQUEST superglobal array corresponding to the
* given key.
@@ -30,6 +28,7 @@ use Apache\Log4php\LoggingEvent;
*
* @since 2.3
*/
-class RequestConverter extends SuperglobalConverter {
- protected $name = '_REQUEST';
-}
\ No newline at end of file
+class RequestConverter extends SuperglobalConverter
+{
+ protected $name = '_REQUEST';
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/ServerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ServerConverter.php b/src/Pattern/ServerConverter.php
index c6085ce..0ed7d5a 100644
--- a/src/Pattern/ServerConverter.php
+++ b/src/Pattern/ServerConverter.php
@@ -18,8 +18,6 @@
namespace Apache\Log4php\Pattern;
-use Apache\Log4php\LoggingEvent;
-
/**
* Returns a value from the $_SERVER superglobal array corresponding to the
* given key.
@@ -30,6 +28,7 @@ use Apache\Log4php\LoggingEvent;
*
* @since 2.3
*/
-class ServerConverter extends SuperglobalConverter {
- protected $name = '_SERVER';
+class ServerConverter extends SuperglobalConverter
+{
+ protected $name = '_SERVER';
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/SessionConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SessionConverter.php b/src/Pattern/SessionConverter.php
index c5d812b..52343de 100644
--- a/src/Pattern/SessionConverter.php
+++ b/src/Pattern/SessionConverter.php
@@ -18,8 +18,6 @@
namespace Apache\Log4php\Pattern;
-use Apache\Log4php\LoggingEvent;
-
/**
* Returns a value from the $_SESSION superglobal array corresponding to the
* given key.
@@ -30,6 +28,7 @@ use Apache\Log4php\LoggingEvent;
*
* @since 2.3
*/
-class SessionConverter extends SuperglobalConverter {
- protected $name = '_SESSION';
+class SessionConverter extends SuperglobalConverter
+{
+ protected $name = '_SESSION';
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/SessionIdConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SessionIdConverter.php b/src/Pattern/SessionIdConverter.php
index c5d622c..23324c4 100644
--- a/src/Pattern/SessionIdConverter.php
+++ b/src/Pattern/SessionIdConverter.php
@@ -24,8 +24,10 @@ use Apache\Log4php\LoggingEvent;
* Returns the active session ID, or an empty string if out of session.
* @since 2.3
*/
-class SessionIdConverter extends AbstractConverter {
- public function convert(LoggingEvent $event) {
- return session_id();
- }
+class SessionIdConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ return session_id();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/SuperglobalConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SuperglobalConverter.php b/src/Pattern/SuperglobalConverter.php
index c43d0c0..7befa67 100644
--- a/src/Pattern/SuperglobalConverter.php
+++ b/src/Pattern/SuperglobalConverter.php
@@ -34,67 +34,70 @@ use Apache\Log4php\LoggingEvent;
* @see http://www.php.net/manual/en/ini.core.php#ini.variables-order
* @since 2.3
*/
-abstract class SuperglobalConverter extends AbstractConverter {
+abstract class SuperglobalConverter extends AbstractConverter
+{
+ /**
+ * Name of the superglobal variable, to be defined by subclasses.
+ * For example: "_SERVER" or "_ENV".
+ */
+ protected $name;
- /**
- * Name of the superglobal variable, to be defined by subclasses.
- * For example: "_SERVER" or "_ENV".
- */
- protected $name;
+ protected $value = '';
- protected $value = '';
+ public function activateOptions()
+ {
+ // Read the key from options array
+ if (isset($this->option) && $this->option !== '') {
+ $key = $this->option;
+ }
- public function activateOptions() {
- // Read the key from options array
- if (isset($this->option) && $this->option !== '') {
- $key = $this->option;
- }
+ /*
+ * There is a bug in PHP which doesn't allow superglobals to be
+ * accessed when their name is stored in a variable, e.g.:
+ *
+ * $name = '_SERVER';
+ * $array = $$name;
+ *
+ * This code does not work when run from within a method (only when run
+ * in global scope). But the following code does work:
+ *
+ * $name = '_SERVER';
+ * global $$name;
+ * $array = $$name;
+ *
+ * That's why global is used here.
+ */
+ global ${$this->name};
- /*
- * There is a bug in PHP which doesn't allow superglobals to be
- * accessed when their name is stored in a variable, e.g.:
- *
- * $name = '_SERVER';
- * $array = $$name;
- *
- * This code does not work when run from within a method (only when run
- * in global scope). But the following code does work:
- *
- * $name = '_SERVER';
- * global $$name;
- * $array = $$name;
- *
- * That's why global is used here.
- */
- global ${$this->name};
+ // Check the given superglobal exists. It is possible that it is not initialized.
+ if (!isset(${$this->name})) {
+ $class = basename(get_class($this));
+ trigger_error("log4php: $class: Cannot find superglobal variable \${$this->name}.", E_USER_WARNING);
- // Check the given superglobal exists. It is possible that it is not initialized.
- if (!isset(${$this->name})) {
- $class = basename(get_class($this));
- trigger_error("log4php: $class: Cannot find superglobal variable \${$this->name}.", E_USER_WARNING);
- return;
- }
+ return;
+ }
- $source = ${$this->name};
+ $source = ${$this->name};
- // When the key is set, display the matching value
- if (isset($key)) {
- if (isset($source[$key])) {
- $this->value = $source[$key];
- }
- }
+ // When the key is set, display the matching value
+ if (isset($key)) {
+ if (isset($source[$key])) {
+ $this->value = $source[$key];
+ }
+ }
- // When the key is not set, display all values
- else {
- $values = array();
- foreach($source as $key => $value) {
- $values[] = "$key=$value";
- }
- $this->value = implode(', ', $values);
- }
- }
+ // When the key is not set, display all values
+ else {
+ $values = array();
+ foreach ($source as $key => $value) {
+ $values[] = "$key=$value";
+ }
+ $this->value = implode(', ', $values);
+ }
+ }
- public function convert(LoggingEvent $event) {
- return $this->value;
- }
+ public function convert(LoggingEvent $event)
+ {
+ return $this->value;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Pattern/ThrowableConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ThrowableConverter.php b/src/Pattern/ThrowableConverter.php
index f18e322..8f12a84 100644
--- a/src/Pattern/ThrowableConverter.php
+++ b/src/Pattern/ThrowableConverter.php
@@ -22,14 +22,17 @@ namespace Apache\Log4php\Pattern;
* Returns the throwable information linked to the logging event, if any.
* @since 2.3
*/
-class ThrowableConverter extends AbstractConverter {
+class ThrowableConverter extends AbstractConverter
+{
+ public function convert(LoggingEvent $event)
+ {
+ $info = $event->getThrowableInformation();
+ if (isset($info)) {
+ $ex = $info->getThrowable();
- public function convert(LoggingEvent $event) {
- $info = $event->getThrowableInformation();
- if (isset($info)) {
- $ex = $info->getThrowable();
- return (string) $ex . PHP_EOL;
- }
- return '';
- }
+ return (string) $ex . PHP_EOL;
+ }
+
+ return '';
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/ReflectionUtils.php
----------------------------------------------------------------------
diff --git a/src/ReflectionUtils.php b/src/ReflectionUtils.php
index cc39ec3..38793fd 100644
--- a/src/ReflectionUtils.php
+++ b/src/ReflectionUtils.php
@@ -21,131 +21,140 @@ namespace Apache\Log4php;
/**
* Provides methods for reflective use on php objects
*/
-class ReflectionUtils {
+class ReflectionUtils
+{
+ /** the target object */
+ private $obj;
- /** the target object */
- private $obj;
+ /**
+ * Create a new ReflectionUtils for the specified Object.
+ * This is done in prepartion for invoking {@link setProperty()}
+ * one or more times.
+ * @param object &$obj the object for which to set properties
+ */
+ public function __construct($obj)
+ {
+ $this->obj = $obj;
+ }
- /**
- * Create a new ReflectionUtils for the specified Object.
- * This is done in prepartion for invoking {@link setProperty()}
- * one or more times.
- * @param object &$obj the object for which to set properties
- */
- public function __construct($obj) {
- $this->obj = $obj;
- }
+ /**
+ * Set the properties of an object passed as a parameter in one
+ * go. The <code>properties</code> are parsed relative to a
+ * <code>prefix</code>.
+ *
+ * @param object $obj The object to configure.
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ */
+ // TODO: check, if this is really useful
+ public static function setPropertiesByObject($obj, $properties, $prefix)
+ {
+ $pSetter = new ReflectionUtils($obj);
- /**
- * Set the properties of an object passed as a parameter in one
- * go. The <code>properties</code> are parsed relative to a
- * <code>prefix</code>.
- *
- * @param object $obj The object to configure.
- * @param array $properties An array containing keys and values.
- * @param string $prefix Only keys having the specified prefix will be set.
- */
- // TODO: check, if this is really useful
- public static function setPropertiesByObject($obj, $properties, $prefix) {
- $pSetter = new ReflectionUtils($obj);
- return $pSetter->setProperties($properties, $prefix);
- }
+ return $pSetter->setProperties($properties, $prefix);
+ }
- /**
- * Set the properites for the object that match the
- * <code>prefix</code> passed as parameter.
- *
- * Example:
- *
- * $arr['xxxname'] = 'Joe';
- * $arr['xxxmale'] = true;
- * and prefix xxx causes setName and setMale.
- *
- * @param array $properties An array containing keys and values.
- * @param string $prefix Only keys having the specified prefix will be set.
- */
- public function setProperties($properties, $prefix) {
- $len = strlen($prefix);
- reset($properties);
- while(list($key,) = each($properties)) {
- if(strpos($key, $prefix) === 0) {
- if(strpos($key, '.', ($len + 1)) > 0) {
- continue;
- }
- $value = $properties[$key];
- $key = substr($key, $len);
- if($key == 'layout' and ($this->obj instanceof Appender)) {
- continue;
- }
- $this->setProperty($key, $value);
- }
- }
- $this->activate();
- }
+ /**
+ * Set the properites for the object that match the
+ * <code>prefix</code> passed as parameter.
+ *
+ * Example:
+ *
+ * $arr['xxxname'] = 'Joe';
+ * $arr['xxxmale'] = true;
+ * and prefix xxx causes setName and setMale.
+ *
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ */
+ public function setProperties($properties, $prefix)
+ {
+ $len = strlen($prefix);
+ reset($properties);
+ while (list($key,) = each($properties)) {
+ if (strpos($key, $prefix) === 0) {
+ if (strpos($key, '.', ($len + 1)) > 0) {
+ continue;
+ }
+ $value = $properties[$key];
+ $key = substr($key, $len);
+ if ($key == 'layout' and ($this->obj instanceof Appender)) {
+ continue;
+ }
+ $this->setProperty($key, $value);
+ }
+ }
+ $this->activate();
+ }
- /**
- * Set a property on this PropertySetter's Object. If successful, this
- * method will invoke a setter method on the underlying Object. The
- * setter is the one for the specified property name and the value is
- * determined partly from the setter argument type and partly from the
- * value specified in the call to this method.
- *
- * <p>If the setter expects a String no conversion is necessary.
- * If it expects an int, then an attempt is made to convert 'value'
- * to an int using new Integer(value). If the setter expects a boolean,
- * the conversion is by new Boolean(value).
- *
- * @param string $name name of the property
- * @param string $value String value of the property
- */
- public function setProperty($name, $value) {
- if($value === null) {
- return;
- }
+ /**
+ * Set a property on this PropertySetter's Object. If successful, this
+ * method will invoke a setter method on the underlying Object. The
+ * setter is the one for the specified property name and the value is
+ * determined partly from the setter argument type and partly from the
+ * value specified in the call to this method.
+ *
+ * <p>If the setter expects a String no conversion is necessary.
+ * If it expects an int, then an attempt is made to convert 'value'
+ * to an int using new Integer(value). If the setter expects a boolean,
+ * the conversion is by new Boolean(value).
+ *
+ * @param string $name name of the property
+ * @param string $value String value of the property
+ */
+ public function setProperty($name, $value)
+ {
+ if ($value === null) {
+ return;
+ }
- $method = "set" . ucfirst($name);
+ $method = "set" . ucfirst($name);
- if(!method_exists($this->obj, $method)) {
- throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
- } else {
- return call_user_func(array($this->obj, $method), $value);
- }
- }
+ if (!method_exists($this->obj, $method)) {
+ throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
+ } else {
+ return call_user_func(array($this->obj, $method), $value);
+ }
+ }
- public function activate() {
- if(method_exists($this->obj, 'activateoptions')) {
- return call_user_func(array($this->obj, 'activateoptions'));
- }
- }
+ public function activate()
+ {
+ if (method_exists($this->obj, 'activateoptions')) {
+ return call_user_func(array($this->obj, 'activateoptions'));
+ }
+ }
- /**
- * Creates an instances from the given class name.
- *
- * @param string $classname
- * @return an object from the class with the given classname
- */
- public static function createObject($class) {
- if(!empty($class)) {
- return new $class();
- }
- return null;
- }
+ /**
+ * Creates an instances from the given class name.
+ *
+ * @param string $classname
+ * @return an object from the class with the given classname
+ */
+ public static function createObject($class)
+ {
+ if (!empty($class)) {
+ return new $class();
+ }
- /**
- * @param object $object
- * @param string $name
- * @param mixed $value
- */
- public static function setter($object, $name, $value) {
- if (empty($name)) {
- return false;
- }
- $methodName = 'set'.ucfirst($name);
- if (method_exists($object, $methodName)) {
- return call_user_func(array($object, $methodName), $value);
- } else {
- return false;
- }
- }
+ return null;
+ }
+
+ /**
+ * @param object $object
+ * @param string $name
+ * @param mixed $value
+ */
+ public static function setter($object, $name, $value)
+ {
+ if (empty($name)) {
+ return false;
+ }
+ $methodName = 'set'.ucfirst($name);
+ if (method_exists($object, $methodName)) {
+ return call_user_func(array($object, $methodName), $value);
+ } else {
+ return false;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Renderers/DefaultRenderer.php
----------------------------------------------------------------------
diff --git a/src/Renderers/DefaultRenderer.php b/src/Renderers/DefaultRenderer.php
index 78b844c..6d1a2be 100644
--- a/src/Renderers/DefaultRenderer.php
+++ b/src/Renderers/DefaultRenderer.php
@@ -24,10 +24,11 @@ namespace Apache\Log4php\Renderers;
* Renders the input using <var>print_r</var>.
* @since 0.3
*/
-class DefaultRenderer implements RendererInterface {
-
- /** @inheritdoc */
- public function render($input) {
- return print_r($input, true);
- }
+class DefaultRenderer implements RendererInterface
+{
+ /** @inheritdoc */
+ public function render($input)
+ {
+ return print_r($input, true);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Renderers/ExceptionRenderer.php
----------------------------------------------------------------------
diff --git a/src/Renderers/ExceptionRenderer.php b/src/Renderers/ExceptionRenderer.php
index d625ae8..ad9b09f 100644
--- a/src/Renderers/ExceptionRenderer.php
+++ b/src/Renderers/ExceptionRenderer.php
@@ -22,12 +22,12 @@ namespace Apache\Log4php\Renderers;
* Renderer used for Exceptions.
* @since 2.1
*/
-class ExceptionRenderer implements RendererInterface {
-
- public function render($input) {
-
- // Exception class has a very decent __toString method
- // so let's just use that instead of writing lots of code.
- return (string) $input;
- }
+class ExceptionRenderer implements RendererInterface
+{
+ public function render($input)
+ {
+ // Exception class has a very decent __toString method
+ // so let's just use that instead of writing lots of code.
+ return (string) $input;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Renderers/RendererInterface.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererInterface.php b/src/Renderers/RendererInterface.php
index 8bfda22..ad96b85 100644
--- a/src/Renderers/RendererInterface.php
+++ b/src/Renderers/RendererInterface.php
@@ -22,11 +22,12 @@ namespace Apache\Log4php\Renderers;
* Implement this interface in order to render objects to strings.
* @since 0.3
*/
-interface RendererInterface {
- /**
- * Renders the entity passed as <var>input</var> to a string.
- * @param mixed $input The entity to render.
- * @return string The rendered string.
- */
- public function render($input);
+interface RendererInterface
+{
+ /**
+ * Renders the entity passed as <var>input</var> to a string.
+ * @param mixed $input The entity to render.
+ * @return string The rendered string.
+ */
+ public function render($input);
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Renderers/RendererMap.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererMap.php b/src/Renderers/RendererMap.php
index 1444d25..1165720 100644
--- a/src/Renderers/RendererMap.php
+++ b/src/Renderers/RendererMap.php
@@ -23,167 +23,180 @@ namespace Apache\Log4php\Renderers;
* input.
* @since 0.3
*/
-class RendererMap {
-
- /**
- * Maps class names to appropriate renderers.
- * @var array
- */
- private $map = array();
-
- /**
- * The default renderer to use if no specific renderer is found.
- * @var RendererInterface
- */
- private $defaultRenderer;
-
- public function __construct() {
-
- // Set default config
- $this->reset();
- }
-
- /**
- * Adds a renderer to the map.
- *
- * If a renderer already exists for the given <var>$renderedClass</var> it
- * will be overwritten without warning.
- *
- * @param string $renderedClass The name of the class which will be
- * rendered by the renderer.
- * @param string $renderingClass The name of the class which will
- * perform the rendering.
- */
- public function addRenderer($renderedClass, $renderingClass) {
-
- if (class_exists($renderingClass)) {
- $renderer = new $renderingClass();
- } else {
- // Try to find renderer in the default namespace
- $namespaced = "Apache\\Log4php\\Renderers\\$renderingClass";
- if (class_exists($namespaced)) {
- $renderer = new $namespaced();
- }
- }
-
- if (!isset($renderer)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
- return;
- }
-
- // Check the class implements the right interface
- if (!($renderer instanceof RendererInterface)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
- return;
- }
-
- // Convert to lowercase since class names in PHP are not case sensitive
- $renderedClass = strtolower($renderedClass);
-
- $this->map[$renderedClass] = $renderer;
- }
-
- /**
- * Sets a custom default renderer class.
- *
- * TODO: there's code duplication here. This method is almost identical to
- * addRenderer(). However, it has custom error messages so let it sit for
- * now.
- *
- * @param string $renderingClass The name of the class which will
- * perform the rendering.
- */
- public function setDefaultRenderer($renderingClass) {
- // Check the class exists
- if (!class_exists($renderingClass)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
- return;
- }
-
- // Create the instance
- $renderer = new $renderingClass();
-
- // Check the class implements the right interface
- if (!($renderer instanceof RendererInterface)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
- return;
- }
-
- $this->defaultRenderer = $renderer;
- }
-
- /**
- * Returns the default renderer.
- * @var RendererInterface
- */
- public function getDefaultRenderer() {
- return $this->defaultRenderer;
- }
-
- /**
- * Finds the appropriate renderer for the given <var>input</var>, and
- * renders it (i.e. converts it to a string).
- *
- * @param mixed $input Input to render.
- * @return string The rendered contents.
- */
- public function findAndRender($input) {
- if ($input === null) {
- return null;
- }
-
- // For objects, try to find a renderer in the map
- if(is_object($input)) {
- $renderer = $this->getByClassName(get_class($input));
- if (isset($renderer)) {
- return $renderer->render($input);
- }
- }
-
- // Fall back to the default renderer
- return $this->defaultRenderer->render($input);
- }
-
- /**
- * Returns the appropriate renderer for a given object.
- *
- * @param mixed $object
- * @return RendererInterface Or null if none found.
- */
- public function getByObject($object) {
- if (!is_object($object)) {
- return null;
- }
- return $this->getByClassName(get_class($object));
- }
-
- /**
- * Returns the appropriate renderer for a given class name.
- *
- * If no renderer could be found, returns NULL.
- *
- * @param string $class
- * @return LoggerRendererObject Or null if not found.
- */
- public function getByClassName($class) {
- for(; !empty($class); $class = get_parent_class($class)) {
- $class = strtolower($class);
- if(isset($this->map[$class])) {
- return $this->map[$class];
- }
- }
- return null;
- }
-
- /** Empties the renderer map. */
- public function clear() {
- $this->map = array();
- }
-
- /** Resets the renderer map to it's default configuration. */
- public function reset() {
- $this->defaultRenderer = new DefaultRenderer();
- $this->clear();
- $this->addRenderer('Exception', 'ExceptionRenderer');
- }
+class RendererMap
+{
+ /**
+ * Maps class names to appropriate renderers.
+ * @var array
+ */
+ private $map = array();
+
+ /**
+ * The default renderer to use if no specific renderer is found.
+ * @var RendererInterface
+ */
+ private $defaultRenderer;
+
+ public function __construct()
+ {
+ // Set default config
+ $this->reset();
+ }
+
+ /**
+ * Adds a renderer to the map.
+ *
+ * If a renderer already exists for the given <var>$renderedClass</var> it
+ * will be overwritten without warning.
+ *
+ * @param string $renderedClass The name of the class which will be
+ * rendered by the renderer.
+ * @param string $renderingClass The name of the class which will
+ * perform the rendering.
+ */
+ public function addRenderer($renderedClass, $renderingClass)
+ {
+ if (class_exists($renderingClass)) {
+ $renderer = new $renderingClass();
+ } else {
+ // Try to find renderer in the default namespace
+ $namespaced = "Apache\\Log4php\\Renderers\\$renderingClass";
+ if (class_exists($namespaced)) {
+ $renderer = new $namespaced();
+ }
+ }
+
+ if (!isset($renderer)) {
+ trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
+
+ return;
+ }
+
+ // Check the class implements the right interface
+ if (!($renderer instanceof RendererInterface)) {
+ trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
+
+ return;
+ }
+
+ // Convert to lowercase since class names in PHP are not case sensitive
+ $renderedClass = strtolower($renderedClass);
+
+ $this->map[$renderedClass] = $renderer;
+ }
+
+ /**
+ * Sets a custom default renderer class.
+ *
+ * TODO: there's code duplication here. This method is almost identical to
+ * addRenderer(). However, it has custom error messages so let it sit for
+ * now.
+ *
+ * @param string $renderingClass The name of the class which will
+ * perform the rendering.
+ */
+ public function setDefaultRenderer($renderingClass)
+ {
+ // Check the class exists
+ if (!class_exists($renderingClass)) {
+ trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
+
+ return;
+ }
+
+ // Create the instance
+ $renderer = new $renderingClass();
+
+ // Check the class implements the right interface
+ if (!($renderer instanceof RendererInterface)) {
+ trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.");
+
+ return;
+ }
+
+ $this->defaultRenderer = $renderer;
+ }
+
+ /**
+ * Returns the default renderer.
+ * @var RendererInterface
+ */
+ public function getDefaultRenderer()
+ {
+ return $this->defaultRenderer;
+ }
+
+ /**
+ * Finds the appropriate renderer for the given <var>input</var>, and
+ * renders it (i.e. converts it to a string).
+ *
+ * @param mixed $input Input to render.
+ * @return string The rendered contents.
+ */
+ public function findAndRender($input)
+ {
+ if ($input === null) {
+ return null;
+ }
+
+ // For objects, try to find a renderer in the map
+ if (is_object($input)) {
+ $renderer = $this->getByClassName(get_class($input));
+ if (isset($renderer)) {
+ return $renderer->render($input);
+ }
+ }
+
+ // Fall back to the default renderer
+ return $this->defaultRenderer->render($input);
+ }
+
+ /**
+ * Returns the appropriate renderer for a given object.
+ *
+ * @param mixed $object
+ * @return RendererInterface Or null if none found.
+ */
+ public function getByObject($object)
+ {
+ if (!is_object($object)) {
+ return null;
+ }
+
+ return $this->getByClassName(get_class($object));
+ }
+
+ /**
+ * Returns the appropriate renderer for a given class name.
+ *
+ * If no renderer could be found, returns NULL.
+ *
+ * @param string $class
+ * @return LoggerRendererObject Or null if not found.
+ */
+ public function getByClassName($class)
+ {
+ for (; !empty($class); $class = get_parent_class($class)) {
+ $class = strtolower($class);
+ if (isset($this->map[$class])) {
+ return $this->map[$class];
+ }
+ }
+
+ return null;
+ }
+
+ /** Empties the renderer map. */
+ public function clear()
+ {
+ $this->map = array();
+ }
+
+ /** Resets the renderer map to it's default configuration. */
+ public function reset()
+ {
+ $this->defaultRenderer = new DefaultRenderer();
+ $this->clear();
+ $this->addRenderer('Exception', 'ExceptionRenderer');
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/RootLogger.php
----------------------------------------------------------------------
diff --git a/src/RootLogger.php b/src/RootLogger.php
index ba7f5c3..bd9b089 100644
--- a/src/RootLogger.php
+++ b/src/RootLogger.php
@@ -24,46 +24,50 @@ namespace Apache\Log4php;
*/
class RootLogger extends Logger
{
- /**
- * Constructor
- *
- * @param integer $level initial log level
- */
- public function __construct(Level $level = null) {
- parent::__construct('root');
+ /**
+ * Constructor
+ *
+ * @param integer $level initial log level
+ */
+ public function __construct(Level $level = null)
+ {
+ parent::__construct('root');
- if($level == null) {
- $level = Level::getLevelAll();
- }
- $this->setLevel($level);
- }
+ if ($level == null) {
+ $level = Level::getLevelAll();
+ }
+ $this->setLevel($level);
+ }
- /**
- * @return Level the level
- */
- public function getEffectiveLevel() {
- return $this->getLevel();
- }
+ /**
+ * @return Level the level
+ */
+ public function getEffectiveLevel()
+ {
+ return $this->getLevel();
+ }
- /**
- * Override level setter to prevent setting the root logger's level to
- * null. Root logger must always have a level.
- *
- * @param Level $level
- */
- public function setLevel(Level $level = null) {
- if (isset($level)) {
- parent::setLevel($level);
- } else {
- trigger_error("log4php: Cannot set RootLogger level to null.", E_USER_WARNING);
- }
- }
+ /**
+ * Override level setter to prevent setting the root logger's level to
+ * null. Root logger must always have a level.
+ *
+ * @param Level $level
+ */
+ public function setLevel(Level $level = null)
+ {
+ if (isset($level)) {
+ parent::setLevel($level);
+ } else {
+ trigger_error("log4php: Cannot set RootLogger level to null.", E_USER_WARNING);
+ }
+ }
- /**
- * Override parent setter. Root logger cannot have a parent.
- * @param Logger $parent
- */
- public function setParent(Logger $parent) {
- trigger_error("log4php: RootLogger cannot have a parent.", E_USER_WARNING);
- }
+ /**
+ * Override parent setter. Root logger cannot have a parent.
+ * @param Logger $parent
+ */
+ public function setParent(Logger $parent)
+ {
+ trigger_error("log4php: RootLogger cannot have a parent.", E_USER_WARNING);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/ThrowableInformation.php
----------------------------------------------------------------------
diff --git a/src/ThrowableInformation.php b/src/ThrowableInformation.php
index e2befeb..255c0b8 100644
--- a/src/ThrowableInformation.php
+++ b/src/ThrowableInformation.php
@@ -25,43 +25,46 @@ namespace Apache\Log4php;
*/
class ThrowableInformation
{
- /** @var Exception Throwable to log */
- private $throwable;
+ /** @var Exception Throwable to log */
+ private $throwable;
- /** @var array Array of throwable messages */
- private $throwableArray;
+ /** @var array Array of throwable messages */
+ private $throwableArray;
- /**
- * Create a new instance
- *
- * @param $throwable - a throwable as a exception
- * @param $logger - Logger reference
- */
- public function __construct(\Exception $throwable) {
- $this->throwable = $throwable;
- }
+ /**
+ * Create a new instance
+ *
+ * @param $throwable - a throwable as a exception
+ * @param $logger - Logger reference
+ */
+ public function __construct(\Exception $throwable)
+ {
+ $this->throwable = $throwable;
+ }
- /**
- * Return source exception
- *
- * @return Exception
- */
- public function getThrowable() {
- return $this->throwable;
- }
+ /**
+ * Return source exception
+ *
+ * @return Exception
+ */
+ public function getThrowable()
+ {
+ return $this->throwable;
+ }
- /**
- * @desc Returns string representation of throwable
- *
- * @return array
- */
- public function getStringRepresentation() {
- if (!is_array($this->throwableArray)) {
- $renderer = new Renderers\ExceptionRenderer();
+ /**
+ * @desc Returns string representation of throwable
+ *
+ * @return array
+ */
+ public function getStringRepresentation()
+ {
+ if (!is_array($this->throwableArray)) {
+ $renderer = new Renderers\ExceptionRenderer();
- $this->throwableArray = explode("\n", $renderer->render($this->throwable));
- }
+ $this->throwableArray = explode("\n", $renderer->render($this->throwable));
+ }
- return $this->throwableArray;
- }
+ return $this->throwableArray;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/bootstrap.php
----------------------------------------------------------------------
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index b95c505..3d81583 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -30,7 +30,7 @@ date_default_timezone_set('Europe/London');
// Define a temp dir where tests may write to
$tmpDir = __DIR__ . '/../target/temp/phpunit';
if (!is_dir($tmpDir)) {
- mkdir($tmpDir, 0777, true);
+ mkdir($tmpDir, 0777, true);
}
define('PHPUNIT_TEMP_DIR', realpath($tmpDir));
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/php/config_empty.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_empty.php b/tests/resources/configs/adapters/php/config_empty.php
index 5ca9004..eaf556c 100644
--- a/tests/resources/configs/adapters/php/config_empty.php
+++ b/tests/resources/configs/adapters/php/config_empty.php
@@ -1,26 +1,24 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php
- */
-
-// Empty config
-
-?>
\ No newline at end of file
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+// Empty config
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/php/config_invalid_syntax.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_invalid_syntax.php b/tests/resources/configs/adapters/php/config_invalid_syntax.php
index 5019f68..49df5f4 100644
--- a/tests/resources/configs/adapters/php/config_invalid_syntax.php
+++ b/tests/resources/configs/adapters/php/config_invalid_syntax.php
@@ -1,40 +1,38 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php
- */
-
-return array(
- 'rootLogger' => array(
- 'level' => 'info',
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- )
- )
- )
-
-// Invalid file - no closing brace.
-
-?>
\ No newline at end of file
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+return array(
+ 'rootLogger' => array(
+ 'level' => 'info',
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ )
+ )
+
+// Invalid file - no closing brace.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/php/config_not_an_array.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_not_an_array.php b/tests/resources/configs/adapters/php/config_not_an_array.php
index 030bb10..a4b3945 100644
--- a/tests/resources/configs/adapters/php/config_not_an_array.php
+++ b/tests/resources/configs/adapters/php/config_not_an_array.php
@@ -1,27 +1,25 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php
- */
-
-// Not an array
-return new Exception();
-
-?>
\ No newline at end of file
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+// Not an array
+return new Exception();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/php/config_valid.php
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/php/config_valid.php b/tests/resources/configs/adapters/php/config_valid.php
index bfabfce..6485239 100644
--- a/tests/resources/configs/adapters/php/config_valid.php
+++ b/tests/resources/configs/adapters/php/config_valid.php
@@ -1,40 +1,38 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php
- */
-
-return array(
- 'rootLogger' => array(
- 'level' => 'info',
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- )
- )
- )
-)
-;
-
-?>
\ No newline at end of file
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+return array(
+ 'rootLogger' => array(
+ 'level' => 'info',
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ )
+ )
+)
+;
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_duplicate_logger.xml b/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
index 978b9c7..db60593 100644
--- a/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
+++ b/tests/resources/configs/adapters/xml/config_duplicate_logger.xml
@@ -1,39 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
-
- <appender name="default" class="EchoAppender">
- <layout class="SimpleLayout"/>
- </appender>
-
- <!-- Duplicate logger -->
- <logger name="foo">
- <level value="info" />
- <appender_ref ref="default" />
- </logger>
-
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <!-- Duplicate logger -->
+ <logger name="foo">
+ <level value="info" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml b/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
index 4ac97bc..a79b0e0 100644
--- a/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
+++ b/tests/resources/configs/adapters/xml/config_duplicate_renderer.xml
@@ -1,30 +1,30 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration>
- <!-- Duplicate renderer -->
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer1" />
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer2" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="EchoAppender">
- <layout class="SimpleLayout"/>
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration>
+ <!-- Duplicate renderer -->
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer1" />
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer2" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_invalid_syntax.xml b/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
index 6592fa5..1e2c3c1 100644
--- a/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
+++ b/tests/resources/configs/adapters/xml/config_invalid_syntax.xml
@@ -1,39 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="default" class="EchoAppender">
- <layout class="SimpleLayout"/>
- </appender>
-
- <!-- Duplicate logger -->
- <logger name="foo">
- <level value="info" />
- <appender_ref ref="default" />
- </logger>
-
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-
- <!-- Invalid XML file for testing -->
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="default" class="EchoAppender">
+ <layout class="SimpleLayout"/>
+ </appender>
+
+ <!-- Duplicate logger -->
+ <logger name="foo">
+ <level value="info" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ </logger>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+
+ <!-- Invalid XML file for testing -->
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/xml/config_valid.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_valid.xml b/tests/resources/configs/adapters/xml/config_valid.xml
index 6553c44..bb326a6 100644
--- a/tests/resources/configs/adapters/xml/config_valid.xml
+++ b/tests/resources/configs/adapters/xml/config_valid.xml
@@ -1,54 +1,54 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="EchoAppender">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LevelRangeFilter">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- <filter class="DenyAllFilter" />
- </appender>
- <appender name="file" class="DailyFileAppender" threshold="warn">
- <param name="datePattern" value="Ymd" />
- <param name="file" value="target/examples/daily_%s.log" />
- <layout class="PatternLayout">
- <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
- </layout>
- </appender>
- <logger name="foo.bar.baz" additivity="false">
- <level value="trace" />
- <appender_ref ref="default" />
- </logger>
- <logger name="foo.bar" additivity="true">
- <level value="debug" />
- <appender_ref ref="file" />
- </logger>
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- <appender_ref ref="file" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="LoggerLayoutTTCC"/>
+ <filter class="LevelRangeFilter">
+ <param name="levelMin" value="ERROR" />
+ <param name="levelMax" value="FATAL" />
+ <param name="acceptOnMatch" value="false" />
+ </filter>
+ <filter class="DenyAllFilter" />
+ </appender>
+ <appender name="file" class="DailyFileAppender" threshold="warn">
+ <param name="datePattern" value="Ymd" />
+ <param name="file" value="target/examples/daily_%s.log" />
+ <layout class="PatternLayout">
+ <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
+ </layout>
+ </appender>
+ <logger name="foo.bar.baz" additivity="false">
+ <level value="trace" />
+ <appender_ref ref="default" />
+ </logger>
+ <logger name="foo.bar" additivity="true">
+ <level value="debug" />
+ <appender_ref ref="file" />
+ </logger>
+ <logger name="foo">
+ <level value="warn" />
+ <appender_ref ref="default" />
+ <appender_ref ref="file" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/adapters/xml/config_valid_underscore.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/adapters/xml/config_valid_underscore.xml b/tests/resources/configs/adapters/xml/config_valid_underscore.xml
index 4ff6e21..179629e 100644
--- a/tests/resources/configs/adapters/xml/config_valid_underscore.xml
+++ b/tests/resources/configs/adapters/xml/config_valid_underscore.xml
@@ -1,57 +1,57 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- Same as config_valid.xml but uses appender-ref instead of appender_ref -->
-
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
- <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
- <appender name="default" class="EchoAppender">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LevelRangeFilter">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- <filter class="DenyAllFilter" />
- </appender>
- <appender name="file" class="DailyFileAppender" threshold="warn">
- <param name="datePattern" value="Ymd" />
- <param name="file" value="target/examples/daily_%s.log" />
- <layout class="PatternLayout">
- <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
- </layout>
- </appender>
- <logger name="foo.bar.baz" additivity="false">
- <level value="trace" />
- <appender-ref ref="default" />
- </logger>
- <logger name="foo.bar" additivity="true">
- <level value="debug" />
- <appender-ref ref="file" />
- </logger>
- <logger name="foo">
- <level value="warn" />
- <appender-ref ref="default" />
- <appender-ref ref="file" />
- </logger>
- <root>
- <level value="DEBUG" />
- <appender-ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Same as config_valid.xml but uses appender-ref instead of appender_ref -->
+
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <renderer renderedClass="Fruit" renderingClass="FruitRenderer" />
+ <renderer renderedClass="Beer" renderingClass="BeerRenderer" />
+ <appender name="default" class="EchoAppender">
+ <layout class="LoggerLayoutTTCC"/>
+ <filter class="LevelRangeFilter">
+ <param name="levelMin" value="ERROR" />
+ <param name="levelMax" value="FATAL" />
+ <param name="acceptOnMatch" value="false" />
+ </filter>
+ <filter class="DenyAllFilter" />
+ </appender>
+ <appender name="file" class="DailyFileAppender" threshold="warn">
+ <param name="datePattern" value="Ymd" />
+ <param name="file" value="target/examples/daily_%s.log" />
+ <layout class="PatternLayout">
+ <param name="conversionPattern" value= "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" />
+ </layout>
+ </appender>
+ <logger name="foo.bar.baz" additivity="false">
+ <level value="trace" />
+ <appender-ref ref="default" />
+ </logger>
+ <logger name="foo.bar" additivity="true">
+ <level value="debug" />
+ <appender-ref ref="file" />
+ </logger>
+ <logger name="foo">
+ <level value="warn" />
+ <appender-ref ref="default" />
+ <appender-ref ref="file" />
+ </logger>
+ <root>
+ <level value="DEBUG" />
+ <appender-ref ref="default" />
+ </root>
+</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/resources/configs/appenders/config_invalid_appender_class.xml
----------------------------------------------------------------------
diff --git a/tests/resources/configs/appenders/config_invalid_appender_class.xml b/tests/resources/configs/appenders/config_invalid_appender_class.xml
index db3ccf0..0f72552 100644
--- a/tests/resources/configs/appenders/config_invalid_appender_class.xml
+++ b/tests/resources/configs/appenders/config_invalid_appender_class.xml
@@ -1,25 +1,25 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
- <appender name="foo" class="stdClass"/>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration xmlns="http://logging.apache.org/log4php" threshold="debug">
+ <appender name="foo" class="stdClass"/>
+
+ <root>
+ <level value="DEBUG" />
+ <appender_ref ref="default" />
+ </root>
+</configuration>
[08/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts/pattern.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts/pattern.xml b/src/site/xdoc/docs/layouts/pattern.xml
deleted file mode 100644
index 7b3a6cf..0000000
--- a/src/site/xdoc/docs/layouts/pattern.xml
+++ /dev/null
@@ -1,655 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerLayoutPattern</title>
- </properties>
-
- <body>
- <section name="LoggerLayoutPattern">
-
- <p>LoggerLayoutPattern is a flexible layout configurable via a conversion pattern.</p>
-
- <subsection name="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>conversionPattern</td>
- <td>string</td>
- <td>No</td>
- <td>%message%newline</td>
- <td>String which controls the output. See full specification below.</td>
- </tr>
- </tbody>
- </table>
-
- <h4>Conversion patterns</h4>
-
- <p><strong>Conversion pattern</strong> is a string which controls the formatting of logging
- events. It controls how logging events will be transformed into strings by the layout.</p>
-
- <p>The conversion pattern is closely related to the conversion pattern of the PHP
- <a href="http://www.php.net/manual/en/function.sprintf.php" class="external">sprintf</a> function.
- It is composed of literal text and format control expressions called <em>conversion specifiers</em>.
- </p>
-
- <p>A conversion specifier begins with a percent sign (%) and is followed by a <em>conversion word</em>.
- Some conversion words require one or more <em>options</em> to be given. These are specified in braces after the
- conversion word. An example of a conversion specifier is <code>%message</code> which will be converted into
- the message from the logging event which is being logged.</p>
-
- <p>The recognized conversion specifiers are:</p>
-
- <table class="table table-bordered">
- <thead>
- <tr>
- <th>Conversion specifier</th>
- <th>Converts to</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>
- <p><strong>%c</strong>{length}</p>
- <p><strong>%lo</strong>{length}</p>
- <p><strong>%logger</strong>{length}</p>
- </td>
- <td>
- <p>Name of the Logger which generated the logging request.</p>
-
- <p>Optionally, a desired output length can be specified. If given, the converter will attempt
- to abbreviate the logger name without losing too much information in the process. If
- zero length is specified, only the rightmost name fragment will be output.</p>
-
- <p>Specifying the desired length 0 means that only the class name will be returned without
- the corresponding namespace.</p>
-
- <p>Several examples of the shortening algorithm in action:</p>
-
- <table class="table table-bordered table-not-wide">
- <thead>
- <tr>
- <th>Conversion specifier</th>
- <th>Logger name</th>
- <th>Result</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>%logger</td>
- <td>org\apache\logging\log4php\Foo</td>
- <td>org\apache\logging\log4php\Foo</td>
- </tr>
- <tr>
- <td>%logger{0}</td>
- <td>org\apache\logging\log4php\Foo</td>
- <td>Foo</td>
- </tr>
- <tr>
- <td>%logger{10}</td>
- <td>org\apache\logging\log4php\Foo</td>
- <td>o\a\l\l\Foo</td>
- </tr>
- <tr>
- <td>%logger{20}</td>
- <td>org\apache\logging\log4php\Foo</td>
- <td>o\a\l\log4php\Foo</td>
- </tr>
- <tr>
- <td>%logger{25}</td>
- <td>org\apache\logging\log4php\Foo</td>
- <td>o\a\logging\log4php\Foo</td>
- </tr>
- <tr>
- <td>%logger{30}</td>
- <td>org\apache\logging\log4php\Foo</td>
- <td>org\apache\logging\log4php\Foo</td>
- </tr>
- </tbody>
- </table>
-
- <p>Note that rightmost segment will never be shortened. It is possible that the
- resulting string will be longer than the specified desired length.</p>
- <p>For backward compatibility, a dot can be used as a namespace separator, as well as
- the backslash.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%C</strong>{length}</p>
- <p><strong>%class</strong>{length}</p>
- </td>
- <td>
- <p>The fully qualified class name of the caller issuing the logging request.</p>
- <p>Just like <strong>%logger</strong>, a desired length can be defined as an option.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%cookie</strong>{key}</p>
- </td>
- <td>
- <p>A value from the $_COOKIE superglobal array corresponding to the given key.</p>
- <p>If no key is given, will return all values in key=value format.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%d</strong>{pattern}</p>
- <p><strong>%date</strong>{pattern}</p>
- </td>
- <td>
- <p>The date/time of the logging event. Accepts a pattern string as an option. The
- pattern syntax is the same as used by the PHP's <code><a href="http://php.net/manual/en/function.date.php"
- class="external">date()</a></code> function.</p>
-
- <p>If no pattern is given, the date format will default to the ISO8601 datetime format,
- which is the same as giving the pattern: <code>c</code>.</p>
-
- <table>
- <thead>
- <tr>
- <th>Conversion specifier</th>
- <th>Result</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>%d</td>
- <td>2011-12-27T12:01:32+01:00</td>
- </tr>
- <tr>
- <td>%date</td>
- <td>2011-12-27T12:01:32+01:00</td>
- </tr>
- <tr>
- <td>%date{ISO8601}</td>
- <td>2011-12-27T12:01:32+01:00</td>
- </tr>
- <tr>
- <td>%date{Y-m-d H:i:s,u}</td>
- <td>2011-12-27 12:01:32,610</td>
- </tr>
- <tr>
- <td>%date{l jS \of F Y h:i:s A}</td>
- <td>Tuesday 27th of December 2011 12:01:32 PM</td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%e</strong>{key}</p>
- <p><strong>%env</strong>{key}</p>
- </td>
- <td>
- <p>A value from the $_ENV superglobal array corresponding to the given key.</p>
- <p>If no key is given, will return all values in key=value format.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%ex</strong></p>
- <p><strong>%exception</strong></p>
- <p><strong>%throwable</strong></p>
- </td>
- <td>
- <p>The exception associated with the logging event, along with it's stack trace. If
- there is no exception, evalutates to an empty string.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%F</strong></p>
- <p><strong>%file</strong></p>
- </td>
- <td>Name of the file from which the logging request was issued.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%l</strong></p>
- <p><strong>%location</strong></p>
- </td>
- <td>
- <p>Location information of the caller which generated the logging event.</p>
- <p>Identical to <code>%C.%M(%F:%L)</code></p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%L</strong></p>
- <p><strong>%line</strong></p>
- </td>
- <td>The line number at which the logging request was issued.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%m</strong></p>
- <p><strong>%msg</strong></p>
- <p><strong>%message</strong></p>
- </td>
- <td>The message associated with the logging event.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%M</strong></p>
- <p><strong>%method</strong></p>
- </td>
- <td>The method or function name from which the logging request was issued.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%n</strong></p>
- <p><strong>%newline</strong></p>
- </td>
- <td>
- <p>A platform dependent line-break character(s).</p>
- <p>Note that a line break will not be printed unless explicitely specified.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%p</strong></p>
- <p><strong>%le</strong></p>
- <p><strong>%level</strong></p>
- </td>
- <td>The level of the logging event.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%r</strong></p>
- <p><strong>%relative</strong></p>
- </td>
- <td>The number of milliseconds elapsed since the start of the application until the creation of the logging event.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%req</strong>{key}</p>
- <p><strong>%request</strong>{key}</p>
- </td>
- <td>
- <p>A value from the $_REQUEST superglobal array corresponding to the given key.</p>
- <p>If no key is given, will return all values in key=value format.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%s</strong>{key}</p>
- <p><strong>%server</strong>{key}</p>
- </td>
- <td>
- <p>A value from the $_SERVER superglobal array corresponding to the given key.</p>
- <p>If no key is given, will return all values in key=value format.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%ses</strong>{key}</p>
- <p><strong>%session</strong>{key}</p>
- </td>
- <td>
- <p>A value from the $_SESSION superglobal array corresponding to the given key.</p>
- <p>If no key is given, will return all values in key=value format.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%sid</strong></p>
- <p><strong>%sessionid</strong></p>
- </td>
- <td>
- <p>The active session ID, or an empty string if not in session.</p>
- <p>Equivalent to calling <code>session_id()</code>.</p>
- </td>
- </tr>
- <tr>
- <td>
- <p><strong>%t</strong></p>
- <p><strong>%pid</strong></p>
- <p><strong>%process</strong></p>
- </td>
- <td>The ID of the process that generated the logging event.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%x</strong></p>
- <p><strong>%ndc</strong></p>
- </td>
- <td>The NDC (Nested Diagnostic Context) associated with the thread that generated the logging event.</td>
- </tr>
- <tr>
- <td>
- <p><strong>%X</strong>{key}</p>
- <p><strong>%mdc</strong>{key}</p>
- </td>
- <td>
- <p>A value from the Mapped Diagnostic Context (MDC) corresponding to the given key.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Format modifiers">
- <p>By default the relevant information is output as-is. However, with the aid of format modifiers
- it is possible to change the minimum and maximum width and the justifications of each data field.
- </p>
-
- <p>Both format modifiers are optional, and are placed between the percent sign (%) and the conversion
- word. These are, in order:</p>
-
- <ol>
- <li>A <b>minimum width specifier</b>, a number which determines the minimum width of the resulting
- string. If the resulting string is shorter that the given number, it will be padded with spaces to
- the desired length. By default, the string is right-justified (padded from left), but adding a
- "-" sign before the specifier will make it left-justified.</li>
-
- <li>A <b>maximum widht specifier</b>, a dot (".") followed by a number which determines the maximum
- allowed width of the resulting string. If the resulting string is shorter than the given number, it
- will be truncated to the maximum width. By default the string is truncated from the right, but
- adding a "-" sign before the specifier will cause it to truncate from the left.</li>
- </ol>
-
- <p>The following table demonstrates various uses of format modifiers:</p>
-
- <table>
- <thead>
- <tr>
- <th>Format modifier</th>
- <th>Padding</th>
- <th>Trimming</th>
- <th>Minimum width</th>
- <th>Maximum width</th>
- <th>Comment</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td align="center"><strong>%logger</strong></td>
- <td align="center">none</td>
- <td align="center">none</td>
- <td align="center">none</td>
- <td align="center">none</td>
- <td>Output the logger name as-is.</td>
- </tr>
- <tr>
- <td align="center"><strong>%20logger</strong></td>
- <td align="center">right</td>
- <td align="center">none</td>
- <td align="center">20</td>
- <td align="center">none</td>
- <td>Left pad with spaces if the logger name is less than 20 characters long.</td>
- </tr>
- <tr>
- <td align="center"><strong>%-20logger</strong></td>
- <td align="center">left</td>
- <td align="center">none</td>
- <td align="center">20</td>
- <td align="center">none</td>
- <td>Right pad with spaces if the logger name is less than 20 characters long.</td>
- </tr>
- <tr>
- <td align="center"><strong>%.30logger</strong></td>
- <td align="center">none</td>
- <td align="center">right</td>
- <td align="center">none</td>
- <td align="center">30</td>
- <td>Trim from the end if the logger name is longer than 30 characters.</td>
- </tr>
- <tr>
- <td align="center"><strong>%.-30logger</strong></td>
- <td align="center">none</td>
- <td align="center">left</td>
- <td align="center">none</td>
- <td align="center">30</td>
- <td>Trim from the beginning if the logger name is longer than 30 characters.</td>
- </tr>
- <tr>
- <td align="center"><strong>%20.30logger</strong></td>
- <td align="center">right</td>
- <td align="center">right</td>
- <td align="center">20</td>
- <td align="center">30</td>
- <td>Left pad with spaces if the logger name is shorter than 20 characters. However, if
- the logger name is longer than 30 characters, then trim from the end.</td>
- </tr>
- <tr>
- <td align="center"><strong>%-20.30logger</strong></td>
- <td align="center">left</td>
- <td align="center">right</td>
- <td align="center">20</td>
- <td align="center">30</td>
- <td>Right pad with spaces if the logger name is shorter than 20 characters. However, if the
- logger name is longer than 30 characters, then trim from the end.</td>
- </tr>
- </tbody>
- </table>
-
- <p>The following table lists a couple of examples for using format modifiers. Note that the square
- brackets are added to the conversion pattern to delimit the output.</p>
-
- <table class="table table-bordered table-striped table-not-wide">
- <thead>
- <tr>
- <th>Conversion pattern</th>
- <th>Logger name</th>
- <th>Result</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>[%10logger]</td>
- <td>Foo</td>
- <td><code>[ Foo]</code></td>
- <td>Added padding, right aligned.</td>
- </tr>
- <tr>
- <td>[%-10logger]</td>
- <td>Foo</td>
- <td><code>[Foo ]</code></td>
- <td>Added padding, left aligned.</td>
- </tr>
- <tr>
- <td>[%.10logger]</td>
- <td>org.apache.log4php.Foo</td>
- <td><code>[org.apache]</code></td>
- <td>Trimmed from right.</td>
- </tr>
- <tr>
- <td>[%.-10logger]</td>
- <td>org.apache.log4php.Foo</td>
- <td><code>[og4php.Foo]</code></td>
- <td>Trimmed from left.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
- <p>The following configuration configures a <code>LoggerAppenderEcho</code> which uses the pattern
- layout. All examples will use the same code and configuration, only the conversion pattern will
- change from example to example.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutPattern">
- <param name="conversionPattern" value="%date %logger %-5level %msg%n" />
- </layout>
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'params' => array(
- 'conversionPattern' => '%date %logger %-5level %msg%n'
- )
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
-
- <p>Example code:</p>
-
-<pre class="prettyprint linenums">
-Logger::configure("config.xml");
-$logger = Logger::getLogger('myLogger');
-$logger->info("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
-$logger->debug("Donec a diam lectus.");
-$logger->warn("Sed sit amet ipsum mauris.");
-</pre>
-
- <h4>A simple example</h4>
-
- <p>Conversion pattern: <code>%date %logger %-5level %msg%n</code></p>
-
- <p>Running the example code produces the following output:</p>
-
-<pre>
-2012-02-27T19:42:17+01:00 myLogger INFO Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-2012-02-27T19:42:17+01:00 myLogger DEBUG Donec a diam lectus.
-2012-02-27T19:42:17+01:00 myLogger WARN Sed sit amet ipsum mauris.
-</pre>
-
- <p>In this example, <code>%date</code> is converted to the event datetime in default format
- (corresponding to the ISO-8601 specification), and <code>%-5level</code> produces the event
- level right padded to 5 characters. Since longest level name is 5 characters long, this
- ensures that the message always starts at the same character position which improves log
- readability.</p>
-
- <p>Notice that the newline between logging events (%n) has to be explicitely defined. Otherwise all
- logging events will be logged in the same line.</p>
-
- <h4>Formatting the date</h4>
-
- <p>The <code>%date</code> conversion word can take the desired date format as an option. For example,
- if you're European, the d.m.Y date format might be more familiar. Also, adding milliseconds.</p>
-
- <p>Conversion pattern: <code>%date{d.m.Y H:i:s,u} %logger %-5level %msg%n</code></p>
-
- <p>Running the example code produces the following output:</p>
-
-<pre>
-27.02.2012 20:14:41,624 myLogger INFO Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-27.02.2012 20:14:41,625 myLogger DEBUG Donec a diam lectus.
-27.02.2012 20:14:41,626 myLogger WARN Sed sit amet ipsum mauris.
-</pre>
-
- <h4>Logging HTTP requests</h4>
-
- <p>If log4php is used to log HTTP requests, a pattern like this might be useful:</p>
-
- <p><code>%date [%pid] From:%server{REMOTE_ADDR}:%server{REMOTE_PORT} Request:[%request] Message: %msg%n</code></p>
-
- <p>Request <code>/test.php?foo=bar</code> it will produce the output similar to:</p>
-
-<pre>
-2012-01-02T14:19:33+01:00 [22924] From:194.152.205.71:11257 Request:[foo=bar] Message: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-2012-01-02T14:19:33+01:00 [22924] From:194.152.205.71:11257 Request:[foo=bar] Message: Donec a diam lectus.
-2012-01-02T14:19:33+01:00 [22924] From:194.152.205.71:11257 Request:[foo=bar] Message: Sed sit amet ipsum mauris.
-</pre>
-
- <p><code>%server{REMOTE_ADDR}</code> is equivalent to PHP code <code>$_SERVER['REMOTE_ADDR']</code>.</p>
-
- <h4>Logging exceptions</h4>
-
- <p>If you wish to log any exception passed to the logging methods, you should add the <code>%ex</code>
- specifier to the end of your conversion pattern, after <code>%newline</code>. This way, if an exception
- is loggerd it will be addded to your log below your message.</p>
-
- <p>For example: <code>%date %logger %message%newline%ex</code></p>
-
- <p>In the following code, suppose that the work() method can throw an exception. This wolud be a good
- way to deal with it:</p>
-
-<pre class="prettyprint linenums">
-$log = Logger::getLogger('foo');
-$log->info("Let's try this");
-
-try
-{
- $foo = new Foo();
- $foo->work(123);
-}
-catch(Exception $ex)
-{
- // Exception is passed as the second parameter
- $log->error("That didn't work", $ex);
-}
-$log->info("Done.");
-</pre>
-
- <p>If work() throws an exception, your log might look something like this:</p>
-
-<pre>
-2012-10-08T10:11:18+02:00 foo Let's try this
-2012-10-08T10:11:18+02:00 foo That didn't work
-exception 'Exception' with message 'Doesn't work' in D:\work\exceptions.php:38
-Stack trace:
-#0 D:\work\exceptions.php(29): Bar->work(123)
-#1 D:\work\exceptions.php(48): Foo->work(123)
-#2 {main}
-2012-10-08T10:11:18+02:00 foo Done.
-</pre>
-
- <p>The exception, along with the full stack trace ends up in your log. This also works with nested
- exceptions, the full stack trace is added.</p>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts/serialized.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts/serialized.xml b/src/site/xdoc/docs/layouts/serialized.xml
deleted file mode 100644
index adae267..0000000
--- a/src/site/xdoc/docs/layouts/serialized.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerLayoutSerialized</title>
- </properties>
-
- <body>
- <section name="LoggerLayoutSerialized">
-
- <p><code>LoggerLayoutSerialized</code> formats the logging event using the PHP's
- <code><a href="http://php.net/manual/en/function.serialize.php">serialize()</a></code> function.</p>
-
- <subsection name="Parameters" id="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>locationInfo</td>
- <td>boolean</td>
- <td>No</td>
- <td>false</td>
- <td>If set to true, event's location information will be initialized before serialization.
- Enabling this parameter makes logging slower and should be used only if required.</td>
- </tr>
- </tbody>
- </table>
-
- </subsection>
-
- <subsection name="Examples">
-
- <p>Sample configuration file:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSerialized" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSerialized',
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>Running the following code:</p>
-
-<pre class="prettyprint linenums">
-Logger::configure("config.xml");
-$logger = Logger::getLogger('myLogger');
-$logger->info("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
-$logger->debug("Donec a diam lectus.");
-$logger->warn("Sed sit amet ipsum mauris.");
-</pre>
-
- <p>Produces the following output:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-O:18:"LoggerLoggingEvent":10:{s:24:" LoggerLoggingEvent fqcn";s:6:"Logger";s:32:" LoggerLoggingEvent categoryName";s:8:"myLogger";s:8:" * level";O:11:"LoggerLevel":3:{s:18:" LoggerLevel level";i:20000;s:21:" LoggerLevel levelStr";s:4:"INFO";s:29:" LoggerLevel syslogEquivalent";i:6;}s:23:" LoggerLoggingEvent ndc";N;s:37:" LoggerLoggingEvent ndcLookupRequired";b:1;s:27:" LoggerLoggingEvent message";s:56:"Lorem ipsum dolor sit amet, consectetur adipiscing elit.";s:35:" LoggerLoggingEvent renderedMessage";N;s:30:" LoggerLoggingEvent threadName";N;s:9:"timeStamp";d:1319380554.782227;s:32:" LoggerLoggingEvent locationInfo";N;}
-O:18:"LoggerLoggingEvent":10:{s:24:" LoggerLoggingEvent fqcn";s:6:"Logger";s:32:" LoggerLoggingEvent categoryName";s:8:"myLogger";s:8:" * level";O:11:"LoggerLevel":3:{s:18:" LoggerLevel level";i:10000;s:21:" LoggerLevel levelStr";s:5:"DEBUG";s:29:" LoggerLevel syslogEquivalent";i:7;}s:23:" LoggerLoggingEvent ndc";N;s:37:" LoggerLoggingEvent ndcLookupRequired";b:1;s:27:" LoggerLoggingEvent message";s:20:"Donec a diam lectus.";s:35:" LoggerLoggingEvent renderedMessage";N;s:30:" LoggerLoggingEvent threadName";N;s:9:"timeStamp";d:1319380554.78247;s:32:" LoggerLoggingEvent locationInfo";N;}
-O:18:"LoggerLoggingEvent":10:{s:24:" LoggerLoggingEvent fqcn";s:6:"Logger";s:32:" LoggerLoggingEvent categoryName";s:8:"myLogger";s:8:" * level";O:11:"LoggerLevel":3:{s:18:" LoggerLevel level";i:30000;s:21:" LoggerLevel levelStr";s:4:"WARN";s:29:" LoggerLevel syslogEquivalent";i:4;}s:23:" LoggerLoggingEvent ndc";N;s:37:" LoggerLoggingEvent ndcLookupRequired";b:1;s:27:" LoggerLoggingEvent message";s:26:"Sed sit amet ipsum mauris.";s:35:" LoggerLoggingEvent renderedMessage";N;s:30:" LoggerLoggingEvent threadName";N;s:9:"timeStamp";d:1319380554.78268;s:32:" LoggerLoggingEvent locationInfo";N;}
-]]></pre>
- </subsection>
-
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts/simple.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts/simple.xml b/src/site/xdoc/docs/layouts/simple.xml
deleted file mode 100644
index 0e59715..0000000
--- a/src/site/xdoc/docs/layouts/simple.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerLayoutSimple</title>
- </properties>
-
- <body>
- <section name="LoggerLayoutSimple">
-
- <p><code>LoggerLayoutSimple</code> is a basic layout which outputs only the level followed by the message.</p>
-
- <p>It is interesting to note that the output of <code>LoggerLayoutSimple</code> is identical to that of
- <code><a href="pattern.html">LoggerLayoutPattern</a></code> with the <em>conversion pattern</em> set to
- <code>%p - %m%n</code>.</p>
-
-
- <subsection name="Parameters">
- <p>This layout does not have any configurable parameters.</p>
- </subsection>
-
- <subsection name="Examples">
-
- <p>Configuration:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutSimple" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
-
- <p>Running the following code:</p>
-
-<pre class="prettyprint linenums">
-Logger::configure("layout_xml.xml");
-$log = Logger::getRootLogger();
-$log->info("My first message.");
-$log->debug("My second message.");
-$log->warn("My third message.");
-</pre>
-
- <p>Produces the following output:</p>
-
-<pre>
-INFO - My first message.
-DEBUG - My second message.
-WARN - My third message.
-</pre>
-
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts/ttcc.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts/ttcc.xml b/src/site/xdoc/docs/layouts/ttcc.xml
deleted file mode 100644
index 4a797f9..0000000
--- a/src/site/xdoc/docs/layouts/ttcc.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerLayoutTTCC</title>
- </properties>
-
- <body>
- <section name="LoggerLayoutTTCC">
-
- <div class="alert alert-error">
- <span class="alert-heading">Deprecated!</span>
- <p>LoggerLayoutTTCC is deprecated and will be removed in a future release. Please use
- <a href="pattern.html">LoggerLayoutPattern</a> instead.</p>
- </div>
-
- <p>The TTCC layout format was taken from Apache log4j, and originally consisted of Time, Thread, Category
- and nested diagnostic Context information, hence the name.</p>
-
- <p><code>LoggerLayoutTTCC</code> contains equivalent information:</p>
- <ul>
- <li>Time</li>
- <li>Process ID</li>
- <li>Logger name</li>
- <li>Nested diagnostic context</li>
- </ul>
-
- <p>Output of <code>LoggerLayoutTTCC</code> is identical to that of
- <code><a href="pattern.html">LoggerLayoutPattern</a></code> with the <em>conversion pattern</em> set to
- <code>%d{m/d/y H:i:s,u} [%t] %p %c %x - %m%n</code>.</p>
-
- <subsection name="Parameters">
-
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>threadPrinting</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the process ID will be included in output.</td>
- </tr>
- <tr>
- <td>categoryPrefixing</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the logger name will be included in output.</td>
- </tr>
- <tr>
- <td>contextPrinting</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the nested diagnostic context will be included in output.</td>
- </tr>
- <tr>
- <td>microSecondsPrinting</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, the microseconds will be included in output.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
-
- <p>Configuration:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutTTCC',
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
-
- <p>For this example, some Nested Diagnostic Context is added also. Running the following code:</p>
-
-<pre class="prettyprint linenums">
-Logger::configure("config.xml");
-LoggerNDC::push("Some Context");
-
-$logger = Logger::getLogger('myLogger');
-$logger->info("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
-$logger->debug("Donec a diam lectus.");
-$logger->warn("Sed sit amet ipsum mauris.");
-</pre>
-
- <p>Produces the following output:</p>
-
-<pre>
-02/20/12 23:36:39,772 [9820] INFO myLogger Some Context - Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-02/20/12 23:36:39,773 [9820] DEBUG myLogger Some Context - Donec a diam lectus.
-02/20/12 23:36:39,773 [9820] WARN myLogger Some Context - Sed sit amet ipsum mauris.
-</pre>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/layouts/xml.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/layouts/xml.xml b/src/site/xdoc/docs/layouts/xml.xml
deleted file mode 100644
index 125c0d2..0000000
--- a/src/site/xdoc/docs/layouts/xml.xml
+++ /dev/null
@@ -1,189 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>LoggerLayoutXml</title>
- </properties>
-
- <body>
- <section name="LoggerLayoutXml">
-
- <p><code>LoggerLayoutXml</code> formats the messages as an XML document.</p>
-
- <subsection name="Parameters" id="Parameters">
- <p>The following parameters are available:</p>
-
- <table>
- <thead>
- <tr>
- <th>Parameter</th>
- <th>Type</th>
- <th>Required</th>
- <th>Default</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>locationInfo</td>
- <td>boolean</td>
- <td>No</td>
- <td>true</td>
- <td>If set to true, adds the file name and line number at which the log statement originated.</td>
- </tr>
- <tr>
- <td>log4jNamespace</td>
- <td>boolean</td>
- <td>No</td>
- <td>false</td>
- <td>If set to true then log4j XML namespace will be used instead of the log4php namespace.
- This can be usefull when using log viewers which can only parse the log4j namespace such as
- Apache Chainsaw.</td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Examples">
-
- <h4>Default configuration example</h4>
-
- <p>The default configuration of <code>LoggerLayoutXml</code> will use the log4php XML namespace and
- include the location information.</p>
-
- <p>Configuration file:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content" >
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutXml" />
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutXml',
- )
- )
- ),
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
-
- <p>Running the following code:</p>
-
-<pre class="prettyprint linenums">
-Logger::configure("config.xml");
-$logger = Logger::getLogger('myLogger');
-$logger->info("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
-$logger->debug("Donec a diam lectus.");
-$logger->warn("Sed sit amet ipsum mauris.");
-</pre>
-
- <p>Produces the following output:</p>
-
-<pre class="prettyprint"><![CDATA[
-<log4php:eventSet xmlns:log4php="http://logging.apache.org/log4php/" version="0.3" includesLocationInfo="true">
-
-<log4php:event logger="myLogger" level="INFO" thread="4464" timestamp="1317215164482">
-<log4php:message><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit.]]]]><![CDATA[>]]><![CDATA[</log4php:message>
-<log4php:locationInfo class="main" file="D:\Temp\log4php\layout_pattern.php" line="5" method="main" />
-</log4php:event>
-
-<log4php:event logger="myLogger" level="DEBUG" thread="4464" timestamp="1317215164513">
-<log4php:message><![CDATA[Donec a diam lectus.]]]]><![CDATA[>]]><![CDATA[</log4php:message>
-<log4php:locationInfo class="main" file="D:\Temp\log4php\layout_pattern.php" line="6" method="main" />
-</log4php:event>
-
-<log4php:event logger="myLogger" level="WARN" thread="4464" timestamp="1317215164514">
-<log4php:message><![CDATA[Sed sit amet ipsum mauris.]]]]><![CDATA[>]]><![CDATA[</log4php:message>
-<log4php:locationInfo class="main" file="D:\Temp\log4php\layout_pattern.php" line="7" method="main" />
-</log4php:event>
-
-</log4php:eventSet>
-]]></pre>
-
-
- <h4>Overriding default options</h4>
-
- <p>This example show how to configure <code>LoggerLayoutXml</code> to exclude the location information
- and use the log4j XML namespace.</p>
-
- <p>Configuration file:</p>
-
-<pre class="prettyprint"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutXml">
- <param name="locationInfo" value="false" />
- <param name="log4jNamespace" value="true" />
- </layout>
- </appender>
- <root>
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- <p>Using this configuration will produce the following output:</p>
-
-<pre class="prettyprint"><![CDATA[
-<log4j:eventSet xmlns:log4j="http://jakarta.apache.org/log4j/" version="0.3" includesLocationInfo="false">
-<log4j:event logger="myLogger" level="INFO" thread="3156" timestamp="1317216571470">
-<log4j:message><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit.]]]]><![CDATA[>]]><![CDATA[</log4j:message>
-</log4j:event>
-
-<log4j:event logger="myLogger" level="DEBUG" thread="3156" timestamp="1317216571471">
-<log4j:message><![CDATA[Donec a diam lectus.]]]]><![CDATA[>]]><![CDATA[</log4j:message>
-</log4j:event>
-
-<log4j:event logger="myLogger" level="WARN" thread="3156" timestamp="1317216571471">
-<log4j:message><![CDATA[Sed sit amet ipsum mauris.]]]]><![CDATA[>]]><![CDATA[</log4j:message>
-</log4j:event>
-
-</log4j:eventSet>
-]]></pre>
-
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/loggers.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/loggers.xml b/src/site/xdoc/docs/loggers.xml
deleted file mode 100644
index 9892d4f..0000000
--- a/src/site/xdoc/docs/loggers.xml
+++ /dev/null
@@ -1,289 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Loggers</title>
- </properties>
-
- <body>
- <section name="Loggers">
-
- <p>A logger is a component which will take your logging request and log it. Each class in a project can
- have an individual logger, or they can all use a common logger. Loggers are named entities; it is
- common to name them after the class which will use it for logging.</p>
-
- <p>Creating a logger is done by calling the static <code>getLogger()</code> method on the Logger object
- and providing the name of the logger. For example, to create a logger named <code>foo</code>:</p>
-
- <pre class="prettyprint">$logger = Logger::getLogger('foo');</pre>
-
- <p>Logging requests are made by invoking one of the printing methods of a Logger instance. These logging
- methods are: trace, debug, info, warn, error and fatal. The printing method determines the level of a
- logging request. For example, calling the method <code>info()</code> creates a logging request of level
- <code>INFO</code>. For example:</p>
-
- <pre class="prettyprint">$logger->info("This is the message to be logged.");</pre>
-
- <p>Loggers by themselves do not define where these messages will be logged. For that you need to assign
- one or more <a href="./appenders.html">appenders</a> to the logger.</p>
-
- <subsection name="Logger threshold" id="Logger_threshold">
- <p>A logger can be assigned a threshold level. All logging requests with level lower than this threshold
- will be ignored.</p>
-
- <p>For example, setting logger threshold to <code>INFO</code> means that logging requests with levels
- <code>TRACE</code> and <code>DEBUG</code> will not be logged by this logger.</p>
-
- <p>An example of setting the root logger threshold to <code>INFO</code>:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderConsole" />
- <root>
- <level value="info" />
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
-
- <p>If not explicitly configured, loggers will have their threshold level set to <code>DEBUG</code> by
- default.</p>
- </subsection>
-
- <subsection name="Configuring loggers" id="Configuring_loggers">
- <p>Loggers can be individually configured in the configuration file. </p>
-
- <p>The simplest example is to configure the root logger, since all other loggers will inherit its
- settings, as explained in the <a href="#Logger_hierarchy">next section</a>.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderConsole" />
- <root>
- <level value="info" />
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
- <p>This configuration adds the <code>default</code> appender to the root logger, and sets it's
- <a href="#Logger_threshold">threshold level</a> to <code>INFO</code>.</p>
-
- <p>It is also possible to configure individual named loggers. For example, let's configure the
- <code>foo</code> logger, used in the example above, and set it's threshold to WARN:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderConsole" />
- <logger name="foo">
- <level value="warn" />
- <appender_ref ref="default" />
- </logger>
-</configuration>
-]]></pre>
- </subsection>
-
- <subsection name="Logger hierarchy" id="Logger_hierarchy">
- <p>Loggers follow a parent-child relationship pattern which is implemented by using a naming pattern.
- A logger is said to be an <em>ancestor</em> of another logger if its name followed by a dot is a
- prefix of the <em>descendant</em> logger name. A logger is said to be a <em>parent</em> of a
- <em>child</em> logger if there are no ancestors between itself and the descendant logger.</p>
-
- <p>For example, the logger named <code>foo</code> is a parent of the logger named <code>foo.bar</code>.
- Similarly, <code>org</code> is a parent of <code>org.apache</code> and an ancestor of
- <code>org.apache.logging</code>. This naming scheme should be familiar to most developers.</p>
-
- <p>The root logger resides at the top of the logger hierarchy. It is exceptional in two ways:</p>
- <ul>
- <li>it always exists,</li>
- <li>it cannot be retrieved by name.</li>
- </ul>
-
- <p>Invoking the class static <code>Logger::getRootLogger()</code> method retrieves the root logger.
- All other loggers are instantiated and retrieved with the <code>Logger::getLogger($name)</code>
- method. This method takes the name of the desired logger as a parameter. If the logger does not exist
- at the time of the call, it will be created.</p>
- </subsection>
-
- <subsection name="Logger inheritance" id="Logger_inheritance">
- <p>The threshold level and appenders are inherited from the parent to the child loggers.</p>
-
- <p>For example examine the following configuration:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="default" class="LoggerAppenderConsole" />
- <root>
- <level value="debug" />
- <appender_ref ref="default" />
- </root>
-</configuration>
-]]></pre>
-
- <p>The threshold level of the root logger is set to debug. Also, the root logger is linked to a console
- appender. Any named logger that is created will inherit these root settings.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-$main = Logger::getLogger('main');
-$main->trace('This will not be logged.');
-$main->info('This will be logged.');
-]]></pre>
- <p>A logger named <code>main</code> is created. Since there is no logger-specific configuration, it
- will inherit all of it's settings from the root logger: a console appender, and threshold set to DEBUG.
- Therefore, this code will produce the following output:</p>
-
- <pre>INFO - This will be logged.</pre>
- </subsection>
-
- <subsection name="Appender additivity" id="Appender_additivity">
- <p>Appender additivity is a property of loggers to inherit their parent's appenders. By default all
- loggers have appender additivity enabled.</p>
-
- <p>Let's take the following example:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="A1" class="LoggerAppenderConsole" />
- <appender name="A2" class="LoggerAppenderConsole" />
- <root>
- <appender_ref ref="A1" />
- </root>
- <logger name="foo">
- <appender_ref ref="A2" />
- </logger>
-</configuration>
-]]></pre>
- <p>Since additivity is enabled by default, the logger <code>foo</code> will have two linked appenders:
- A1 which it will inherit from the root logger, and A2 which is defined for it specifically.</p>
-
- <p>Therefore, by executing the following code:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-$main = Logger::getLogger('foo');
-$main->info('This will be logged twice.');
-]]></pre>
- <p>The message will be logged twice - once by A1 and once by A2, producing:</p>
-
-<pre>
-INFO - This will be logged twice.
-INFO - This will be logged twice.
-</pre>
-
- <h4>Disabling appender additivity</h4>
-
- <p>Logger's appender additivity can also be disabled if needed.</p>
-
- <p>If the <code>foo</code> logger in the previous example was configured like this:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<logger name="foo" additivity="false">
- <appender_ref ref="A2" />
-</logger>
-]]></pre>
- <p>Then the logger would not have inherited the A1 appender from the root logger, and the message
- would have been logged only once.</p>
-
- <h4>A more complex example</h4>
-
- <p>In this example we will look at multiple loggers making a hierarchy.</p>
-
- <p>Not to make the example too complex, all appenders will log to the console. Of course, this doesn't
- always have to be the case.</p>
-
- <p>Let's take the following configuration file:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="A1" class="LoggerAppenderConsole" />
- <appender name="A2" class="LoggerAppenderConsole" />
- <appender name="A3" class="LoggerAppenderConsole" />
- <appender name="A4" class="LoggerAppenderConsole" />
-
- <root>
- <appender_ref ref="A1" />
- </root>
- <logger name="foo">
- <appender_ref ref="A2" />
- <appender_ref ref="A3" />
- </logger>
- <logger name="foo.bar" />
- <logger name="foo.bar.baz" additivity="false">
- <appender_ref ref="A4" />
- </logger>
-</configuration>
-]]></pre>
- <p>The table below shows how the configuration is interpreted, and which appenders are inherited:</p>
-
- <table>
- <thead>
- <tr>
- <th>Logger name</th>
- <th>Linked appenders</th>
- <th>Additivity flag</th>
- <th>Output targets</th>
- <th>Comment</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>root</td>
- <td>A1</td>
- <td>N/A</td>
- <td>A1</td>
- <td>One appender, named A1, is added to root logger. Any logging requests to root logger
- will be forwarded only to that one appender.</td>
- </tr>
- <tr>
- <td>foo</td>
- <td>A2, A3</td>
- <td>true</td>
- <td>A1, A2, A3</td>
- <td>A logger named <code>foo</code> is created and two appenders, named A2 and A3, are
- added to it. Additionally, because of logger additivity, <code>foo</code> inherits the
- appender A1 from the root logger which is it's parent in the logger hierarchy. Therefore
- logging requests to this logger will be forwarded to appenders A1, A2 and A3.</td>
- </tr>
- <tr>
- <td>foo.bar</td>
- <td>none</td>
- <td>true</td>
- <td>A1, A2, A3</td>
- <td>A logger named <code>foo.bar</code> is created. Because it's name starts with
- <code>foo</code>, it will be created as a child of the <code>foo</code> logger.
- No appenders are added to <code>foo.bar</code> but it will inherit it's ancestor's
- appenders: appenders A2 and A3 from <code>foo</code> and A1 from <code>root</code>.
- Logging requests to this logger will be forwarded to appenders A1, A2 and A3.</td>
- </tr>
- <tr>
- <td>foo.bar.baz</td>
- <td>A4</td>
- <td>false</td>
- <td>A4</td>
- <td>Finally, logger <code>foo.bar.baz</code> is created, and because of it's name it is
- created as child to <code>foo.bar</code>. One appender, A4 is added to it. However, since
- it's additivity flag is set to <em>false</em>, it will not inherit any appenders from it's
- ancestors. Logging requests to this logger will be forwarded only to appender A4.</td>
- </tr>
- </tbody>
-
- </table>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/docs/renderers.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/docs/renderers.xml b/src/site/xdoc/docs/renderers.xml
deleted file mode 100644
index 6c1b921..0000000
--- a/src/site/xdoc/docs/renderers.xml
+++ /dev/null
@@ -1,218 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Renderers</title>
- </properties>
-
- <body>
- <section name="Renderers">
- <p>Apache log4php can log more than just string messages. If you try to log an object it will be converted
- to a string and logged. The component which converts Objects to strings in log4php is called a
- <em>renderer</em>.</p>
-
- <subsection name="Default renderer">
-
- <p>For example, let's say that an application uses a Person object, like this one:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-class Person {
- public $firstName;
- public $lastName;
- public $age;
-}
-]]></pre>
-
- <p>If you try logging it:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-$person = new Person();
-$person->firstName = 'John';
-$person->lastName = 'Doe';
-$person->age = 37;
-
-$logger = Logger::getLogger('main');
-$logger->info("Here comes the person:");
-$logger->info($person);
-]]></pre>
- <p>Log4php will render it using the default renderer and you will end the output will look something
- like:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-INFO - Here comes the person:
-INFO - Person Object
-(
- [firstName] => John
- [lastName] => Doe
- [age] => 37
-)
-]]></pre>
-
- </subsection>
-
- <subsection name="Creating a custom renderer">
- <p>In order to make log4php log the Person object in a more readable format, a custom renderer
- class can be defined which will convert Person objects to a string suitable for logging.</p>
-
- <p>Let's call this renderer class PersonRenderer.</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-/** All renderers must implement the LoggerRenderer interface. */
-class PersonRenderer implements LoggerRenderer {
- public function render($person) {
- return "{$person->firstName} {$person->lastName} ({$person->age})";
- }
-}
-]]></pre>
-
- <p>Now log4php has to be configured to use PersonRenderer for rendering Person objects. This is done
- in the configuration file.</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content">
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <renderer renderedClass="Person" renderingClass="PersonRenderer" />
- <appender name="defualt" class="LoggerAppenderEcho" />
- <root>
- <appender_ref ref="defualt" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'renderers' => array(
- array(
- 'renderedClass' => 'Person',
- 'renderingClass' => 'PersonRenderer'
- )
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
-
- <p>If the same code is run as above, the following output is produced:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-INFO - Here comes the person:
-INFO - John Doe (37)
-]]></pre>
- <p>Which is much more readable than the default rendering.</p>
- </subsection>
-
- <subsection name="Overriding the default renderer">
- <p>It is possible to set your own custom renderer as the default renderer.</p>
-
- <p>For example, if you're not happy with the way in which the default renderer converts objects,
- you can create your own renderer:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-class MyRenderer implements LoggerRenderer {
- public function render($input) {
- return var_dump($input);
- }
-}
-]]></pre>
-
- <p>And set it as the default renderer in the configuration:</p>
-
- <div class="auto-tabs">
- <ul>
- <li>XML</li>
- <li>PHP</li>
- </ul>
-
- <div class="tab-content">
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <defaultRenderer renderingClass="MyRenderer" />
- <appender name="defualt" class="LoggerAppenderEcho" />
- <root>
- <appender_ref ref="defualt" />
- </root>
-</configuration>
-]]></pre>
- </div>
- <div class="tab-pane">
-<pre class="prettyprint linenums"><![CDATA[
-array(
- 'defaultRenderer' => 'MyRenderer',
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
-)
-]]></pre>
- </div>
- </div>
- </div>
-
- <p>Logging a Person object using this configuration will make log4php fall back to the newly
- defined default renderer, which uses <code>var_dump</code> instead of <code>print_r</code>, and
- the result will look like:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-INFO - Here comes the person:
-class Person#5 (3) {
- public $firstName =>
- string(4) "John"
- public $lastName =>
- string(3) "Doe"
- public $age =>
- int(37)
-}
-]]></pre>
- </subsection>
-
- <subsection name="Class hierarchy">
- <p>Object rendering follows the class hierarchy. </p>
-
- <p>For example, if there is a class named Fruit, and classes Orange, Lemon and Apple all extend Fruit.
- When FruitRenderer is registered as renderer for the Fruit class, all subclasses of Fruit will also
- be rendered by FruitRenderer. Of course, it is possible to override this by registering OrangeRenderer
- as renderer for the Orange class.</p>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/install.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/install.xml b/src/site/xdoc/install.xml
deleted file mode 100644
index 82572c2..0000000
--- a/src/site/xdoc/install.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Installing</title>
- </properties>
-
- <body>
- <section name="Installing">
-
- <subsection name="From source package">
-
- <p>Download the latest source package from the <a href="download.html">download page</a> and unpack it.</p>
-
- <p>The package directory structure is as follows:</p>
-
-<pre>
-├───apidocs - API generated documentation
-└───src
- ├───assembly - Maven assembly configuration
- ├───changes - The change log
- ├───examples - Various usage examples
- ├───main
- │ └───php - The main source code
- ├───site - Web site source
- └───test - Unit tests
-</pre>
- <p>Most users will primarily be interested in the source code which is located in
- <code>/src/main/php</code>. The contents of this directory may be copied to a directory within your
- project for easier access.</p>
-
- </subsection>
-
- <subsection name="From PEAR repository">
-
- <p>Apache log4php has it's own <a href="http://pear.apache.org/log4php/index.html">PEAR channel</a>.</p>
-
- <p>To install from the PEAR channel, execute the following commands:</p>
-
-<pre>
-pear channel-discover pear.apache.org/log4php
-pear install log4php/Apache_log4php
-</pre>
-
- </subsection>
-
- <subsection name="From Composer">
-
- <p>Apache log4php is available from <a href="https://packagist.org/packages/apache/log4php">Packagist</a> via <a href="http://getcomposer.org/">Composer</a>. Please note: this channel is not an official Apache Software Foundation channel,
- but maintained from Apache log4php committers.</p>
-
- <p>To with compoers, add the following lines to composer.json:</p>
-
-<pre>
-"require": {
- "apache/log4php": "2.3.0"
-}
-</pre>
- <p>Then run:</p>
-
-<pre>
-php composer.phar install
-</pre>
- <p>Or, if you have composer installed as binary:</p>
-
-<pre>
-composer install
-</pre>
- </subsection>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/privacy.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/privacy.xml b/src/site/xdoc/privacy.xml
deleted file mode 100644
index 523c79f..0000000
--- a/src/site/xdoc/privacy.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Privacy policy</title>
- </properties>
-
- <body>
- <section name="Privacy policy">
- <p>Information about your use of this web site is collected using server access logs and a tracking cookie.
- The collected information consists of the following:</p>
-
- <ul>
- <li>The IP address from which you access the web site;</li>
- <li>The type of browser and operating system you use to access our site;</li>
- <li>The date and time you access our site;</li>
- <li>The pages you visit; and</li>
- <li>The addresses of pages from where you followed a link to our site.</li>
- </ul>
-
- <p>Part of this information is gathered using a tracking cookie set by the
- <a href="http://www.google.com/analytics" class="external">Google Analytics</a> service and handled by
- Google as described in their
- <a href="http://www.google.com/privacy.html" class="external">privacy policy</a>.
- See your browser documentation for instructions on how to disable the cookie if you prefer not to share
- this data with Google.</p>
-
- <p>We use the gathered information to help us make our site more useful to visitors and to better understand how
- and when our site is used. We do not track or collect personally identifiable information or associate gathered
- data with any personally identifying information from other sources.</p>
-
- <p>By using this web site, you consent to the collection of this data in the manner and for the purpose described
- above.</p>
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/xdoc/quickstart.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/quickstart.xml b/src/site/xdoc/quickstart.xml
deleted file mode 100644
index cc54eab..0000000
--- a/src/site/xdoc/quickstart.xml
+++ /dev/null
@@ -1,208 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Quick start</title>
- </properties>
-
- <body>
- <section name="Quick start">
-
- <p>First, <a href="install.html">install Apache log4php</a>.</p>
-
- <p>You may also like to read the <a href="docs/introduction.html">introduction chapter</a> to familiarise
- yoursef with the basic concepts used throughout the documentation and examples.</p>
-
- <subsection name="A trivial example">
- <p>Just want logging to stdout?</p>
-
-<pre class="prettyprint linenums">
-include('Logger.php');
-$logger = Logger::getLogger("main");
-$logger->info("This is an informational message.");
-$logger->warn("I'm not feeling so good...");
-</pre>
-
- <p>This produces the following output:</p>
-
-<pre>
-INFO - This is an informational message.
-WARN - I'm not feeling so good...
-</pre>
-
- </subsection>
-
- <subsection name="A simple example">
- <p>This example shows how to configure log4php using an XML configuration file. The framework will be
- configured to log messages to a file, but only those with level greater or equal to <code>WARN</code>.
- </p>
-
- <p>First, create a configuration file named <code>config.xml</code> containing:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="myAppender" class="LoggerAppenderFile">
- <param name="file" value="myLog.log" />
- </appender>
- <root>
- <level value="WARN" />
- <appender_ref ref="myAppender" />
- </root>
-</configuration>
-]]></pre>
-
- <p>This configuration file does the following:</p>
-
- <ul>
- <li><em>line 2</em>: Creates an appender named <code>myAppender</code> using appender class <code>
- <a href="docs/appenders/file.html">LoggerAppenderFile</a></code> which is used for
- logging to a file.</li>
-
- <li><em>line 3</em>: Sets the <code>file</code> parameter, which tells the appender to which file to
- write.</li>
-
- <li><em>line 6</em>: Sets the root logger level to <code>WARN</code>. This means that logging requests
- with the level lower than <code>WARN</code> will not be logged by the root logger.</li>
-
- <li><em>line 7</em>: Links <code>myAppender</code> to the root logger so that all events recieved by the root
- logger will be forwarded to <code>myAppender</code> and written into the log file.</li>
- </ul>
-
- <p>To try it out, run the following code:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-// Insert the path where you unpacked log4php
-include('log4php/Logger.php');
-
-// Tell log4php to use our configuration file.
-Logger::configure('config.xml');
-
-// Fetch a logger, it will inherit settings from the root logger
-$log = Logger::getLogger('myLogger');
-
-// Start logging
-$log->trace("My first message."); // Not logged because TRACE < WARN
-$log->debug("My second message."); // Not logged because DEBUG < WARN
-$log->info("My third message."); // Not logged because INFO < WARN
-$log->warn("My fourth message."); // Logged because WARN >= WARN
-$log->error("My fifth message."); // Logged because ERROR >= WARN
-$log->fatal("My sixth message."); // Logged because FATAL >= WARN
-]]></pre>
-
- <p>This will create a file named <code>myLog.log</code> containing the following output:</p>
-
-<pre><![CDATA[
-WARN - My fourth message.
-ERROR - My fifth message.
-FATAL - My sixth message.
-]]></pre>
-
- </subsection>
-
- <subsection name="An advanced example">
-
- <p>This example covers named loggers, layouts and best practices in object-oriented programming.</p>
-
- <p>Create a configuration file named <code>config.xml</code> with the following content:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-<configuration xmlns="http://logging.apache.org/log4php/">
-
- <appender name="myConsoleAppender" class="LoggerAppenderConsole" />
-
- <appender name="myFileAppender" class="LoggerAppenderFile">
- <layout class="LoggerLayoutPattern">
- <param name="conversionPattern" value="%date [%logger] %message%newline" />
- </layout>
- <param name="file" value="myLog.log" />
- </appender>
-
- <logger name="Foo">
- <appender_ref ref="myFileAppender" />
- </logger>
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="myConsoleAppender" />
- </root>
-</configuration>
-]]></pre>
-
- <p>The configuration defines two appenders: one writes to the console, and the other to a file.</p>
-
- <p>The
- console appender doesn't have a layout defined, so it will revert to default layout
- (<code><a href="docs/layouts/simple.html">LoggerLayoutSimple</a></code>). The
- file appender uses a different layout
- (<code><a href="docs/layouts/pattern.html">LoggerLayoutPattern</a></code>)
- which will result in different formatting of the logging
- events.</p>
-
- <p>The console appender is linked to the root logger. The file appender is linked to the logger named
- <code>Foo</code>, however <code>Foo</code> also inherits appenders from the root logger (in this case
- the console appender). This means that logging events sent to the <code>Foo</code> logger will be
- logged both to the console and the file.</p>
-
- <p>Consider the following code snippet:</p>
-
-<pre class="prettyprint linenums"><![CDATA[
-// Include and configure log4php
-include('log4php/Logger.php');
-Logger::configure('config.xml');
-
-/**
- * This is a classic usage pattern: one logger object per class.
- */
-class Foo
-{
- /** Holds the Logger. */
- private $log;
-
- /** Logger is instantiated in the constructor. */
- public function __construct()
- {
- // The __CLASS__ constant holds the class name, in our case "Foo".
- // Therefore this creates a logger named "Foo" (which we configured in the config file)
- $this->log = Logger::getLogger(__CLASS__);
- }
-
- /** Logger can be used from any member method. */
- public function go()
- {
- $this->log->info("We have liftoff.");
- }
-}
-
-$foo = new Foo();
-$foo->go();
-]]></pre>
-
- <p>This produces the following output in the console:</p>
- <pre>INFO - We have liftoff.</pre>
-
- <p>And the following in the log file:</p>
- <pre>01/06/11 18:43:39,545 [5428] INFO Foo - We have liftoff.</pre>
-
- <p>Note the different layout, this is because LoggerLayoutTTCC was used as layout for the file appender.</p>
- </subsection>
-
- </section>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/config/phpunit_to_surefire.xslt
----------------------------------------------------------------------
diff --git a/src/test/config/phpunit_to_surefire.xslt b/src/test/config/phpunit_to_surefire.xslt
deleted file mode 100644
index 1f8fd61..0000000
--- a/src/test/config/phpunit_to_surefire.xslt
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<xsl:stylesheet version="2.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:fn="http://www.w3.org/2005/xpath-functions">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
- <xsl:param name="outputDir">.</xsl:param>
-
- <xsl:template match="testsuites">
- <xsl:apply-templates select="testsuite" />
- </xsl:template>
-
- <xsl:template match="testsuite">
- <xsl:if test="testcase">
- <xsl:variable name="outputName" select="./@name" />
- <xsl:result-document href="{$outputDir}/{$outputName}.xml" method="xml">
- <xsl:copy-of select="." />
- </xsl:result-document>
- </xsl:if>
-
- <xsl:apply-templates select="testsuite" />
- </xsl:template>
-</xsl:stylesheet>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerAppenderPoolTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerAppenderPoolTest.php b/src/test/php/LoggerAppenderPoolTest.php
deleted file mode 100644
index 89aecff..0000000
--- a/src/test/php/LoggerAppenderPoolTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage filters
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group filters
- */
-class LoggerAppenderPoolTest extends PHPUnit_Framework_TestCase {
-
- private $appenderMock;
-
- public function setUp() {
- $this->appenderMock = $this->getMock('LoggerAppenderConsole', array(), array(), '', false);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Cannot add unnamed appender to pool.
- */
- public function testAppenderHasNoName() {
- $this->appenderMock->expects($this->once())
- ->method('getName')
- ->will($this->returnValue(''));
-
- LoggerAppenderPool::add($this->appenderMock);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Appender [foo] already exists in pool. Overwriting existing appender.
- */
- public function testAppenderIsAdded() {
- $this->appenderMock->expects($this->any())
- ->method('getName')
- ->will($this->returnValue('foo'));
-
- LoggerAppenderPool::add($this->appenderMock);
- LoggerAppenderPool::add($this->appenderMock);
-
- $expected = 1;
- $actual = count(LoggerAppenderPool::getAppenders());
- $this->assertEquals($expected, $actual);
- }
-}
[30/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/ConfiguratorTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ConfiguratorTest.php b/tests/src/ConfiguratorTest.php
index b6fb802..d38cc0c 100644
--- a/tests/src/ConfiguratorTest.php
+++ b/tests/src/ConfiguratorTest.php
@@ -30,8 +30,9 @@ use Apache\Log4php\Configuration\DefaultConfigurator;
use Mockery as m;
-class CostumDefaultRenderer implements RendererInterface {
- public function render($o) { }
+class CostumDefaultRenderer implements RendererInterface
+{
+ public function render($o) { }
}
/**
@@ -39,68 +40,74 @@ class CostumDefaultRenderer implements RendererInterface {
*/
class ConfiguratorTest extends \PHPUnit_Framework_TestCase
{
- /** Reset configuration after each test. */
- public function setUp() {
- Logger::resetConfiguration();
- }
- /** Reset configuration after each test. */
- public function tearDown() {
- Logger::resetConfiguration();
- }
-
- /** Check default setup. */
- public function testDefaultConfig() {
- Logger::configure();
-
- $actual = Logger::getCurrentLoggers();
- $expected = array();
- $this->assertSame($expected, $actual);
-
- $appenders = Logger::getRootLogger()->getAllAppenders();
- $this->assertInternalType('array', $appenders);
- $this->assertEquals(count($appenders), 1);
-
- $names = array_keys($appenders);
- $this->assertSame('default', $names[0]);
-
- $appender = array_shift($appenders);
- $this->assertInstanceOf('Apache\\Log4php\\Appenders\\EchoAppender', $appender);
- $this->assertSame('default', $appender->getName());
-
- $layout = $appender->getLayout();
- $this->assertInstanceOf('Apache\\Log4php\\Layouts\\SimpleLayout', $layout);
-
- $root = Logger::getRootLogger();
- $appenders = $root->getAllAppenders();
- $this->assertInternalType('array', $appenders);
- $this->assertEquals(count($appenders), 1);
-
- $actual = $root->getLevel();
- $expected = Level::getLevelDebug();
- $this->assertEquals($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid configuration param given. Reverting to default configuration.
- */
- public function testInputIsInteger() {
- Logger::configure(12345);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Configuration failed. Unsupported configuration file extension: yml
- */
- public function testYAMLFile() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/config.yml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid configuration provided for appender
- */
- public function testAppenderConfigNotArray() {
+ /** Reset configuration after each test. */
+ public function setUp()
+ {
+ Logger::resetConfiguration();
+ }
+ /** Reset configuration after each test. */
+ public function tearDown()
+ {
+ Logger::resetConfiguration();
+ }
+
+ /** Check default setup. */
+ public function testDefaultConfig()
+ {
+ Logger::configure();
+
+ $actual = Logger::getCurrentLoggers();
+ $expected = array();
+ $this->assertSame($expected, $actual);
+
+ $appenders = Logger::getRootLogger()->getAllAppenders();
+ $this->assertInternalType('array', $appenders);
+ $this->assertEquals(count($appenders), 1);
+
+ $names = array_keys($appenders);
+ $this->assertSame('default', $names[0]);
+
+ $appender = array_shift($appenders);
+ $this->assertInstanceOf('Apache\\Log4php\\Appenders\\EchoAppender', $appender);
+ $this->assertSame('default', $appender->getName());
+
+ $layout = $appender->getLayout();
+ $this->assertInstanceOf('Apache\\Log4php\\Layouts\\SimpleLayout', $layout);
+
+ $root = Logger::getRootLogger();
+ $appenders = $root->getAllAppenders();
+ $this->assertInternalType('array', $appenders);
+ $this->assertEquals(count($appenders), 1);
+
+ $actual = $root->getLevel();
+ $expected = Level::getLevelDebug();
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid configuration param given. Reverting to default configuration.
+ */
+ public function testInputIsInteger()
+ {
+ Logger::configure(12345);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Configuration failed. Unsupported configuration file extension: yml
+ */
+ public function testYAMLFile()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/config.yml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid configuration provided for appender
+ */
+ public function testAppenderConfigNotArray()
+ {
$config = array(
'appenders' => array(
'default',
@@ -110,344 +117,362 @@ class CostumDefaultRenderer implements RendererInterface {
$hierachyMock = m::mock("Apache\\Log4php\\Hierarchy");
$configurator = new DefaultConfigurator();
$configurator->configure($hierachyMock, $config);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage No class given for appender
- */
- public function testNoAppenderClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid class [unknownClass] given for appender [foo]. Class does not exist. Skipping appender definition.
- */
- public function testNotExistingAppenderClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid class [stdClass] given for appender [foo]. Not a valid Appender class. Skipping appender definition.
- */
- public function testInvalidAppenderClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_appender_class.xml');
- }
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage No class given for appender
+ */
+ public function testNoAppenderClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid class [unknownClass] given for appender [foo]. Class does not exist. Skipping appender definition.
+ */
+ public function testNotExistingAppenderClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid class [stdClass] given for appender [foo]. Not a valid Appender class. Skipping appender definition.
+ */
+ public function testInvalidAppenderClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_appender_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistant filter class [Foo] specified on appender [foo]. Skipping filter definition.
- */
- public function testNotExistingAppenderFilterClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_filter_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistant filter class [Foo] specified on appender [foo]. Skipping filter definition.
+ */
+ public function testNotExistingAppenderFilterClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_filter_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistant option [fooParameter] specified on [Apache\Log4php\Filters\StringMatchFilter]. Skipping.
- */
- public function testInvalidAppenderFilterParamter() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_parameters.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistant option [fooParameter] specified on [Apache\Log4php\Filters\StringMatchFilter]. Skipping.
+ */
+ public function testInvalidAppenderFilterParamter()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_parameters.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid filter class [stdClass] sepcified on appender [foo]. Skipping filter definition.
- */
- public function testInvalidAppenderFilterClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid filter class [stdClass] sepcified on appender [foo]. Skipping filter definition.
+ */
+ public function testInvalidAppenderFilterClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistant layout class [Foo] specified for appender [foo]. Reverting to default layout.
- */
- public function testNotExistingAppenderLayoutClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_layout_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistant layout class [Foo] specified for appender [foo]. Reverting to default layout.
+ */
+ public function testNotExistingAppenderLayoutClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_layout_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid layout class [stdClass] sepcified for appender [foo]. Reverting to default layout.
- */
- public function testInvalidAppenderLayoutClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_layout_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid layout class [stdClass] sepcified for appender [foo]. Reverting to default layout.
+ */
+ public function testInvalidAppenderLayoutClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_layout_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Layout class not specified for appender [foo]. Reverting to default layout.
- */
- public function testNoAppenderLayoutClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_layout_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Layout class not specified for appender [foo]. Reverting to default layout.
+ */
+ public function testNoAppenderLayoutClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_layout_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
- */
- public function testInvalidRenderingClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_invalid_rendering_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ */
+ public function testInvalidRenderingClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_invalid_rendering_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Rendering class not specified. Skipping renderer definition.
- */
- public function testNoRenderingClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendering_class.xml');
- }
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Rendering class not specified. Skipping renderer definition.
+ */
+ public function testNoRenderingClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendering_class.xml');
+ }
/**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Rendered class not specified. Skipping renderer definition.
- */
- public function testNoRenderedClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendered_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExistRenderer] not found.
- */
- public function testNotExistingRenderingClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_not_existing_rendering_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid additivity value [4711] specified for logger [myLogger].
- */
- public function testInvalidLoggerAddivity() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_invalid_additivity.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistnant appender [unknownAppender] linked to logger [myLogger].
- */
- public function testNotExistingLoggerAppendersClass() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_not_existing_appenders.xml');
- }
-
- /**
- * Test that an error is reported when config file is not found.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Configuration failed. File not found
- */
- public function testNonexistantFile() {
- Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
-
- }
-
- /** Test correct fallback to the default configuration. */
- public function testNonexistantFileFallback() {
- @Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
- $this->testDefaultConfig();
- }
-
- public function testAppendersWithLayout() {
- $config = Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('app1', 'app2')
- ),
- 'loggers' => array(
- 'myLogger' => array(
- 'appenders' => array('app1'),
- 'additivity'=> true
- )
- ),
- 'renderers' => array(
- array('renderedClass' => 'stdClass', 'renderingClass' => 'DefaultRenderer')
- ),
- 'appenders' => array(
- 'app1' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- ),
- 'params' => array(
- 'htmlLineBreaks' => false
- )
- ),
- 'app2' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'PatternLayout',
- 'params' => array(
- 'conversionPattern' => 'message: %m%n'
- )
- ),
- 'filters' => array(
- array(
- 'class' => 'StringMatchFilter',
- 'params'=> array(
- 'stringToMatch' => 'foo',
- 'acceptOnMatch' => false
- )
- )
- )
- ),
- )
- ));
-
- ob_start();
- Logger::getRootLogger()->info('info');
- $actual = ob_get_contents();
- ob_end_clean();
-
- $expected = "INFO - info" . PHP_EOL . "message: info" . PHP_EOL;
- $this->assertSame($expected, $actual);
- }
-
- public function testThreshold()
- {
- Logger::configure(array(
- 'threshold' => 'WARN',
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- ),
- )
- ));
-
- $actual = Logger::getHierarchy()->getThreshold();
- $expected = Level::getLevelWarn();
-
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid threshold value [FOO] specified. Ignoring threshold definition.
- */
- public function testInvalidThreshold()
- {
- Logger::configure(array(
- 'threshold' => 'FOO',
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- ),
- )
- ));
- }
-
- public function testAppenderThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'threshold' => 'INFO'
- ),
- )
- ));
-
- $actual = Logger::getRootLogger()->getAppender('default')->getThreshold();
- $expected = Level::getLevelInfo();
-
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid threshold value [FOO] specified for appender [default]. Ignoring threshold definition.
- */
- public function testAppenderInvalidThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'threshold' => 'FOO'
- ),
- )
- ));
- }
-
- public function testLoggerThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- 'level' => 'ERROR'
- ),
- 'loggers' => array(
- 'default' => array(
- 'appenders' => array('default'),
- 'level' => 'WARN'
- )
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- ),
- )
- ));
-
- // Check root logger
- $actual = Logger::getRootLogger()->getLevel();
- $expected = Level::getLevelError();
- self::assertSame($expected, $actual);
-
- // Check default logger
- $actual = Logger::getLogger('default')->getLevel();
- $expected = Level::getLevelWarn();
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid level value [FOO] specified for logger [default]. Ignoring level definition.
- */
- public function testInvalidLoggerThreshold()
- {
- Logger::configure(array(
- 'loggers' => array(
- 'default' => array(
- 'appenders' => array('default'),
- 'level' => 'FOO'
- )
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- ),
- )
- ));
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid level value [FOO] specified for logger [root]. Ignoring level definition.
- */
- public function testInvalidRootLoggerThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- 'level' => 'FOO'
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- ),
- )
- ));
- }
- }
\ No newline at end of file
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Rendered class not specified. Skipping renderer definition.
+ */
+ public function testNoRenderedClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendered_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExistRenderer] not found.
+ */
+ public function testNotExistingRenderingClassSet()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_not_existing_rendering_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid additivity value [4711] specified for logger [myLogger].
+ */
+ public function testInvalidLoggerAddivity()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_invalid_additivity.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistnant appender [unknownAppender] linked to logger [myLogger].
+ */
+ public function testNotExistingLoggerAppendersClass()
+ {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_not_existing_appenders.xml');
+ }
+
+ /**
+ * Test that an error is reported when config file is not found.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Configuration failed. File not found
+ */
+ public function testNonexistantFile()
+ {
+ Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
+
+ }
+
+ /** Test correct fallback to the default configuration. */
+ public function testNonexistantFileFallback()
+ {
+ @Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
+ $this->testDefaultConfig();
+ }
+
+ public function testAppendersWithLayout()
+ {
+ $config = Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('app1', 'app2')
+ ),
+ 'loggers' => array(
+ 'myLogger' => array(
+ 'appenders' => array('app1'),
+ 'additivity'=> true
+ )
+ ),
+ 'renderers' => array(
+ array('renderedClass' => 'stdClass', 'renderingClass' => 'DefaultRenderer')
+ ),
+ 'appenders' => array(
+ 'app1' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array(
+ 'htmlLineBreaks' => false
+ )
+ ),
+ 'app2' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => 'message: %m%n'
+ )
+ ),
+ 'filters' => array(
+ array(
+ 'class' => 'StringMatchFilter',
+ 'params'=> array(
+ 'stringToMatch' => 'foo',
+ 'acceptOnMatch' => false
+ )
+ )
+ )
+ ),
+ )
+ ));
+
+ ob_start();
+ Logger::getRootLogger()->info('info');
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $expected = "INFO - info" . PHP_EOL . "message: info" . PHP_EOL;
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testThreshold()
+ {
+ Logger::configure(array(
+ 'threshold' => 'WARN',
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+
+ $actual = Logger::getHierarchy()->getThreshold();
+ $expected = Level::getLevelWarn();
+
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid threshold value [FOO] specified. Ignoring threshold definition.
+ */
+ public function testInvalidThreshold()
+ {
+ Logger::configure(array(
+ 'threshold' => 'FOO',
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+ }
+
+ public function testAppenderThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'threshold' => 'INFO'
+ ),
+ )
+ ));
+
+ $actual = Logger::getRootLogger()->getAppender('default')->getThreshold();
+ $expected = Level::getLevelInfo();
+
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid threshold value [FOO] specified for appender [default]. Ignoring threshold definition.
+ */
+ public function testAppenderInvalidThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'threshold' => 'FOO'
+ ),
+ )
+ ));
+ }
+
+ public function testLoggerThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ 'level' => 'ERROR'
+ ),
+ 'loggers' => array(
+ 'default' => array(
+ 'appenders' => array('default'),
+ 'level' => 'WARN'
+ )
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+
+ // Check root logger
+ $actual = Logger::getRootLogger()->getLevel();
+ $expected = Level::getLevelError();
+ self::assertSame($expected, $actual);
+
+ // Check default logger
+ $actual = Logger::getLogger('default')->getLevel();
+ $expected = Level::getLevelWarn();
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid level value [FOO] specified for logger [default]. Ignoring level definition.
+ */
+ public function testInvalidLoggerThreshold()
+ {
+ Logger::configure(array(
+ 'loggers' => array(
+ 'default' => array(
+ 'appenders' => array('default'),
+ 'level' => 'FOO'
+ )
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid level value [FOO] specified for logger [root]. Ignoring level definition.
+ */
+ public function testInvalidRootLoggerThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ 'level' => 'FOO'
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+ }
+ }
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Configurators/INIAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/INIAdapterTest.php b/tests/src/Configurators/INIAdapterTest.php
index 92d2380..5b950e4 100644
--- a/tests/src/Configurators/INIAdapterTest.php
+++ b/tests/src/Configurators/INIAdapterTest.php
@@ -30,148 +30,152 @@ use Apache\Log4php\LoggerException;
/**
* @group configuration
*/
-class INIAdapterTest extends \PHPUnit_Framework_TestCase {
-
- /** Expected output of parsing config1.ini. */
- private $expected1 = array(
- 'threshold' => 'debug',
- 'rootLogger' => array(
- 'level' => 'DEBUG',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'LoggerLayoutTTCC',
- ),
- ),
- 'file' => array(
- 'class' => 'DailyFileAppender',
- 'layout' => array(
- 'class' => 'PatternLayout',
- 'params' => array(
- 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
- ),
- ),
- 'params' => array(
- 'datePattern' => 'Ymd',
- 'file' => 'target/examples/daily_%s.log',
- ),
- 'threshold' => 'warn'
- ),
- ),
- 'loggers' => array(
- 'foo' => array(
- 'level' => 'warn',
- 'appenders' => array('default'),
- ),
- 'foo.bar' => array(
- 'level' => 'debug',
- 'appenders' => array('file'),
- 'additivity' => 'true',
- ),
- 'foo.bar.baz' => array(
- 'level' => 'trace',
- 'appenders' => array('default', 'file'),
- 'additivity' => 'false',
- ),
- ),
- 'renderers' => array(
- array(
- 'renderedClass' => 'Fruit',
- 'renderingClass' => 'FruitRenderer',
- ),
- array(
- 'renderedClass' => 'Beer',
- 'renderingClass' => 'BeerRenderer',
- ),
- ),
- );
-
- public function testConfig() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_valid.ini';
- $adapter = new IniAdapter();
- $actual = $adapter->convert($url);
-
- $this->assertSame($this->expected1, $actual);
- }
-
- /**
- * Test exception is thrown when file cannot be found.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage File [you/will/never/find/me.ini] does not exist.
- */
- public function testNonExistantFileException() {
- $adapter = new IniAdapter();
- $adapter->convert('you/will/never/find/me.ini');
- }
-
- /**
- * Test exception is thrown when file is not a valid ini file.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage Error parsing configuration file
- */
- public function testInvalidFileException() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_syntax.ini';
- $adapter = new IniAdapter();
- $adapter->convert($url);
- }
-
- /**
- * Test a warning is triggered when configurator doesn't understand a line.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.layout.param.bla = LoggerLayoutTTCC". Skipping.
- */
- public function testInvalidLineWarning1() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_1.ini';
- $adapter = new IniAdapter();
- $adapter->convert($url);
- }
-
- /**
- * Test a warning is triggered when configurator doesn't understand a line.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.not-layout.param = LoggerLayoutTTCC". Skipping.
- */
- public function testInvalidLineWarning2() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_2.ini';
- $adapter = new IniAdapter();
- $adapter->convert($url);
- }
-
- /**
- * Check that various boolean equivalents from ini file convert properly
- * to boolean.
- */
- public function testBooleanValues() {
- $values = parse_ini_file(PHPUNIT_CONFIG_DIR . '/adapters/ini/values.ini');
-
- $actual = OptionConverter::toBooleanEx($values['unquoted_true']);
- self::assertTrue($actual);
-
- $actual = OptionConverter::toBooleanEx($values['unquoted_yes']);
- self::assertTrue($actual);
-
- $actual = OptionConverter::toBooleanEx($values['unquoted_false']);
- self::assertFalse($actual);
-
- $actual = OptionConverter::toBooleanEx($values['unquoted_no']);
- self::assertFalse($actual);
-
- $actual = OptionConverter::toBooleanEx($values['quoted_true']);
- self::assertTrue($actual);
-
- $actual = OptionConverter::toBooleanEx($values['quoted_false']);
- self::assertFalse($actual);
-
- $actual = OptionConverter::toBooleanEx($values['unquoted_one']);
- self::assertTrue($actual);
-
- $actual = OptionConverter::toBooleanEx($values['unquoted_zero']);
- self::assertFalse($actual);
- }
+class INIAdapterTest extends \PHPUnit_Framework_TestCase
+{
+ /** Expected output of parsing config1.ini. */
+ private $expected1 = array(
+ 'threshold' => 'debug',
+ 'rootLogger' => array(
+ 'level' => 'DEBUG',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'LoggerLayoutTTCC',
+ ),
+ ),
+ 'file' => array(
+ 'class' => 'DailyFileAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
+ ),
+ ),
+ 'params' => array(
+ 'datePattern' => 'Ymd',
+ 'file' => 'target/examples/daily_%s.log',
+ ),
+ 'threshold' => 'warn'
+ ),
+ ),
+ 'loggers' => array(
+ 'foo' => array(
+ 'level' => 'warn',
+ 'appenders' => array('default'),
+ ),
+ 'foo.bar' => array(
+ 'level' => 'debug',
+ 'appenders' => array('file'),
+ 'additivity' => 'true',
+ ),
+ 'foo.bar.baz' => array(
+ 'level' => 'trace',
+ 'appenders' => array('default', 'file'),
+ 'additivity' => 'false',
+ ),
+ ),
+ 'renderers' => array(
+ array(
+ 'renderedClass' => 'Fruit',
+ 'renderingClass' => 'FruitRenderer',
+ ),
+ array(
+ 'renderedClass' => 'Beer',
+ 'renderingClass' => 'BeerRenderer',
+ ),
+ ),
+ );
+
+ public function testConfig()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_valid.ini';
+ $adapter = new IniAdapter();
+ $actual = $adapter->convert($url);
+
+ $this->assertSame($this->expected1, $actual);
+ }
+
+ /**
+ * Test exception is thrown when file cannot be found.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage File [you/will/never/find/me.ini] does not exist.
+ */
+ public function testNonExistantFileException()
+ {
+ $adapter = new IniAdapter();
+ $adapter->convert('you/will/never/find/me.ini');
+ }
+
+ /**
+ * Test exception is thrown when file is not a valid ini file.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Error parsing configuration file
+ */
+ public function testInvalidFileException()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_syntax.ini';
+ $adapter = new IniAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test a warning is triggered when configurator doesn't understand a line.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.layout.param.bla = LoggerLayoutTTCC". Skipping.
+ */
+ public function testInvalidLineWarning1()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_1.ini';
+ $adapter = new IniAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test a warning is triggered when configurator doesn't understand a line.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.not-layout.param = LoggerLayoutTTCC". Skipping.
+ */
+ public function testInvalidLineWarning2()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_2.ini';
+ $adapter = new IniAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Check that various boolean equivalents from ini file convert properly
+ * to boolean.
+ */
+ public function testBooleanValues()
+ {
+ $values = parse_ini_file(PHPUNIT_CONFIG_DIR . '/adapters/ini/values.ini');
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_true']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_yes']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_false']);
+ self::assertFalse($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_no']);
+ self::assertFalse($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['quoted_true']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['quoted_false']);
+ self::assertFalse($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_one']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_zero']);
+ self::assertFalse($actual);
+ }
}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Configurators/PHPAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/PHPAdapterTest.php b/tests/src/Configurators/PHPAdapterTest.php
index 2b79826..dbcf2c2 100644
--- a/tests/src/Configurators/PHPAdapterTest.php
+++ b/tests/src/Configurators/PHPAdapterTest.php
@@ -29,73 +29,76 @@ use Apache\Log4php\Configuration\Adapters\PhpAdapter;
/**
* @group configuration
*/
-class PHPAdapterTest extends \PHPUnit_Framework_TestCase {
+class PHPAdapterTest extends \PHPUnit_Framework_TestCase
+{
+ private $expected1 = array(
+ 'rootLogger' => array(
+ 'level' => 'info',
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ )
+ )
+ );
- private $expected1 = array(
- 'rootLogger' => array(
- 'level' => 'info',
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- )
- )
- )
- );
+ public function testConfig()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_valid.php';
+ $adapter = new PhpAdapter();
+ $actual = $adapter->convert($url);
- public function testConfig() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_valid.php';
- $adapter = new PhpAdapter();
- $actual = $adapter->convert($url);
+ $this->assertSame($this->expected1, $actual);
+ }
- $this->assertSame($this->expected1, $actual);
- }
+ /**
+ * Test exception is thrown when file cannot be found.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
+ */
+ public function testNonExistantFileWarning()
+ {
+ $adapter = new PhpAdapter();
+ $adapter->convert('you/will/never/find/me.conf');
+ }
- /**
- * Test exception is thrown when file cannot be found.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
- */
- public function testNonExistantFileWarning() {
- $adapter = new PhpAdapter();
- $adapter->convert('you/will/never/find/me.conf');
- }
+ /**
+ * Test exception is thrown when file is not valid.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Error parsing configuration: syntax error
+ */
+ public function testInvalidFileWarning()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_invalid_syntax.php';
+ $adapter = new PhpAdapter();
+ $adapter->convert($url);
+ }
- /**
- * Test exception is thrown when file is not valid.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage Error parsing configuration: syntax error
- */
- public function testInvalidFileWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_invalid_syntax.php';
- $adapter = new PhpAdapter();
- $adapter->convert($url);
- }
+ /**
+ * Test exception is thrown when the configuration is empty.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Invalid configuration: empty configuration array.
+ */
+ public function testEmptyConfigWarning()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_empty.php';
+ $adapter = new PhpAdapter();
+ $adapter->convert($url);
+ }
- /**
- * Test exception is thrown when the configuration is empty.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage Invalid configuration: empty configuration array.
- */
- public function testEmptyConfigWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_empty.php';
- $adapter = new PhpAdapter();
- $adapter->convert($url);
- }
-
- /**
- * Test exception is thrown when the configuration does not contain an array.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage Invalid configuration: not an array.
- */
- public function testInvalidConfigWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_not_an_array.php';
- $adapter = new PhpAdapter();
- $adapter->convert($url);
- }
+ /**
+ * Test exception is thrown when the configuration does not contain an array.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Invalid configuration: not an array.
+ */
+ public function testInvalidConfigWarning()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_not_an_array.php';
+ $adapter = new PhpAdapter();
+ $adapter->convert($url);
+ }
}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Configurators/XMLAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/XMLAdapterTest.php b/tests/src/Configurators/XMLAdapterTest.php
index 3c4dbe2..6adee8f 100644
--- a/tests/src/Configurators/XMLAdapterTest.php
+++ b/tests/src/Configurators/XMLAdapterTest.php
@@ -30,149 +30,154 @@ use Apache\Log4php\Configuration\Adapters\XmlAdapter;
/**
* @group configuration
*/
-class XMLAdapterTest extends \PHPUnit_Framework_TestCase {
-
- /** Expected output of parsing config1.xml.*/
- private $expected1 = array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'LoggerLayoutTTCC',
- ),
- 'filters' => array(
- array(
- 'class' => 'LevelRangeFilter',
- 'params' => array(
- 'levelMin' => 'ERROR',
- 'levelMax' => 'FATAL',
- 'acceptOnMatch' => 'false',
- ),
- ),
- array(
- 'class' => 'DenyAllFilter',
- ),
- ),
- ),
- 'file' => array(
- 'class' => 'DailyFileAppender',
- 'layout' => array(
- 'class' => 'PatternLayout',
- 'params' => array(
- 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
- ),
- ),
- 'params' => array(
- 'datePattern' => 'Ymd',
- 'file' => 'target/examples/daily_%s.log',
- ),
- 'threshold' => 'warn'
- ),
- ),
- 'loggers' => array(
- 'foo.bar.baz' => array(
- 'level' => 'trace',
- 'additivity' => 'false',
- 'appenders' => array('default'),
- ),
- 'foo.bar' => array(
- 'level' => 'debug',
- 'additivity' => 'true',
- 'appenders' => array('file'),
- ),
- 'foo' => array(
- 'level' => 'warn',
- 'appenders' => array('default', 'file'),
- ),
- ),
- 'renderers' => array(
- array(
- 'renderedClass' => 'Fruit',
- 'renderingClass' => 'FruitRenderer',
- ),
- array(
- 'renderedClass' => 'Beer',
- 'renderingClass' => 'BeerRenderer',
- ),
- ),
- 'threshold' => 'debug',
- 'rootLogger' => array(
- 'level' => 'DEBUG',
- 'appenders' => array('default'),
- ),
- );
-
- public function setUp() {
- Logger::resetConfiguration();
- }
-
- public function tearDown() {
- Logger::resetConfiguration();
- }
-
- public function testConversion() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid.xml';
- $adapter = new XmlAdapter();
- $actual = $adapter->convert($url);
- $this->assertEquals($this->expected1, $actual);
- }
-
- public function testConversion2() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid_underscore.xml';
- $adapter = new XmlAdapter();
- $actual = $adapter->convert($url);
-
- $this->assertEquals($this->expected1, $actual);
- }
-
- /**
- * Test exception is thrown when file cannot be found.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
- */
- public function testNonExistantFile() {
- $adapter = new XmlAdapter();
- $adapter->convert('you/will/never/find/me.conf');
- }
-
- /**
- * Test exception is thrown when file contains invalid XML.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage Error loading configuration file: Premature end of data in tag configuration line
- */
- public function testInvalidXMLFile() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_invalid_syntax.xml';
- $adapter = new XmlAdapter();
- $adapter->convert($url);
- }
-
- /**
- * Test that a warning is triggered when two loggers with the same name
- * are defined.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Duplicate logger definition [foo]. Overwriting
- */
- public function testDuplicateLoggerWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
- $adapter = new XmlAdapter();
- $adapter->convert($url);
- }
-
-
- /**
- * Test that when two loggers with the same name are defined, the second
- * one will overwrite the first.
- */
- public function testDuplicateLoggerConfig() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
- $adapter = new XmlAdapter();
-
- // Supress the warning so that test can continue
- $config = @$adapter->convert($url);
-
- // Second definition of foo has level set to warn (the first to info)
- $this->assertEquals('warn', $config['loggers']['foo']['level']);
- }
+class XMLAdapterTest extends \PHPUnit_Framework_TestCase
+{
+ /** Expected output of parsing config1.xml.*/
+ private $expected1 = array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'LoggerLayoutTTCC',
+ ),
+ 'filters' => array(
+ array(
+ 'class' => 'LevelRangeFilter',
+ 'params' => array(
+ 'levelMin' => 'ERROR',
+ 'levelMax' => 'FATAL',
+ 'acceptOnMatch' => 'false',
+ ),
+ ),
+ array(
+ 'class' => 'DenyAllFilter',
+ ),
+ ),
+ ),
+ 'file' => array(
+ 'class' => 'DailyFileAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
+ ),
+ ),
+ 'params' => array(
+ 'datePattern' => 'Ymd',
+ 'file' => 'target/examples/daily_%s.log',
+ ),
+ 'threshold' => 'warn'
+ ),
+ ),
+ 'loggers' => array(
+ 'foo.bar.baz' => array(
+ 'level' => 'trace',
+ 'additivity' => 'false',
+ 'appenders' => array('default'),
+ ),
+ 'foo.bar' => array(
+ 'level' => 'debug',
+ 'additivity' => 'true',
+ 'appenders' => array('file'),
+ ),
+ 'foo' => array(
+ 'level' => 'warn',
+ 'appenders' => array('default', 'file'),
+ ),
+ ),
+ 'renderers' => array(
+ array(
+ 'renderedClass' => 'Fruit',
+ 'renderingClass' => 'FruitRenderer',
+ ),
+ array(
+ 'renderedClass' => 'Beer',
+ 'renderingClass' => 'BeerRenderer',
+ ),
+ ),
+ 'threshold' => 'debug',
+ 'rootLogger' => array(
+ 'level' => 'DEBUG',
+ 'appenders' => array('default'),
+ ),
+ );
+
+ public function setUp()
+ {
+ Logger::resetConfiguration();
+ }
+
+ public function tearDown()
+ {
+ Logger::resetConfiguration();
+ }
+
+ public function testConversion()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid.xml';
+ $adapter = new XmlAdapter();
+ $actual = $adapter->convert($url);
+ $this->assertEquals($this->expected1, $actual);
+ }
+
+ public function testConversion2()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid_underscore.xml';
+ $adapter = new XmlAdapter();
+ $actual = $adapter->convert($url);
+
+ $this->assertEquals($this->expected1, $actual);
+ }
+
+ /**
+ * Test exception is thrown when file cannot be found.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
+ */
+ public function testNonExistantFile()
+ {
+ $adapter = new XmlAdapter();
+ $adapter->convert('you/will/never/find/me.conf');
+ }
+
+ /**
+ * Test exception is thrown when file contains invalid XML.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Error loading configuration file: Premature end of data in tag configuration line
+ */
+ public function testInvalidXMLFile()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_invalid_syntax.xml';
+ $adapter = new XmlAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test that a warning is triggered when two loggers with the same name
+ * are defined.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Duplicate logger definition [foo]. Overwriting
+ */
+ public function testDuplicateLoggerWarning()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
+ $adapter = new XmlAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test that when two loggers with the same name are defined, the second
+ * one will overwrite the first.
+ */
+ public function testDuplicateLoggerConfig()
+ {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
+ $adapter = new XmlAdapter();
+
+ // Supress the warning so that test can continue
+ $config = @$adapter->convert($url);
+
+ // Second definition of foo has level set to warn (the first to info)
+ $this->assertEquals('warn', $config['loggers']['foo']['level']);
+ }
}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/ExceptionTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ExceptionTest.php b/tests/src/ExceptionTest.php
index 5b56f9e..e36c194 100644
--- a/tests/src/ExceptionTest.php
+++ b/tests/src/ExceptionTest.php
@@ -27,16 +27,18 @@ use Apache\Log4php\LoggerException;
/**
* @group main
*/
-class ExceptionTest extends \PHPUnit_Framework_TestCase {
- /**
- * @expectedException Apache\Log4php\LoggerException
- */
- public function testMessage() {
- try {
- throw new LoggerException("TEST");
- } catch (LoggerException $e) {
- self::assertEquals("TEST", $e->getMessage());
- throw $e;
- }
- }
+class ExceptionTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @expectedException Apache\Log4php\LoggerException
+ */
+ public function testMessage()
+ {
+ try {
+ throw new LoggerException("TEST");
+ } catch (LoggerException $e) {
+ self::assertEquals("TEST", $e->getMessage());
+ throw $e;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/FilterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/FilterTest.php b/tests/src/FilterTest.php
index e54d01b..4448853 100644
--- a/tests/src/FilterTest.php
+++ b/tests/src/FilterTest.php
@@ -32,23 +32,24 @@ class MyFilter extends AbstractFilter {}
/**
* @group filters
*/
-class FilterTest extends \PHPUnit_Framework_TestCase {
-
- public function testDecide() {
- $filter = new MyFilter();
- // activateOptions is empty, but should at least throw no exeception
- $filter->activateOptions();
- $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
- $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
+class FilterTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDecide()
+ {
+ $filter = new MyFilter();
+ // activateOptions is empty, but should at least throw no exeception
+ $filter->activateOptions();
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Filters/FilterDenyAllTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterDenyAllTest.php b/tests/src/Filters/FilterDenyAllTest.php
index ac41f3b..7109c9c 100644
--- a/tests/src/Filters/FilterDenyAllTest.php
+++ b/tests/src/Filters/FilterDenyAllTest.php
@@ -30,46 +30,48 @@ use Apache\Log4php\Logger;
/**
* @group filters
*/
-class FilterDenyAllTest extends \PHPUnit_Framework_TestCase {
+class FilterDenyAllTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDecide()
+ {
+ $filter = new DenyAllFilter();
- public function testDecide() {
- $filter = new DenyAllFilter();
+ $events = array(
+ TestHelper::getTraceEvent(),
+ TestHelper::getDebugEvent(),
+ TestHelper::getInfoEvent(),
+ TestHelper::getWarnEvent(),
+ TestHelper::getErrorEvent(),
+ TestHelper::getFatalEvent(),
+ );
- $events = array(
- TestHelper::getTraceEvent(),
- TestHelper::getDebugEvent(),
- TestHelper::getInfoEvent(),
- TestHelper::getWarnEvent(),
- TestHelper::getErrorEvent(),
- TestHelper::getFatalEvent(),
- );
-
- foreach($events as $event) {
- $actual = $filter->decide($event);
- self::assertEquals(AbstractFilter::DENY, $actual);
- }
+ foreach ($events as $event) {
+ $actual = $filter->decide($event);
+ self::assertEquals(AbstractFilter::DENY, $actual);
+ }
}
- public function testConfiguration() {
- $config = DefaultConfigurator::getDefaultConfiguration();
- $config['appenders']['default']['filters'] = array(
- array(
- 'class' => 'DenyAllFilter'
- )
- );
+ public function testConfiguration()
+ {
+ $config = DefaultConfigurator::getDefaultConfiguration();
+ $config['appenders']['default']['filters'] = array(
+ array(
+ 'class' => 'DenyAllFilter'
+ )
+ );
- Logger::configure($config);
- $logger = Logger::getRootLogger();
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
- ob_start();
- $logger->trace('Test');
- $logger->debug('Test');
- $logger->info('Test');
- $logger->warn('Test');
- $logger->error('Test');
- $logger->fatal('Test');
- $actual = ob_get_clean();
+ ob_start();
+ $logger->trace('Test');
+ $logger->debug('Test');
+ $logger->info('Test');
+ $logger->warn('Test');
+ $logger->error('Test');
+ $logger->fatal('Test');
+ $actual = ob_get_clean();
- $this->assertEmpty($actual);
+ $this->assertEmpty($actual);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Filters/FilterLevelMatchTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterLevelMatchTest.php b/tests/src/Filters/FilterLevelMatchTest.php
index 28f5601..9eddd68 100644
--- a/tests/src/Filters/FilterLevelMatchTest.php
+++ b/tests/src/Filters/FilterLevelMatchTest.php
@@ -29,156 +29,160 @@ use Apache\Log4php\Logger;
/**
* @group filters
*/
-class FilterLevelMatchTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * Tests all possible combinations of event level and filter levelToMatch
- * option, with acceptOnMatch set to TRUE.
- */
- public function testDecideAccept() {
- $filter = new LevelMatchFilter();
- $filter->setAcceptOnMatch("true");
-
- $levels = TestHelper::getAllLevels();
- $events = TestHelper::getAllEvents();
-
- foreach($levels as $level) {
- $filter->setLevelToMatch($level);
-
- foreach($events as $event) {
- // Expecting given level to be accepted, neutral for others
- $expected = ($event->getLevel() == $level) ? AbstractFilter::ACCEPT : AbstractFilter::NEUTRAL;
- $actual = $filter->decide($event);
-
- // Get string represenations for logging
- $sExpected = TestHelper::decisionToString($expected);
- $sActual = TestHelper::decisionToString($actual);
-
- $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
- }
- }
- }
-
- /**
- * Tests all possible combinations of event level and filter levelToMatch
- * option, with acceptOnMatch set to TRUE.
- */
- public function testDecideDeny() {
- $filter = new LevelMatchFilter();
- $filter->setAcceptOnMatch("false");
-
- $levels = TestHelper::getAllLevels();
- $events = TestHelper::getAllEvents();
-
- foreach($levels as $level) {
- $filter->setLevelToMatch($level);
-
- foreach($events as $event) {
- // Expecting given level to be denied, neutral for others
- $expected = ($event->getLevel() == $level) ? AbstractFilter::DENY : AbstractFilter::NEUTRAL;
- $actual = $filter->decide($event);
-
- // Get string represenations for logging
- $sExpected = TestHelper::decisionToString($expected);
- $sActual = TestHelper::decisionToString($actual);
-
- $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
- }
- }
- }
-
- /** Test that filter always decides NEUTRAL when levelToMatch is not set. */
- public function testDecideNull() {
- $filter = new LevelMatchFilter();
- $events = TestHelper::getAllEvents();
-
- foreach($events as $event) {
- $expected = AbstractFilter::NEUTRAL;
- $actual = $filter->decide($event);
-
- // Get string represenations for logging
- $sExpected = TestHelper::decisionToString($expected);
- $sActual = TestHelper::decisionToString($actual);
- $level = $event->getLevel();
-
- $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
- }
- }
-
- /** Test logger configuration. */
- public function testAcceptConfig() {
- $config = TestHelper::getEchoConfig();
-
- // Add filters to default appender
- $config['appenders']['default']['filters'] = array(
-
- // Accepts only INFO events
- array(
- 'class' => 'LevelMatchFilter',
- 'params' => array(
- 'levelToMatch' => 'info',
- 'acceptOnMatch' => true
- )
- ),
-
- // Denies all events not accepted by first filter
- array(
- 'class' => 'DenyAllFilter',
- )
- );
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
-
- ob_start();
- $logger->trace('Test');
- $logger->debug('Test');
- $logger->info('Test');
- $logger->warn('Test');
- $logger->error('Test');
- $logger->fatal('Test');
-
- $actual = ob_get_clean();
-
-
- $expected = "INFO - Test" . PHP_EOL;
- }
-
- public function testDenyConfig() {
- $config = TestHelper::getEchoConfig();
-
- // Add filter which denies INFO events
- $config['appenders']['default']['filters'] = array(
- array(
- 'class' => 'LevelMatchFilter',
- 'params' => array(
- 'levelToMatch' => 'info',
- 'acceptOnMatch' => false
- )
- )
- );
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
-
- ob_start();
- $logger->trace('Test');
- $logger->debug('Test');
- $logger->info('Test');
- $logger->warn('Test');
- $logger->error('Test');
- $logger->fatal('Test');
-
- $actual = ob_get_clean();
-
- // Should log all except info
- $expected =
- "TRACE - Test" . PHP_EOL .
- "DEBUG - Test" . PHP_EOL .
- "WARN - Test" . PHP_EOL .
- "ERROR - Test" . PHP_EOL .
- "FATAL - Test" . PHP_EOL;
-
- $this->assertSame($expected, $actual);
- }
+class FilterLevelMatchTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * Tests all possible combinations of event level and filter levelToMatch
+ * option, with acceptOnMatch set to TRUE.
+ */
+ public function testDecideAccept()
+ {
+ $filter = new LevelMatchFilter();
+ $filter->setAcceptOnMatch("true");
+
+ $levels = TestHelper::getAllLevels();
+ $events = TestHelper::getAllEvents();
+
+ foreach ($levels as $level) {
+ $filter->setLevelToMatch($level);
+
+ foreach ($events as $event) {
+ // Expecting given level to be accepted, neutral for others
+ $expected = ($event->getLevel() == $level) ? AbstractFilter::ACCEPT : AbstractFilter::NEUTRAL;
+ $actual = $filter->decide($event);
+
+ // Get string represenations for logging
+ $sExpected = TestHelper::decisionToString($expected);
+ $sActual = TestHelper::decisionToString($actual);
+
+ $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
+ }
+ }
+ }
+
+ /**
+ * Tests all possible combinations of event level and filter levelToMatch
+ * option, with acceptOnMatch set to TRUE.
+ */
+ public function testDecideDeny()
+ {
+ $filter = new LevelMatchFilter();
+ $filter->setAcceptOnMatch("false");
+
+ $levels = TestHelper::getAllLevels();
+ $events = TestHelper::getAllEvents();
+
+ foreach ($levels as $level) {
+ $filter->setLevelToMatch($level);
+
+ foreach ($events as $event) {
+ // Expecting given level to be denied, neutral for others
+ $expected = ($event->getLevel() == $level) ? AbstractFilter::DENY : AbstractFilter::NEUTRAL;
+ $actual = $filter->decide($event);
+
+ // Get string represenations for logging
+ $sExpected = TestHelper::decisionToString($expected);
+ $sActual = TestHelper::decisionToString($actual);
+
+ $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
+ }
+ }
+ }
+
+ /** Test that filter always decides NEUTRAL when levelToMatch is not set. */
+ public function testDecideNull()
+ {
+ $filter = new LevelMatchFilter();
+ $events = TestHelper::getAllEvents();
+
+ foreach ($events as $event) {
+ $expected = AbstractFilter::NEUTRAL;
+ $actual = $filter->decide($event);
+
+ // Get string represenations for logging
+ $sExpected = TestHelper::decisionToString($expected);
+ $sActual = TestHelper::decisionToString($actual);
+ $level = $event->getLevel();
+
+ $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
+ }
+ }
+
+ /** Test logger configuration. */
+ public function testAcceptConfig()
+ {
+ $config = TestHelper::getEchoConfig();
+
+ // Add filters to default appender
+ $config['appenders']['default']['filters'] = array(
+
+ // Accepts only INFO events
+ array(
+ 'class' => 'LevelMatchFilter',
+ 'params' => array(
+ 'levelToMatch' => 'info',
+ 'acceptOnMatch' => true
+ )
+ ),
+
+ // Denies all events not accepted by first filter
+ array(
+ 'class' => 'DenyAllFilter',
+ )
+ );
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+
+ ob_start();
+ $logger->trace('Test');
+ $logger->debug('Test');
+ $logger->info('Test');
+ $logger->warn('Test');
+ $logger->error('Test');
+ $logger->fatal('Test');
+
+ $actual = ob_get_clean();
+
+ $expected = "INFO - Test" . PHP_EOL;
+ }
+
+ public function testDenyConfig()
+ {
+ $config = TestHelper::getEchoConfig();
+
+ // Add filter which denies INFO events
+ $config['appenders']['default']['filters'] = array(
+ array(
+ 'class' => 'LevelMatchFilter',
+ 'params' => array(
+ 'levelToMatch' => 'info',
+ 'acceptOnMatch' => false
+ )
+ )
+ );
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+
+ ob_start();
+ $logger->trace('Test');
+ $logger->debug('Test');
+ $logger->info('Test');
+ $logger->warn('Test');
+ $logger->error('Test');
+ $logger->fatal('Test');
+
+ $actual = ob_get_clean();
+
+ // Should log all except info
+ $expected =
+ "TRACE - Test" . PHP_EOL .
+ "DEBUG - Test" . PHP_EOL .
+ "WARN - Test" . PHP_EOL .
+ "ERROR - Test" . PHP_EOL .
+ "FATAL - Test" . PHP_EOL;
+
+ $this->assertSame($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Filters/FilterLevelRangeTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterLevelRangeTest.php b/tests/src/Filters/FilterLevelRangeTest.php
index 31999eb..171517b 100644
--- a/tests/src/Filters/FilterLevelRangeTest.php
+++ b/tests/src/Filters/FilterLevelRangeTest.php
@@ -31,45 +31,47 @@ use Apache\Log4php\LoggingEvent;
/**
* @group filters
*/
-class FilterLevelRangeTest extends \PHPUnit_Framework_TestCase {
+class FilterLevelRangeTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDecide()
+ {
+ $filter = new LevelRangeFilter();
+ $filter->setAcceptOnMatch("true");
+ $filter->setLevelMin(Level::getLevelWarn());
+ $filter->setLevelMax(Level::getLevelError());
- public function testDecide() {
- $filter = new LevelRangeFilter();
- $filter->setAcceptOnMatch("true");
- $filter->setLevelMin(Level::getLevelWarn());
- $filter->setLevelMax(Level::getLevelError());
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
- $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
- $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
- $result = $filter->decide($eventError);
- self::assertEquals($result, AbstractFilter::ACCEPT);
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::DENY);
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, AbstractFilter::DENY);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, AbstractFilter::ACCEPT);
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
}
- public function testDecideAcceptFalse() {
- $filter = new LevelRangeFilter();
- $filter->setAcceptOnMatch("false");
- $filter->setLevelMin(Level::getLevelWarn());
- $filter->setLevelMax(Level::getLevelError());
+ public function testDecideAcceptFalse()
+ {
+ $filter = new LevelRangeFilter();
+ $filter->setAcceptOnMatch("false");
+ $filter->setLevelMin(Level::getLevelWarn());
+ $filter->setLevelMax(Level::getLevelError());
- $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
- $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
- $result = $filter->decide($eventError);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, AbstractFilter::DENY);
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::DENY);
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Filters/FilterStringMatchTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterStringMatchTest.php b/tests/src/Filters/FilterStringMatchTest.php
index 5618412..dc07e08 100644
--- a/tests/src/Filters/FilterStringMatchTest.php
+++ b/tests/src/Filters/FilterStringMatchTest.php
@@ -31,88 +31,92 @@ use Apache\Log4php\LoggingEvent;
/**
* @group filters
*/
-class FilterStringMatchTest extends \PHPUnit_Framework_TestCase {
-
- public function testDecideAccept() {
- $filter = new StringMatchFilter();
- $filter->setAcceptOnMatch("true");
- $filter->setStringToMatch("testmessage");
-
- $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventError2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "xyz");
- $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventDebug2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "xyz");
- $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
- $eventWarn2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "xyz");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, AbstractFilter::ACCEPT);
-
- $result = $filter->decide($eventError2);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, AbstractFilter::ACCEPT);
-
- $result = $filter->decide($eventDebug2);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, AbstractFilter::ACCEPT);
-
- $result = $filter->decide($eventWarn2);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
- }
-
- public function testDecideDeny() {
- $filter = new StringMatchFilter();
- $filter->setAcceptOnMatch("false");
- $filter->setStringToMatch("testmessage");
-
- $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventError2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "xyz");
- $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $eventDebug2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "xyz");
- $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
- $eventWarn2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "xyz");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, AbstractFilter::DENY);
-
- $result = $filter->decide($eventError2);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, AbstractFilter::DENY);
-
- $result = $filter->decide($eventDebug2);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, AbstractFilter::DENY);
-
- $result = $filter->decide($eventWarn2);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
- }
-
- public function testDecideNullMessage() {
- $filter = new StringMatchFilter();
- $filter->setAcceptOnMatch("false");
- $filter->setStringToMatch("testmessage");
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), null);
-
- $result = $filter->decide($event);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
- }
-
- public function testDecideNullMatch() {
- $filter = new StringMatchFilter();
- $filter->setAcceptOnMatch("false");
-
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
-
- $result = $filter->decide($event);
- self::assertEquals($result, AbstractFilter::NEUTRAL);
- }
+class FilterStringMatchTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDecideAccept()
+ {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("true");
+ $filter->setStringToMatch("testmessage");
+
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventError2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "xyz");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "xyz");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ $eventWarn2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "xyz");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventError2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventDebug2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventWarn2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+
+ public function testDecideDeny()
+ {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("false");
+ $filter->setStringToMatch("testmessage");
+
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventError2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "xyz");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "xyz");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ $eventWarn2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "xyz");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventError2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventDebug2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventWarn2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+
+ public function testDecideNullMessage()
+ {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("false");
+ $filter->setStringToMatch("testmessage");
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), null);
+
+ $result = $filter->decide($event);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+
+ public function testDecideNullMatch()
+ {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("false");
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $result = $filter->decide($event);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Helpers/OptionConverterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Helpers/OptionConverterTest.php b/tests/src/Helpers/OptionConverterTest.php
index 6c00e43..e2ee509 100644
--- a/tests/src/Helpers/OptionConverterTest.php
+++ b/tests/src/Helpers/OptionConverterTest.php
@@ -31,9 +31,10 @@ define('MY_CONSTANT_CONSTANT_OTHER', 'DEFINE_OTHER');
/**
* @group helpers
*/
-class OptionConverterTest extends \PHPUnit_Framework_TestCase {
-
- public function testToBoolean() {
+class OptionConverterTest extends \PHPUnit_Framework_TestCase
+{
+ public function testToBoolean()
+ {
self::assertTrue(OptionConverter::toBooleanEx(1));
self::assertTrue(OptionConverter::toBooleanEx("1"));
self::assertTrue(OptionConverter::toBooleanEx(true));
@@ -51,11 +52,12 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
/**
* Test fail on NULL.
- * @expectedException Apache\Log4php\LoggerException
- * @expectedExceptionMessage Given value [NULL] cannot be converted to boolean.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value [NULL] cannot be converted to boolean.
*/
- public function testToBooleanFailure1() {
- OptionConverter::toBooleanEx(null);
+ public function testToBooleanFailure1()
+ {
+ OptionConverter::toBooleanEx(null);
}
/**
@@ -63,17 +65,19 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
* @expectedException Apache\Log4php\LoggerException
* @expectedExceptionMessage Given value ['foo'] cannot be converted to boolean.
*/
- public function testToBooleanFailure2() {
- OptionConverter::toBooleanEx('foo');
+ public function testToBooleanFailure2()
+ {
+ OptionConverter::toBooleanEx('foo');
}
- public function testToInteger() {
- self::assertSame(1, OptionConverter::toIntegerEx('1'));
- self::assertSame(1, OptionConverter::toIntegerEx(1));
- self::assertSame(0, OptionConverter::toIntegerEx('0'));
- self::assertSame(0, OptionConverter::toIntegerEx(0));
- self::assertSame(-1, OptionConverter::toIntegerEx('-1'));
- self::assertSame(-1, OptionConverter::toIntegerEx(-1));
+ public function testToInteger()
+ {
+ self::assertSame(1, OptionConverter::toIntegerEx('1'));
+ self::assertSame(1, OptionConverter::toIntegerEx(1));
+ self::assertSame(0, OptionConverter::toIntegerEx('0'));
+ self::assertSame(0, OptionConverter::toIntegerEx(0));
+ self::assertSame(-1, OptionConverter::toIntegerEx('-1'));
+ self::assertSame(-1, OptionConverter::toIntegerEx(-1));
}
/**
@@ -81,8 +85,9 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
* @expectedException Apache\Log4php\LoggerException
* @expectedExceptionMessage Given value [NULL] cannot be converted to integer.
*/
- public function testToIntegerFailure1() {
- OptionConverter::toIntegerEx(null);
+ public function testToIntegerFailure1()
+ {
+ OptionConverter::toIntegerEx(null);
}
/**
@@ -90,8 +95,9 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
* @expectedException Apache\Log4php\LoggerException
* @expectedExceptionMessage Given value [''] cannot be converted to integer.
*/
- public function testToIntegerFailure2() {
- OptionConverter::toIntegerEx('');
+ public function testToIntegerFailure2()
+ {
+ OptionConverter::toIntegerEx('');
}
/**
@@ -99,8 +105,9 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
* @expectedException Apache\Log4php\LoggerException
* @expectedExceptionMessage Given value ['foo'] cannot be converted to integer.
*/
- public function testToIntegerFailure3() {
- OptionConverter::toIntegerEx('foo');
+ public function testToIntegerFailure3()
+ {
+ OptionConverter::toIntegerEx('foo');
}
/**
@@ -108,8 +115,9 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
* @expectedException Apache\Log4php\LoggerException
* @expectedExceptionMessage Given value [true] cannot be converted to integer.
*/
- public function testToIntegerFailure4() {
- OptionConverter::toIntegerEx(true);
+ public function testToIntegerFailure4()
+ {
+ OptionConverter::toIntegerEx(true);
}
/**
@@ -117,14 +125,16 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
* @expectedException Apache\Log4php\LoggerException
* @expectedExceptionMessage Given value [false] cannot be converted to integer.
*/
- public function testToIntegerFailure5() {
- OptionConverter::toIntegerEx(false);
+ public function testToIntegerFailure5()
+ {
+ OptionConverter::toIntegerEx(false);
}
- public function testSubstituteConstants() {
- define('OTHER_CONSTANT', 'OTHER');
- define('MY_CONSTANT', 'TEST');
- define('NEXT_CONSTANT', 'NEXT');
+ public function testSubstituteConstants()
+ {
+ define('OTHER_CONSTANT', 'OTHER');
+ define('MY_CONSTANT', 'TEST');
+ define('NEXT_CONSTANT', 'NEXT');
$result = OptionConverter::substConstants('Value of key is ${MY_CONSTANT}.');
self::assertEquals('Value of key is TEST.', $result);
@@ -139,11 +149,12 @@ class OptionConverterTest extends \PHPUnit_Framework_TestCase {
self::assertEquals('Value of key is DEFINE or DEFINE_OTHER.', $result);
}
- public function testActualSubstituteConstants() {
- $a = new FileAppender();
- $a->setFile('${PHPUNIT_TEMP_DIR}/log.txt');
- $actual = $a->getFile();
- $expected = PHPUNIT_TEMP_DIR . '/log.txt';
- self::assertSame($expected, $actual);
+ public function testActualSubstituteConstants()
+ {
+ $a = new FileAppender();
+ $a->setFile('${PHPUNIT_TEMP_DIR}/log.txt');
+ $actual = $a->getFile();
+ $expected = PHPUNIT_TEMP_DIR . '/log.txt';
+ self::assertSame($expected, $actual);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Helpers/PatternParserTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Helpers/PatternParserTest.php b/tests/src/Helpers/PatternParserTest.php
index f849c2d..7005722 100644
--- a/tests/src/Helpers/PatternParserTest.php
+++ b/tests/src/Helpers/PatternParserTest.php
@@ -27,9 +27,10 @@ namespace Apache\Log4php\Tests\Helpers;
*
* TODO: Should also test complex patterns like: "%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n"
*/
-class LoggerPatternParserTest extends \PHPUnit_Framework_TestCase {
-
- public function testErrorLayout() {
+class LoggerPatternParserTest extends \PHPUnit_Framework_TestCase
+{
+ public function testErrorLayout()
+ {
// $event = new LoggingEvent("XmlLayout", new Logger("TEST"), Level::getLevelError(), "testmessage");
// $expected = 'ERROR TEST : testmessage in NA at NA'.PHP_EOL;
@@ -42,7 +43,8 @@ class LoggerPatternParserTest extends \PHPUnit_Framework_TestCase {
}
- public function testClassname() {
+ public function testClassname()
+ {
// $event = new LoggingEvent("MyClass", new Logger("TEST"), Level::getLevelError(), "testmessage");
// $expected = 'MyClass';
// $patternParser = new PatternParser("%C");
[35/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/OptionConverter.php
----------------------------------------------------------------------
diff --git a/src/Helpers/OptionConverter.php b/src/Helpers/OptionConverter.php
index c496f02..d67b4a8 100644
--- a/src/Helpers/OptionConverter.php
+++ b/src/Helpers/OptionConverter.php
@@ -25,201 +25,210 @@ use Apache\Log4php\LoggerException;
* A convenience class to convert property values to specific types.
* @since 0.5
*/
-class OptionConverter {
-
- /** String values which are converted to boolean TRUE. */
- private static $trueValues = array('1', 'true', 'yes', 'on');
-
- /**
- * String values which are converted to boolean FALSE.
- *
- * Note that an empty string must convert to false, because
- * parse_ini_file() which is used for parsing configuration
- * converts the value _false_ to an empty string.
- */
- private static $falseValues = array('0', 'false', 'no', 'off', '');
-
- /**
- * Read a predefined var.
- *
- * It returns a value referenced by <var>$key</var> using this search criteria:
- * - if <var>$key</var> is a constant then return it. Else
- * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
- * - return <var>$def</var>.
- *
- * @param string $key The key to search for.
- * @param string $def The default value to return.
- * @return string the string value of the system property, or the default
- * value if there is no property with that key.
- */
- public static function getSystemProperty($key, $def) {
- if(defined($key)) {
- return (string)constant($key);
- } else if(isset($_SERVER[$key])) {
- return (string)$_SERVER[$key];
- } else if(isset($_ENV[$key])) {
- return (string)$_ENV[$key];
- } else {
- return $def;
- }
- }
-
- /** Converts $value to boolean, or throws an exception if not possible. */
- public static function toBooleanEx($value) {
- if (isset($value)) {
- if (is_bool($value)) {
- return $value;
- }
- $value = strtolower(trim($value));
- if (in_array($value, self::$trueValues)) {
- return true;
- }
- if (in_array($value, self::$falseValues)) {
- return false;
- }
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
- }
-
- /**
- * Converts $value to integer, or throws an exception if not possible.
- * Floats cannot be converted to integer.
- */
- public static function toIntegerEx($value) {
- if (is_integer($value)) {
- return $value;
- }
- if (is_numeric($value) && ($value == (integer) $value)) {
- return (integer) $value;
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
- }
-
- /**
- * Converts $value to integer, or throws an exception if not possible.
- * Floats cannot be converted to integer.
- */
- public static function toPositiveIntegerEx($value) {
- if (is_integer($value) && $value > 0) {
- return $value;
- }
- if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
- return (integer) $value;
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
- }
-
- /** Converts the value to a level. Throws an exception if not possible. */
- public static function toLevelEx($value) {
- if ($value instanceof Level) {
- return $value;
- }
- $level = Level::toLevel($value);
- if ($level === null) {
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
- }
- return $level;
- }
-
- /**
- * Converts a value to a valid file size (integer).
- *
- * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
- *
- * The final value will be rounded to the nearest integer.
- *
- * Examples:
- * - '100' => 100
- * - '100.12' => 100
- * - '100KB' => 102400
- * - '1.5MB' => 1572864
- *
- * @param mixed $value File size (optionally with suffix).
- * @return integer Parsed file size.
- */
- public static function toFileSizeEx($value) {
-
- if (empty($value)) {
- throw new LoggerException("Empty value cannot be converted to a file size.");
- }
-
- if (is_numeric($value)) {
- return (integer) $value;
- }
-
- if (!is_string($value)) {
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
- }
-
- $str = strtoupper(trim($value));
- $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
-
- if ($count > 0) {
- $size = $matches[1];
- $unit = $matches[2];
-
- switch($unit) {
- case 'KB': $size *= pow(1024, 1); break;
- case 'MB': $size *= pow(1024, 2); break;
- case 'GB': $size *= pow(1024, 3); break;
- }
-
- return (integer) $size;
- }
-
- throw new LoggerException("Given value [$value] cannot be converted to a file size.");
- }
-
- /**
- * Converts a value to string, or throws an exception if not possible.
- *
- * Objects can be converted to string if they implement the magic
- * __toString() method.
- *
- */
- public static function toStringEx($value) {
- if (is_string($value)) {
- return $value;
- }
- if (is_numeric($value)) {
- return (string) $value;
- }
- if (is_object($value) && method_exists($value, '__toString')) {
- return (string) $value;
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
- }
-
- /**
- * Performs value substitution for string options.
- *
- * An option can contain PHP constants delimited by '${' and '}'.
- *
- * E.g. for input string "some ${FOO} value", the method will attempt
- * to substitute ${FOO} with the value of constant FOO if it exists.
- *
- * Therefore, if FOO is a constant, and it has value "bar", the resulting
- * string will be "some bar value".
- *
- * If the constant is not defined, it will be replaced by an empty string,
- * and the resulting string will be "some value".
- *
- * @param string $string String on which to perform substitution.
- * @return string
- */
- public static function substConstants($string) {
- preg_match_all('/\${([^}]+)}/', $string, $matches);
-
- foreach($matches[1] as $key => $match) {
- $match = trim($match);
- $search = $matches[0][$key];
- $replacement = defined($match) ? constant($match) : '';
- $string = str_replace($search, $replacement, $string);
- }
- return $string;
- }
+class OptionConverter
+{
+ /** String values which are converted to boolean TRUE. */
+ private static $trueValues = array('1', 'true', 'yes', 'on');
+
+ /**
+ * String values which are converted to boolean FALSE.
+ *
+ * Note that an empty string must convert to false, because
+ * parse_ini_file() which is used for parsing configuration
+ * converts the value _false_ to an empty string.
+ */
+ private static $falseValues = array('0', 'false', 'no', 'off', '');
+
+ /**
+ * Read a predefined var.
+ *
+ * It returns a value referenced by <var>$key</var> using this search criteria:
+ * - if <var>$key</var> is a constant then return it. Else
+ * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
+ * - return <var>$def</var>.
+ *
+ * @param string $key The key to search for.
+ * @param string $def The default value to return.
+ * @return string the string value of the system property, or the default
+ * value if there is no property with that key.
+ */
+ public static function getSystemProperty($key, $def)
+ {
+ if (defined($key)) {
+ return (string) constant($key);
+ } elseif (isset($_SERVER[$key])) {
+ return (string) $_SERVER[$key];
+ } elseif (isset($_ENV[$key])) {
+ return (string) $_ENV[$key];
+ } else {
+ return $def;
+ }
+ }
+
+ /** Converts $value to boolean, or throws an exception if not possible. */
+ public static function toBooleanEx($value)
+ {
+ if (isset($value)) {
+ if (is_bool($value)) {
+ return $value;
+ }
+ $value = strtolower(trim($value));
+ if (in_array($value, self::$trueValues)) {
+ return true;
+ }
+ if (in_array($value, self::$falseValues)) {
+ return false;
+ }
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
+ }
+
+ /**
+ * Converts $value to integer, or throws an exception if not possible.
+ * Floats cannot be converted to integer.
+ */
+ public static function toIntegerEx($value)
+ {
+ if (is_integer($value)) {
+ return $value;
+ }
+ if (is_numeric($value) && ($value == (integer) $value)) {
+ return (integer) $value;
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
+ }
+
+ /**
+ * Converts $value to integer, or throws an exception if not possible.
+ * Floats cannot be converted to integer.
+ */
+ public static function toPositiveIntegerEx($value)
+ {
+ if (is_integer($value) && $value > 0) {
+ return $value;
+ }
+ if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
+ return (integer) $value;
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
+ }
+
+ /** Converts the value to a level. Throws an exception if not possible. */
+ public static function toLevelEx($value)
+ {
+ if ($value instanceof Level) {
+ return $value;
+ }
+ $level = Level::toLevel($value);
+ if ($level === null) {
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
+ }
+
+ return $level;
+ }
+
+ /**
+ * Converts a value to a valid file size (integer) .
+ *
+ * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
+ *
+ * The final value will be rounded to the nearest integer.
+ *
+ * Examples:
+ * - '100' => 100
+ * - '100.12' => 100
+ * - '100KB' => 102400
+ * - '1.5MB' => 1572864
+ *
+ * @param mixed $value File size (optionally with suffix).
+ * @return integer Parsed file size.
+ */
+ public static function toFileSizeEx($value)
+ {
+ if (empty($value)) {
+ throw new LoggerException("Empty value cannot be converted to a file size.");
+ }
+
+ if (is_numeric($value)) {
+ return (integer) $value;
+ }
+
+ if (!is_string($value)) {
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
+ }
+
+ $str = strtoupper(trim($value));
+ $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
+
+ if ($count > 0) {
+ $size = $matches[1];
+ $unit = $matches[2];
+
+ switch ($unit) {
+ case 'KB': $size *= pow(1024, 1); break;
+ case 'MB': $size *= pow(1024, 2); break;
+ case 'GB': $size *= pow(1024, 3); break;
+ }
+
+ return (integer) $size;
+ }
+
+ throw new LoggerException("Given value [$value] cannot be converted to a file size.");
+ }
+
+ /**
+ * Converts a value to string, or throws an exception if not possible.
+ *
+ * Objects can be converted to string if they implement the magic
+ * __toString() method.
+ *
+ */
+ public static function toStringEx($value)
+ {
+ if (is_string($value)) {
+ return $value;
+ }
+ if (is_numeric($value)) {
+ return (string) $value;
+ }
+ if (is_object($value) && method_exists($value, '__toString')) {
+ return (string) $value;
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
+ }
+
+ /**
+ * Performs value substitution for string options.
+ *
+ * An option can contain PHP constants delimited by '${' and '}'.
+ *
+ * E.g. for input string "some ${FOO} value", the method will attempt
+ * to substitute ${FOO} with the value of constant FOO if it exists.
+ *
+ * Therefore, if FOO is a constant, and it has value "bar", the resulting
+ * string will be "some bar value".
+ *
+ * If the constant is not defined, it will be replaced by an empty string,
+ * and the resulting string will be "some value".
+ *
+ * @param string $string String on which to perform substitution.
+ * @return string
+ */
+ public static function substConstants($string)
+ {
+ preg_match_all('/\${([^}]+)}/', $string, $matches);
+
+ foreach ($matches[1] as $key => $match) {
+ $match = trim($match);
+ $search = $matches[0][$key];
+ $replacement = defined($match) ? constant($match) : '';
+ $string = str_replace($search, $replacement, $string);
+ }
+
+ return $string;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/PatternParser.php
----------------------------------------------------------------------
diff --git a/src/Helpers/PatternParser.php b/src/Helpers/PatternParser.php
index 7e98a55..5d22b39 100644
--- a/src/Helpers/PatternParser.php
+++ b/src/Helpers/PatternParser.php
@@ -31,215 +31,223 @@ use Apache\Log4php\Pattern\LiteralConverter;
*
* @since 0.3
*/
-class PatternParser {
-
- /** Escape character for conversion words in the conversion pattern. */
- const ESCAPE_CHAR = '%';
-
- /** Maps conversion words to relevant converters. */
- private $converterMap;
-
- /** Conversion pattern used in layout. */
- private $pattern;
-
- /** Regex pattern used for parsing the conversion pattern. */
- private $regex;
-
- /**
- * First converter in the chain.
- * @var AbstractConverter
- */
- private $head;
-
- /** Last converter in the chain. */
- private $tail;
-
- public function __construct($pattern, $converterMap) {
- $this->pattern = $pattern;
- $this->converterMap = $converterMap;
-
- // Construct the regex pattern
- $this->regex =
- '/' . // Starting regex pattern delimiter
- self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern
- '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
- '(?P<word>[a-zA-Z]+)' . // The conversion word
- '(?P<option>{[^}]*})?' . // Conversion option in braces (optional)
- '/'; // Ending regex pattern delimiter
- }
-
- /**
- * Parses the conversion pattern string, converts it to a chain of pattern
- * converters and returns the first converter in the chain.
- *
- * @return AbstractConverter
- */
- public function parse() {
-
- // Skip parsing if the pattern is empty
- if (empty($this->pattern)) {
- $this->addLiteral('');
- return $this->head;
- }
-
- // Find all conversion words in the conversion pattern
- $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
- if ($count === false) {
- $error = error_get_last();
- throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
- }
-
- $prevEnd = 0;
-
- foreach($matches[0] as $key => $item) {
-
- // Locate where the conversion command starts and ends
- $length = strlen($item[0]);
- $start = $item[1];
- $end = $item[1] + $length;
-
- // Find any literal expressions between matched commands
- if ($start > $prevEnd) {
- $literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
- $this->addLiteral($literal);
- }
-
- // Extract the data from the matched command
- $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
- $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
- $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
-
- // Create a converter and add it to the chain
- $this->addConverter($word, $modifiers, $option);
-
- $prevEnd = $end;
- }
-
- // Add any trailing literals
- if ($end < strlen($this->pattern)) {
- $literal = substr($this->pattern, $end);
- $this->addLiteral($literal);
- }
-
- return $this->head;
- }
-
- /**
- * Adds a literal converter to the converter chain.
- * @param string $string The string for the literal converter.
- */
- private function addLiteral($string) {
- $converter = new LiteralConverter($string);
- $this->addToChain($converter);
- }
-
- /**
- * Adds a non-literal converter to the converter chain.
- *
- * @param string $word The conversion word, used to determine which
- * converter will be used.
- * @param string $modifiers Formatting modifiers.
- * @param string $option Option to pass to the converter.
- */
- private function addConverter($word, $modifiers, $option) {
- $formattingInfo = $this->parseModifiers($modifiers);
- $option = trim($option, "{} ");
-
- if (isset($this->converterMap[$word])) {
- $converter = $this->getConverter($word, $formattingInfo, $option);
- $this->addToChain($converter);
- } else {
- trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
- }
- }
-
- /**
- * Determines which converter to use based on the conversion word. Creates
- * an instance of the converter using the provided formatting info and
- * option and returns it.
- *
- * @param string $word The conversion word.
- * @param FormattingInfo $info Formatting info.
- * @param string $option Converter option.
- *
- * @throws LoggerException
- *
- * @return AbstractConverter
- */
- private function getConverter($word, $info, $option) {
- if (!isset($this->converterMap[$word])) {
- throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
- }
-
- $class = $this->converterMap[$word];
- if (class_exists($class)) {
- $converter = new $class($info, $option);
- } else {
- $nsClass = "Apache\\Log4php\\Pattern\\$class";
- if (class_exists($nsClass)) {
- $converter = new $nsClass($info, $option);
- }
- }
-
- if (!isset($converter)) {
- throw new LoggerException("Class '$class' does not exist.");
- }
-
- if(!($converter instanceof AbstractConverter)) {
- throw new LoggerException("Class '$class' is not an instance of AbstractConverter.");
- }
-
- return $converter;
- }
-
- /** Adds a converter to the chain and updates $head and $tail pointers. */
- private function addToChain(AbstractConverter $converter) {
- if (!isset($this->head)) {
- $this->head = $converter;
- $this->tail = $this->head;
- } else {
- $this->tail->next = $converter;
- $this->tail = $this->tail->next;
- }
- }
-
- /**
- * Parses the formatting modifiers and produces the corresponding
- * FormattingInfo object.
- *
- * @param string $modifier
- * @return FormattingInfo
- * @throws LoggerException
- */
- private function parseModifiers($modifiers) {
- $info = new FormattingInfo();
-
- // If no modifiers are given, return default values
- if (empty($modifiers)) {
- return $info;
- }
-
- // Validate
- $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
- if (!preg_match($pattern, $modifiers)) {
- trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
- return $info;
- }
-
- $parts = explode('.', $modifiers);
-
- if (!empty($parts[0])) {
- $minPart = (integer) $parts[0];
- $info->min = abs($minPart);
- $info->padLeft = ($minPart > 0);
- }
-
- if (!empty($parts[1])) {
- $maxPart = (integer) $parts[1];
- $info->max = abs($maxPart);
- $info->trimLeft = ($maxPart < 0);
- }
-
- return $info;
- }
+class PatternParser
+{
+ /** Escape character for conversion words in the conversion pattern. */
+ const ESCAPE_CHAR = '%';
+
+ /** Maps conversion words to relevant converters. */
+ private $converterMap;
+
+ /** Conversion pattern used in layout. */
+ private $pattern;
+
+ /** Regex pattern used for parsing the conversion pattern. */
+ private $regex;
+
+ /**
+ * First converter in the chain.
+ * @var AbstractConverter
+ */
+ private $head;
+
+ /** Last converter in the chain. */
+ private $tail;
+
+ public function __construct($pattern, $converterMap)
+ {
+ $this->pattern = $pattern;
+ $this->converterMap = $converterMap;
+
+ // Construct the regex pattern
+ $this->regex =
+ '/' . // Starting regex pattern delimiter
+ self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern
+ '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
+ '(?P<word>[a-zA-Z]+)' . // The conversion word
+ '(?P<option>{[^}]*})?' . // Conversion option in braces (optional)
+ '/'; // Ending regex pattern delimiter
+ }
+
+ /**
+ * Parses the conversion pattern string, converts it to a chain of pattern
+ * converters and returns the first converter in the chain.
+ *
+ * @return AbstractConverter
+ */
+ public function parse()
+ {
+ // Skip parsing if the pattern is empty
+ if (empty($this->pattern)) {
+ $this->addLiteral('');
+
+ return $this->head;
+ }
+
+ // Find all conversion words in the conversion pattern
+ $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
+ if ($count === false) {
+ $error = error_get_last();
+ throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
+ }
+
+ $prevEnd = 0;
+
+ foreach ($matches[0] as $key => $item) {
+
+ // Locate where the conversion command starts and ends
+ $length = strlen($item[0]);
+ $start = $item[1];
+ $end = $item[1] + $length;
+
+ // Find any literal expressions between matched commands
+ if ($start > $prevEnd) {
+ $literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
+ $this->addLiteral($literal);
+ }
+
+ // Extract the data from the matched command
+ $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
+ $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
+ $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
+
+ // Create a converter and add it to the chain
+ $this->addConverter($word, $modifiers, $option);
+
+ $prevEnd = $end;
+ }
+
+ // Add any trailing literals
+ if ($end < strlen($this->pattern)) {
+ $literal = substr($this->pattern, $end);
+ $this->addLiteral($literal);
+ }
+
+ return $this->head;
+ }
+
+ /**
+ * Adds a literal converter to the converter chain.
+ * @param string $string The string for the literal converter.
+ */
+ private function addLiteral($string)
+ {
+ $converter = new LiteralConverter($string);
+ $this->addToChain($converter);
+ }
+
+ /**
+ * Adds a non-literal converter to the converter chain.
+ *
+ * @param string $word The conversion word, used to determine which
+ * converter will be used.
+ * @param string $modifiers Formatting modifiers.
+ * @param string $option Option to pass to the converter.
+ */
+ private function addConverter($word, $modifiers, $option)
+ {
+ $formattingInfo = $this->parseModifiers($modifiers);
+ $option = trim($option, "{} ");
+
+ if (isset($this->converterMap[$word])) {
+ $converter = $this->getConverter($word, $formattingInfo, $option);
+ $this->addToChain($converter);
+ } else {
+ trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
+ }
+ }
+
+ /**
+ * Determines which converter to use based on the conversion word. Creates
+ * an instance of the converter using the provided formatting info and
+ * option and returns it.
+ *
+ * @param string $word The conversion word.
+ * @param FormattingInfo $info Formatting info.
+ * @param string $option Converter option.
+ *
+ * @throws LoggerException
+ *
+ * @return AbstractConverter
+ */
+ private function getConverter($word, $info, $option)
+ {
+ if (!isset($this->converterMap[$word])) {
+ throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
+ }
+
+ $class = $this->converterMap[$word];
+ if (class_exists($class)) {
+ $converter = new $class($info, $option);
+ } else {
+ $nsClass = "Apache\\Log4php\\Pattern\\$class";
+ if (class_exists($nsClass)) {
+ $converter = new $nsClass($info, $option);
+ }
+ }
+
+ if (!isset($converter)) {
+ throw new LoggerException("Class '$class' does not exist.");
+ }
+
+ if (!($converter instanceof AbstractConverter)) {
+ throw new LoggerException("Class '$class' is not an instance of AbstractConverter.");
+ }
+
+ return $converter;
+ }
+
+ /** Adds a converter to the chain and updates $head and $tail pointers. */
+ private function addToChain(AbstractConverter $converter)
+ {
+ if (!isset($this->head)) {
+ $this->head = $converter;
+ $this->tail = $this->head;
+ } else {
+ $this->tail->next = $converter;
+ $this->tail = $this->tail->next;
+ }
+ }
+
+ /**
+ * Parses the formatting modifiers and produces the corresponding
+ * FormattingInfo object.
+ *
+ * @param string $modifier
+ * @return FormattingInfo
+ * @throws LoggerException
+ */
+ private function parseModifiers($modifiers)
+ {
+ $info = new FormattingInfo();
+
+ // If no modifiers are given, return default values
+ if (empty($modifiers)) {
+ return $info;
+ }
+
+ // Validate
+ $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
+ if (!preg_match($pattern, $modifiers)) {
+ trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
+
+ return $info;
+ }
+
+ $parts = explode('.', $modifiers);
+
+ if (!empty($parts[0])) {
+ $minPart = (integer) $parts[0];
+ $info->min = abs($minPart);
+ $info->padLeft = ($minPart > 0);
+ }
+
+ if (!empty($parts[1])) {
+ $maxPart = (integer) $parts[1];
+ $info->max = abs($maxPart);
+ $info->trimLeft = ($maxPart < 0);
+ }
+
+ return $info;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/Utils.php
----------------------------------------------------------------------
diff --git a/src/Helpers/Utils.php b/src/Helpers/Utils.php
index 52be24d..01d5a40 100644
--- a/src/Helpers/Utils.php
+++ b/src/Helpers/Utils.php
@@ -22,99 +22,100 @@ namespace Apache\Log4php\Helpers;
* Contains various helper methods.
* @since 2.3
*/
-class Utils {
-
- /**
- * Splits a fully qualified class name into fragments delimited by the
- * namespace separator (\).
- *
- * For backward compatibility, a dot (.) can be used as a delimiter as
- * well.
- *
- * @param string $name
- *
- * @return array Class name split into fragments.
- */
- public static function tokenizeClassName($name) {
- $name = str_replace('.', '\\', $name);
- $name = trim($name, ' \\');
- $fragments = explode('\\', $name);
-
- foreach($fragments as $key => $fragment) {
- if (trim($fragment) === '') {
- unset($fragments[$key]);
- }
- }
-
- return $fragments;
- }
-
- /**
- * Attempts to shorten the given class name to the desired length.
- *
- * This is done by separating the class name into fragments (delimited
- * by \ or .) and trimming individual fragments, starting with the left,
- * until desired length has been reached.
- *
- * The final fragment (i.e. class name) will never be shortened so the
- * result may still be longer than given length.
- *
- * @param string $name The (qualified) class name.
- * @param integer $length The length to shorten to. If null or 0 is given,
- * the name will be returned without shortening.
- */
- public static function shortenClassName($name, $length) {
- if ($length === null || $length < 0) {
- return $name;
- }
-
- $name = str_replace('.', '\\', $name);
- $name = trim($name, ' \\');
-
- // Check if any shortening is required
- $currentLength = strlen($name);
- if ($currentLength <= $length) {
- return $name;
- }
-
- // Split name into fragments
- $fragments = explode('\\', $name);
-
- // If zero length is specified, return only last fragment
- if ($length == 0) {
- return array_pop($fragments);
- }
-
- // If the name splits to only one fragment, then it cannot be shortened
- $count = count($fragments);
- if ($count == 1) {
- return $name;
- }
-
- foreach($fragments as $key => &$fragment) {
-
- // Never shorten last fragment
- if ($key == $count - 1) {
- break;
- }
-
- // Check for empty fragments (shouldn't happen but it's possible)
- $fragLen = strlen($fragment);
- if ($fragLen <= 1) {
- continue;
- }
-
- // Shorten fragment to one character and check if total length satisfactory
- $fragment = substr($fragment, 0, 1);
- $currentLength = $currentLength - $fragLen + 1;
-
- if ($currentLength <= $length) {
- break;
- }
- }
- unset($fragment);
-
- return implode('\\', $fragments);
- }
+class Utils
+{
+ /**
+ * Splits a fully qualified class name into fragments delimited by the
+ * namespace separator (\).
+ *
+ * For backward compatibility, a dot (.) can be used as a delimiter as
+ * well.
+ *
+ * @param string $name
+ *
+ * @return array Class name split into fragments.
+ */
+ public static function tokenizeClassName($name)
+ {
+ $name = str_replace('.', '\\', $name);
+ $name = trim($name, ' \\');
+ $fragments = explode('\\', $name);
+
+ foreach ($fragments as $key => $fragment) {
+ if (trim($fragment) === '') {
+ unset($fragments[$key]);
+ }
+ }
+
+ return $fragments;
+ }
+
+ /**
+ * Attempts to shorten the given class name to the desired length.
+ *
+ * This is done by separating the class name into fragments (delimited
+ * by \ or .) and trimming individual fragments, starting with the left,
+ * until desired length has been reached.
+ *
+ * The final fragment (i.e. class name) will never be shortened so the
+ * result may still be longer than given length.
+ *
+ * @param string $name The (qualified) class name.
+ * @param integer $length The length to shorten to. If null or 0 is given,
+ * the name will be returned without shortening.
+ */
+ public static function shortenClassName($name, $length)
+ {
+ if ($length === null || $length < 0) {
+ return $name;
+ }
+
+ $name = str_replace('.', '\\', $name);
+ $name = trim($name, ' \\');
+
+ // Check if any shortening is required
+ $currentLength = strlen($name);
+ if ($currentLength <= $length) {
+ return $name;
+ }
+
+ // Split name into fragments
+ $fragments = explode('\\', $name);
+
+ // If zero length is specified, return only last fragment
+ if ($length == 0) {
+ return array_pop($fragments);
+ }
+
+ // If the name splits to only one fragment, then it cannot be shortened
+ $count = count($fragments);
+ if ($count == 1) {
+ return $name;
+ }
+
+ foreach ($fragments as $key => &$fragment) {
+
+ // Never shorten last fragment
+ if ($key == $count - 1) {
+ break;
+ }
+
+ // Check for empty fragments (shouldn't happen but it's possible)
+ $fragLen = strlen($fragment);
+ if ($fragLen <= 1) {
+ continue;
+ }
+
+ // Shorten fragment to one character and check if total length satisfactory
+ $fragment = substr($fragment, 0, 1);
+ $currentLength = $currentLength - $fragLen + 1;
+
+ if ($currentLength <= $length) {
+ break;
+ }
+ }
+ unset($fragment);
+
+ return implode('\\', $fragments);
+ }
}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Hierarchy.php
----------------------------------------------------------------------
diff --git a/src/Hierarchy.php b/src/Hierarchy.php
index 7b28a6b..384b8ee 100644
--- a/src/Hierarchy.php
+++ b/src/Hierarchy.php
@@ -46,211 +46,225 @@ use Apache\Log4php\Renderers\RendererMap;
* to the provision node. Other descendants of the same ancestor add
* themselves to the previously created provision node.</p>
*/
-class Hierarchy {
+class Hierarchy
+{
+ /** Array holding all Logger instances. */
+ protected $loggers = array();
- /** Array holding all Logger instances. */
- protected $loggers = array();
+ /**
+ * The root logger.
+ * @var RootLogger
+ */
+ protected $root;
- /**
- * The root logger.
- * @var RootLogger
- */
- protected $root;
+ /**
+ * The logger renderer map.
+ * @var RendererMap
+ */
+ protected $rendererMap;
- /**
- * The logger renderer map.
- * @var RendererMap
- */
- protected $rendererMap;
+ /**
+ * Main level threshold. Events with lower level will not be logged by any
+ * logger, regardless of it's configuration.
+ * @var Level
+ */
+ protected $threshold;
- /**
- * Main level threshold. Events with lower level will not be logged by any
- * logger, regardless of it's configuration.
- * @var Level
- */
- protected $threshold;
+ /**
+ * Creates a new logger hierarchy.
+ * @param RootLogger $root The root logger.
+ */
+ public function __construct(RootLogger $root)
+ {
+ $this->root = $root;
+ $this->setThreshold(Level::getLevelAll());
+ $this->rendererMap = new RendererMap();
+ }
- /**
- * Creates a new logger hierarchy.
- * @param RootLogger $root The root logger.
- */
- public function __construct(RootLogger $root) {
- $this->root = $root;
- $this->setThreshold(Level::getLevelAll());
- $this->rendererMap = new RendererMap();
- }
+ /**
+ * Clears all loggers.
+ */
+ public function clear()
+ {
+ $this->loggers = array();
+ }
- /**
- * Clears all loggers.
- */
- public function clear() {
- $this->loggers = array();
- }
+ /**
+ * Check if the named logger exists in the hierarchy.
+ * @param string $name
+ * @return boolean
+ */
+ public function exists($name)
+ {
+ return isset($this->loggers[$name]);
+ }
- /**
- * Check if the named logger exists in the hierarchy.
- * @param string $name
- * @return boolean
- */
- public function exists($name) {
- return isset($this->loggers[$name]);
- }
+ /**
+ * Returns all the currently defined loggers in this hierarchy as an array.
+ * @return array
+ */
+ public function getCurrentLoggers()
+ {
+ return array_values($this->loggers);
+ }
- /**
- * Returns all the currently defined loggers in this hierarchy as an array.
- * @return array
- */
- public function getCurrentLoggers() {
- return array_values($this->loggers);
- }
+ /**
+ * Returns a named logger instance logger. If it doesn't exist, one is created.
+ *
+ * @param string $name Logger name
+ * @return Logger Logger instance.
+ */
+ public function getLogger($name)
+ {
+ if (!isset($this->loggers[$name])) {
+ $logger = new Logger($name);
- /**
- * Returns a named logger instance logger. If it doesn't exist, one is created.
- *
- * @param string $name Logger name
- * @return Logger Logger instance.
- */
- public function getLogger($name) {
- if(!isset($this->loggers[$name])) {
- $logger = new Logger($name);
+ $nodes = explode('.', $name);
+ $firstNode = array_shift($nodes);
- $nodes = explode('.', $name);
- $firstNode = array_shift($nodes);
+ // if name is not a first node but another first node is their
+ if ($firstNode != $name and isset($this->loggers[$firstNode])) {
+ $logger->setParent($this->loggers[$firstNode]);
+ } else {
+ // if there is no father, set root logger as father
+ $logger->setParent($this->root);
+ }
- // if name is not a first node but another first node is their
- if($firstNode != $name and isset($this->loggers[$firstNode])) {
- $logger->setParent($this->loggers[$firstNode]);
- } else {
- // if there is no father, set root logger as father
- $logger->setParent($this->root);
- }
+ // if there are more nodes than one
+ if (count($nodes) > 0) {
+ // find parent node
+ foreach ($nodes as $node) {
+ $parentNode = "$firstNode.$node";
+ if (isset($this->loggers[$parentNode]) and $parentNode != $name) {
+ $logger->setParent($this->loggers[$parentNode]);
+ }
+ $firstNode .= ".$node";
+ }
+ }
- // if there are more nodes than one
- if(count($nodes) > 0) {
- // find parent node
- foreach($nodes as $node) {
- $parentNode = "$firstNode.$node";
- if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
- $logger->setParent($this->loggers[$parentNode]);
- }
- $firstNode .= ".$node";
- }
- }
+ $this->loggers[$name] = $logger;
+ }
- $this->loggers[$name] = $logger;
- }
+ return $this->loggers[$name];
+ }
- return $this->loggers[$name];
- }
+ /**
+ * Returns the logger renderer map.
+ * @return RendererMap
+ */
+ public function getRendererMap()
+ {
+ return $this->rendererMap;
+ }
- /**
- * Returns the logger renderer map.
- * @return RendererMap
- */
- public function getRendererMap() {
- return $this->rendererMap;
- }
+ /**
+ * Returns the root logger.
+ * @return RootLogger
+ */
+ public function getRootLogger()
+ {
+ return $this->root;
+ }
- /**
- * Returns the root logger.
- * @return RootLogger
- */
- public function getRootLogger() {
- return $this->root;
- }
+ /**
+ * Returns the main threshold level.
+ * @return Level
+ */
+ public function getThreshold()
+ {
+ return $this->threshold;
+ }
- /**
- * Returns the main threshold level.
- * @return Level
- */
- public function getThreshold() {
- return $this->threshold;
- }
+ /**
+ * Returns true if the hierarchy is disabled for given log level and false
+ * otherwise.
+ * @return boolean
+ */
+ public function isDisabled(Level $level)
+ {
+ return ($this->threshold->toInt() > $level->toInt());
+ }
- /**
- * Returns true if the hierarchy is disabled for given log level and false
- * otherwise.
- * @return boolean
- */
- public function isDisabled(Level $level) {
- return ($this->threshold->toInt() > $level->toInt());
- }
+ /**
+ * Reset all values contained in this hierarchy instance to their
+ * default.
+ *
+ * This removes all appenders from all loggers, sets
+ * the level of all non-root loggers to <i>null</i>,
+ * sets their additivity flag to <i>true</i> and sets the level
+ * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
+ *
+ * <p>Existing loggers are not removed. They are just reset.
+ *
+ * <p>This method should be used sparingly and with care as it will
+ * block all logging until it is completed.</p>
+ */
+ public function resetConfiguration()
+ {
+ $root = $this->getRootLogger();
- /**
- * Reset all values contained in this hierarchy instance to their
- * default.
- *
- * This removes all appenders from all loggers, sets
- * the level of all non-root loggers to <i>null</i>,
- * sets their additivity flag to <i>true</i> and sets the level
- * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
- *
- * <p>Existing loggers are not removed. They are just reset.
- *
- * <p>This method should be used sparingly and with care as it will
- * block all logging until it is completed.</p>
- */
- public function resetConfiguration() {
- $root = $this->getRootLogger();
+ $root->setLevel(Level::getLevelDebug());
+ $this->setThreshold(Level::getLevelAll());
+ $this->shutDown();
- $root->setLevel(Level::getLevelDebug());
- $this->setThreshold(Level::getLevelAll());
- $this->shutDown();
+ foreach ($this->loggers as $logger) {
+ $logger->setLevel(null);
+ $logger->setAdditivity(true);
+ $logger->removeAllAppenders();
+ }
- foreach($this->loggers as $logger) {
- $logger->setLevel(null);
- $logger->setAdditivity(true);
- $logger->removeAllAppenders();
- }
+ $this->rendererMap->reset();
+ AppenderPool::clear();
+ }
- $this->rendererMap->reset();
- AppenderPool::clear();
- }
+ /**
+ * Sets the main threshold level.
+ * @param Level $l
+ */
+ public function setThreshold(Level $threshold)
+ {
+ $this->threshold = $threshold;
+ }
- /**
- * Sets the main threshold level.
- * @param Level $l
- */
- public function setThreshold(Level $threshold) {
- $this->threshold = $threshold;
- }
+ /**
+ * Shutting down a hierarchy will <i>safely</i> close and remove
+ * all appenders in all loggers including the root logger.
+ *
+ * The shutdown method is careful to close nested
+ * appenders before closing regular appenders. This is allows
+ * configurations where a regular appender is attached to a logger
+ * and again to a nested appender.
+ *
+ * @todo Check if the last paragraph is correct.
+ */
+ public function shutdown()
+ {
+ $this->root->removeAllAppenders();
- /**
- * Shutting down a hierarchy will <i>safely</i> close and remove
- * all appenders in all loggers including the root logger.
- *
- * The shutdown method is careful to close nested
- * appenders before closing regular appenders. This is allows
- * configurations where a regular appender is attached to a logger
- * and again to a nested appender.
- *
- * @todo Check if the last paragraph is correct.
- */
- public function shutdown() {
- $this->root->removeAllAppenders();
+ foreach ($this->loggers as $logger) {
+ $logger->removeAllAppenders();
+ }
+ }
- foreach($this->loggers as $logger) {
- $logger->removeAllAppenders();
- }
- }
+ /**
+ * Prints the current Logger hierarchy tree. Useful for debugging.
+ */
+ public function printHierarchy()
+ {
+ $this->printHierarchyInner($this->getRootLogger(), 0);
+ }
- /**
- * Prints the current Logger hierarchy tree. Useful for debugging.
- */
- public function printHierarchy() {
- $this->printHierarchyInner($this->getRootLogger(), 0);
- }
+ private function printHierarchyInner(Logger $current, $level)
+ {
+ for ($i = 0; $i < $level; $i++) {
+ echo ($i == $level - 1) ? "|--" : "| ";
+ }
+ echo $current->getName() . "\n";
- private function printHierarchyInner(Logger $current, $level) {
- for ($i = 0; $i < $level; $i++) {
- echo ($i == $level - 1) ? "|--" : "| ";
- }
- echo $current->getName() . "\n";
-
- foreach($this->loggers as $logger) {
- if ($logger->getParent() == $current) {
- $this->printHierarchyInner($logger, $level + 1);
- }
- }
- }
+ foreach ($this->loggers as $logger) {
+ if ($logger->getParent() == $current) {
+ $this->printHierarchyInner($logger, $level + 1);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/AbstractLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/AbstractLayout.php b/src/Layouts/AbstractLayout.php
index b6a2d14..3a8e486 100644
--- a/src/Layouts/AbstractLayout.php
+++ b/src/Layouts/AbstractLayout.php
@@ -24,51 +24,58 @@ use Apache\Log4php\LoggingEvent;
/**
* Extend this abstract class to create your own log layout format.
*/
-abstract class AbstractLayout extends Configurable {
- /**
- * Activates options for this layout.
- * Override this method if you have options to be activated.
- */
- public function activateOptions() {
- return true;
- }
+abstract class AbstractLayout extends Configurable
+{
+ /**
+ * Activates options for this layout.
+ * Override this method if you have options to be activated.
+ */
+ public function activateOptions()
+ {
+ return true;
+ }
- /**
- * Override this method to create your own layout format.
- *
- * @param LoggingEvent
- * @return string
- */
- public function format(LoggingEvent $event) {
- return $event->getRenderedMessage();
- }
+ /**
+ * Override this method to create your own layout format.
+ *
+ * @param LoggingEvent
+ * @return string
+ */
+ public function format(LoggingEvent $event)
+ {
+ return $event->getRenderedMessage();
+ }
- /**
- * Returns the content type output by this layout.
- * @return string
- */
- public function getContentType() {
- return "text/plain";
- }
+ /**
+ * Returns the content type output by this layout.
+ * @return string
+ */
+ public function getContentType()
+ {
+ return "text/plain";
+ }
- /**
- * Returns the footer for the layout format.
- * @return string
- */
- public function getFooter() {
- return null;
- }
+ /**
+ * Returns the footer for the layout format.
+ * @return string
+ */
+ public function getFooter()
+ {
+ return null;
+ }
- /**
- * Returns the header for the layout format.
- * @return string
- */
- public function getHeader() {
- return null;
- }
+ /**
+ * Returns the header for the layout format.
+ * @return string
+ */
+ public function getHeader()
+ {
+ return null;
+ }
- /** Triggers a warning for this layout with the given message. */
- protected function warn($message) {
- trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
- }
+ /** Triggers a warning for this layout with the given message. */
+ protected function warn($message)
+ {
+ trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/HtmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/HtmlLayout.php b/src/Layouts/HtmlLayout.php
index af74e61..6a5bd50 100644
--- a/src/Layouts/HtmlLayout.php
+++ b/src/Layouts/HtmlLayout.php
@@ -29,169 +29,179 @@ use Apache\Log4php\Level;
* - title
* - locationInfo
*/
-class HtmlLayout extends AbstractLayout {
- /**
- * The <b>LocationInfo</b> option takes a boolean value. By
- * default, it is set to false which means there will be no location
- * information output by this layout. If the the option is set to
- * true, then the file name and line number of the statement
- * at the origin of the log statement will be output.
- *
- * <p>If you are embedding this layout within a {@link MailAppender}
- * or a {@link MailEventAppender} then make sure to set the
- * <b>LocationInfo</b> option of that appender as well.
- * @var boolean
- */
- protected $locationInfo = false;
-
- /**
- * The <b>Title</b> option takes a String value. This option sets the
- * document title of the generated HTML document.
- * Defaults to 'Log4php Log Messages'.
- * @var string
- */
- protected $title = "Log4php Log Messages";
-
- /**
- * The <b>LocationInfo</b> option takes a boolean value. By
- * default, it is set to false which means there will be no location
- * information output by this layout. If the the option is set to
- * true, then the file name and line number of the statement
- * at the origin of the log statement will be output.
- *
- * <p>If you are embedding this layout within a {@link MailAppender}
- * or a {@link MailEventAppender} then make sure to set the
- * <b>LocationInfo</b> option of that appender as well.
- */
- public function setLocationInfo($flag) {
- $this->setBoolean('locationInfo', $flag);
- }
-
- /**
- * Returns the current value of the <b>LocationInfo</b> option.
- */
- public function getLocationInfo() {
- return $this->locationInfo;
- }
-
- /**
- * The <b>Title</b> option takes a String value. This option sets the
- * document title of the generated HTML document.
- * Defaults to 'Log4php Log Messages'.
- */
- public function setTitle($title) {
- $this->setString('title', $title);
- }
-
- /**
- * @return string Returns the current value of the <b>Title</b> option.
- */
- public function getTitle() {
- return $this->title;
- }
-
- /**
- * @return string Returns the content type output by this layout, i.e "text/html".
- */
- public function getContentType() {
- return "text/html";
- }
-
- /**
- * @param LoggingEvent $event
- * @return string
- */
- public function format(LoggingEvent $event) {
- $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
-
- $sbuf .= "<td>";
- $sbuf .= round(1000 * $event->getRelativeTime());
- $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(Level::getLevelDebug())) {
- $sbuf .= "<font color=\"#339933\">$level</font>";
- } else if ($level->equals(Level::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;
- }
-
- /**
- * @return string Returns appropriate HTML headers.
- */
- public function getHeader() {
- $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
- $sbuf .= "<html>" . PHP_EOL;
- $sbuf .= "<head>" . PHP_EOL;
- $sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
- $sbuf .= "<style type=\"text/css\">" . PHP_EOL;
- $sbuf .= "<!--" . PHP_EOL;
- $sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
- $sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
- $sbuf .= "-->" . PHP_EOL;
- $sbuf .= "</style>" . PHP_EOL;
- $sbuf .= "</head>" . PHP_EOL;
- $sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
- $sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
- $sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
- $sbuf .= "<br>" . PHP_EOL;
- $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
- $sbuf .= "<tr>" . PHP_EOL;
- $sbuf .= "<th>Time</th>" . PHP_EOL;
- $sbuf .= "<th>Thread</th>" . PHP_EOL;
- $sbuf .= "<th>Level</th>" . PHP_EOL;
- $sbuf .= "<th>Category</th>" . PHP_EOL;
- if ($this->locationInfo) {
- $sbuf .= "<th>File:Line</th>" . PHP_EOL;
- }
- $sbuf .= "<th>Message</th>" . PHP_EOL;
- $sbuf .= "</tr>" . PHP_EOL;
-
- return $sbuf;
- }
-
- /**
- * @return string Returns the appropriate HTML footers.
- */
- public function getFooter() {
- $sbuf = "</table>" . PHP_EOL;
- $sbuf .= "<br>" . PHP_EOL;
- $sbuf .= "</body></html>";
-
- return $sbuf;
- }
+class HtmlLayout extends AbstractLayout
+{
+ /**
+ * The <b>LocationInfo</b> option takes a boolean value. By
+ * default, it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement
+ * at the origin of the log statement will be output.
+ *
+ * <p>If you are embedding this layout within a {@link MailAppender}
+ * or a {@link MailEventAppender} then make sure to set the
+ * <b>LocationInfo</b> option of that appender as well.
+ * @var boolean
+ */
+ protected $locationInfo = false;
+
+ /**
+ * The <b>Title</b> option takes a String value. This option sets the
+ * document title of the generated HTML document.
+ * Defaults to 'Log4php Log Messages'.
+ * @var string
+ */
+ protected $title = "Log4php Log Messages";
+
+ /**
+ * The <b>LocationInfo</b> option takes a boolean value. By
+ * default, it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement
+ * at the origin of the log statement will be output.
+ *
+ * <p>If you are embedding this layout within a {@link MailAppender}
+ * or a {@link MailEventAppender} then make sure to set the
+ * <b>LocationInfo</b> option of that appender as well.
+ */
+ public function setLocationInfo($flag)
+ {
+ $this->setBoolean('locationInfo', $flag);
+ }
+
+ /**
+ * Returns the current value of the <b>LocationInfo</b> option.
+ */
+ public function getLocationInfo()
+ {
+ return $this->locationInfo;
+ }
+
+ /**
+ * The <b>Title</b> option takes a String value. This option sets the
+ * document title of the generated HTML document.
+ * Defaults to 'Log4php Log Messages'.
+ */
+ public function setTitle($title)
+ {
+ $this->setString('title', $title);
+ }
+
+ /**
+ * @return string Returns the current value of the <b>Title</b> option.
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * @return string Returns the content type output by this layout, i.e "text/html".
+ */
+ public function getContentType()
+ {
+ return "text/html";
+ }
+
+ /**
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event)
+ {
+ $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
+
+ $sbuf .= "<td>";
+ $sbuf .= round(1000 * $event->getRelativeTime());
+ $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(Level::getLevelDebug())) {
+ $sbuf .= "<font color=\"#339933\">$level</font>";
+ } elseif ($level->equals(Level::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;
+ }
+
+ /**
+ * @return string Returns appropriate HTML headers.
+ */
+ public function getHeader()
+ {
+ $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
+ $sbuf .= "<html>" . PHP_EOL;
+ $sbuf .= "<head>" . PHP_EOL;
+ $sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
+ $sbuf .= "<style type=\"text/css\">" . PHP_EOL;
+ $sbuf .= "<!--" . PHP_EOL;
+ $sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
+ $sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
+ $sbuf .= "-->" . PHP_EOL;
+ $sbuf .= "</style>" . PHP_EOL;
+ $sbuf .= "</head>" . PHP_EOL;
+ $sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
+ $sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
+ $sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
+ $sbuf .= "<br>" . PHP_EOL;
+ $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
+ $sbuf .= "<tr>" . PHP_EOL;
+ $sbuf .= "<th>Time</th>" . PHP_EOL;
+ $sbuf .= "<th>Thread</th>" . PHP_EOL;
+ $sbuf .= "<th>Level</th>" . PHP_EOL;
+ $sbuf .= "<th>Category</th>" . PHP_EOL;
+ if ($this->locationInfo) {
+ $sbuf .= "<th>File:Line</th>" . PHP_EOL;
+ }
+ $sbuf .= "<th>Message</th>" . PHP_EOL;
+ $sbuf .= "</tr>" . PHP_EOL;
+
+ return $sbuf;
+ }
+
+ /**
+ * @return string Returns the appropriate HTML footers.
+ */
+ public function getFooter()
+ {
+ $sbuf = "</table>" . PHP_EOL;
+ $sbuf .= "<br>" . PHP_EOL;
+ $sbuf .= "</body></html>";
+
+ return $sbuf;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/PatternLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/PatternLayout.php b/src/Layouts/PatternLayout.php
index c34cbe2..58f1b50 100644
--- a/src/Layouts/PatternLayout.php
+++ b/src/Layouts/PatternLayout.php
@@ -30,142 +30,148 @@ use Apache\Log4php\LoggingEvent;
* * converionPattern - A string which controls the formatting of logging
* events. See docs for full specification.
*/
-class PatternLayout extends AbstractLayout {
+class PatternLayout extends AbstractLayout
+{
+ /** Default conversion pattern */
+ const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
- /** Default conversion pattern */
- const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
+ /** Default conversion TTCC Pattern */
+ const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
- /** Default conversion TTCC Pattern */
- const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
+ /** The conversion pattern. */
+ protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
- /** The conversion pattern. */
- protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
+ /** Maps conversion keywords to the relevant converter (default implementation). */
+ protected static $defaultConverterMap = array(
+ 'c' => 'LoggerConverter',
+ 'lo' => 'LoggerConverter',
+ 'logger' => 'LoggerConverter',
- /** Maps conversion keywords to the relevant converter (default implementation). */
- protected static $defaultConverterMap = array(
- 'c' => 'LoggerConverter',
- 'lo' => 'LoggerConverter',
- 'logger' => 'LoggerConverter',
-
- 'C' => 'ClassConverter',
- 'class' => 'ClassConverter',
-
- 'cookie' => 'CookieConverter',
-
- 'd' => 'DateConverter',
- 'date' => 'DateConverter',
-
- 'e' => 'EnvironmentConverter',
- 'env' => 'EnvironmentConverter',
-
- 'ex' => 'ThrowableConverter',
- 'exception' => 'ThrowableConverter',
- 'throwable' => 'ThrowableConverter',
-
- 'F' => 'FileConverter',
- 'file' => 'FileConverter',
-
- 'l' => 'LocationConverter',
- 'location' => 'LocationConverter',
-
- 'L' => 'LineConverter',
- 'line' => 'LineConverter',
-
- 'm' => 'MessageConverter',
- 'msg' => 'MessageConverter',
- 'message' => 'MessageConverter',
-
- 'M' => 'MethodConverter',
- 'method' => 'MethodConverter',
-
- 'n' => 'NewLineConverter',
- 'newline' => 'NewLineConverter',
-
- 'p' => 'LevelConverter',
- 'le' => 'LevelConverter',
- 'level' => 'LevelConverter',
-
- 'r' => 'RelativeConverter',
- 'relative' => 'RelativeConverter',
-
- 'req' => 'RequestConverter',
- 'request' => 'RequestConverter',
-
- 's' => 'ServerConverter',
- 'server' => 'ServerConverter',
-
- 'ses' => 'SessionConverter',
- 'session' => 'SessionConverter',
-
- 'sid' => 'SessionIdConverter',
- 'sessionid' => 'SessionIdConverter',
-
- 't' => 'ProcessConverter',
- 'pid' => 'ProcessConverter',
- 'process' => 'ProcessConverter',
-
- 'x' => 'NdcConverter',
- 'ndc' => 'NdcConverter',
-
- 'X' => 'MdcConverter',
- 'mdc' => 'MdcConverter',
- );
-
- /** Maps conversion keywords to the relevant converter. */
- protected $converterMap = array();
-
- /**
- * Head of a chain of Converters.
- * @var AbstractConverter
- */
- private $head;
-
- /** Returns the default converter map. */
- public static function getDefaultConverterMap() {
- return self::$defaultConverterMap;
- }
-
- /** Constructor. Initializes the converter map. */
- public function __construct() {
- $this->converterMap = self::$defaultConverterMap;
- }
-
- /**
- * Sets the conversionPattern option. This is the string which
- * controls formatting and consists of a mix of literal content and
- * conversion specifiers.
- * @param array $conversionPattern
- */
- public function setConversionPattern($conversionPattern) {
- $this->pattern = $conversionPattern;
- }
-
- /**
- * 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 PatternParser($this->pattern, $this->converterMap);
- $this->head = $parser->parse();
- }
-
- /**
- * Produces a formatted string as specified by the conversion pattern.
- *
- * @param LoggingEvent $event
- * @return string
- */
- public function format(LoggingEvent $event) {
- $sbuf = '';
- $converter = $this->head;
- while ($converter !== null) {
- $converter->format($sbuf, $event);
- $converter = $converter->next;
- }
- return $sbuf;
- }
-}
\ No newline at end of file
+ 'C' => 'ClassConverter',
+ 'class' => 'ClassConverter',
+
+ 'cookie' => 'CookieConverter',
+
+ 'd' => 'DateConverter',
+ 'date' => 'DateConverter',
+
+ 'e' => 'EnvironmentConverter',
+ 'env' => 'EnvironmentConverter',
+
+ 'ex' => 'ThrowableConverter',
+ 'exception' => 'ThrowableConverter',
+ 'throwable' => 'ThrowableConverter',
+
+ 'F' => 'FileConverter',
+ 'file' => 'FileConverter',
+
+ 'l' => 'LocationConverter',
+ 'location' => 'LocationConverter',
+
+ 'L' => 'LineConverter',
+ 'line' => 'LineConverter',
+
+ 'm' => 'MessageConverter',
+ 'msg' => 'MessageConverter',
+ 'message' => 'MessageConverter',
+
+ 'M' => 'MethodConverter',
+ 'method' => 'MethodConverter',
+
+ 'n' => 'NewLineConverter',
+ 'newline' => 'NewLineConverter',
+
+ 'p' => 'LevelConverter',
+ 'le' => 'LevelConverter',
+ 'level' => 'LevelConverter',
+
+ 'r' => 'RelativeConverter',
+ 'relative' => 'RelativeConverter',
+
+ 'req' => 'RequestConverter',
+ 'request' => 'RequestConverter',
+
+ 's' => 'ServerConverter',
+ 'server' => 'ServerConverter',
+
+ 'ses' => 'SessionConverter',
+ 'session' => 'SessionConverter',
+
+ 'sid' => 'SessionIdConverter',
+ 'sessionid' => 'SessionIdConverter',
+
+ 't' => 'ProcessConverter',
+ 'pid' => 'ProcessConverter',
+ 'process' => 'ProcessConverter',
+
+ 'x' => 'NdcConverter',
+ 'ndc' => 'NdcConverter',
+
+ 'X' => 'MdcConverter',
+ 'mdc' => 'MdcConverter',
+ );
+
+ /** Maps conversion keywords to the relevant converter. */
+ protected $converterMap = array();
+
+ /**
+ * Head of a chain of Converters.
+ * @var AbstractConverter
+ */
+ private $head;
+
+ /** Returns the default converter map. */
+ public static function getDefaultConverterMap()
+ {
+ return self::$defaultConverterMap;
+ }
+
+ /** Constructor. Initializes the converter map. */
+ public function __construct()
+ {
+ $this->converterMap = self::$defaultConverterMap;
+ }
+
+ /**
+ * Sets the conversionPattern option. This is the string which
+ * controls formatting and consists of a mix of literal content and
+ * conversion specifiers.
+ * @param array $conversionPattern
+ */
+ public function setConversionPattern($conversionPattern)
+ {
+ $this->pattern = $conversionPattern;
+ }
+
+ /**
+ * 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 PatternParser($this->pattern, $this->converterMap);
+ $this->head = $parser->parse();
+ }
+
+ /**
+ * Produces a formatted string as specified by the conversion pattern.
+ *
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event)
+ {
+ $sbuf = '';
+ $converter = $this->head;
+ while ($converter !== null) {
+ $converter->format($sbuf, $event);
+ $converter = $converter->next;
+ }
+
+ return $sbuf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/SerializedLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SerializedLayout.php b/src/Layouts/SerializedLayout.php
index 5273c3b..12fb53f 100644
--- a/src/Layouts/SerializedLayout.php
+++ b/src/Layouts/SerializedLayout.php
@@ -28,26 +28,30 @@ use Apache\Log4php\LoggingEvent;
* be serialized (slow, defaults to false).
* @since 2.2
*/
-class SerializedLayout extends AbstractLayout {
+class SerializedLayout extends AbstractLayout
+{
+ /** Whether to include the event's location information (slow). */
+ protected $locationInfo = false;
- /** Whether to include the event's location information (slow). */
- protected $locationInfo = false;
+ /** Sets the location information flag. */
+ public function setLocationInfo($value)
+ {
+ $this->setBoolean('locationInfo', $value);
+ }
- /** Sets the location information flag. */
- public function setLocationInfo($value) {
- $this->setBoolean('locationInfo', $value);
- }
+ /** Returns the location information flag. */
+ public function getLocationInfo()
+ {
+ return $this->locationInfo;
+ }
- /** Returns the location information flag. */
- public function getLocationInfo() {
- return $this->locationInfo;
- }
+ public function format(LoggingEvent $event)
+ {
+ // If required, initialize the location data
+ if ($this->locationInfo) {
+ $event->getLocationInformation();
+ }
- public function format(LoggingEvent $event) {
- // If required, initialize the location data
- if($this->locationInfo) {
- $event->getLocationInformation();
- }
- return serialize($event) . PHP_EOL;
- }
+ return serialize($event) . PHP_EOL;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/SimpleLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SimpleLayout.php b/src/Layouts/SimpleLayout.php
index 16645f3..5f57e0a 100644
--- a/src/Layouts/SimpleLayout.php
+++ b/src/Layouts/SimpleLayout.php
@@ -26,19 +26,22 @@ use Apache\Log4php\LoggingEvent;
* Returns the log statement in a format consisting of the
* <b>level</b>, followed by " - " and then the <b>message</b>.
*/
-class SimpleLayout extends AbstractLayout {
- /**
- * Returns the log statement in a format consisting of the
- * <b>level</b>, followed by " - " and then the
- * <b>message</b>. For example,
- * <samp> INFO - "A message" </samp>
- *
- * @param LoggingEvent $event
- * @return string
- */
- public function format(LoggingEvent $event) {
- $level = $event->getLevel();
- $message = $event->getRenderedMessage();
- return "$level - $message" . PHP_EOL;
- }
+class SimpleLayout extends AbstractLayout
+{
+ /**
+ * Returns the log statement in a format consisting of the
+ * <b>level</b>, followed by " - " and then the
+ * <b>message</b>. For example,
+ * <samp> INFO - "A message" </samp>
+ *
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event)
+ {
+ $level = $event->getLevel();
+ $message = $event->getRenderedMessage();
+
+ return "$level - $message" . PHP_EOL;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Layouts/XmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/XmlLayout.php b/src/Layouts/XmlLayout.php
index 0ada386..f3b94b0 100644
--- a/src/Layouts/XmlLayout.php
+++ b/src/Layouts/XmlLayout.php
@@ -35,158 +35,167 @@ use Apache\Log4php\LoggingEvent;
* a correct XML file.</p>
*
*/
-class XmlLayout extends AbstractLayout {
- const LOG4J_NS_PREFIX ='log4j';
- const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
-
- const LOG4PHP_NS_PREFIX = 'log4php';
- const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
-
- const CDATA_START = '<![CDATA[';
- const CDATA_END = ']]>';
- const CDATA_PSEUDO_END = ']]>';
- const CDATA_EMBEDDED_END = ']]>]]><![CDATA[';
-
- /**
- * If set to true then the file name and line number of the origin of the
- * log statement will be output.
- * @var boolean
- */
- protected $locationInfo = true;
-
- /**
- * If set to true, log4j namespace will be used instead of the log4php
- * namespace.
- * @var boolean
- */
- protected $log4jNamespace = false;
-
- /** The namespace in use. */
- protected $namespace = self::LOG4PHP_NS;
-
- /** The namespace prefix in use */
- protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
-
- public function activateOptions() {
- if ($this->getLog4jNamespace()) {
- $this->namespace = self::LOG4J_NS;
- $this->namespacePrefix = self::LOG4J_NS_PREFIX;
- } else {
- $this->namespace = self::LOG4PHP_NS;
- $this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
- }
- }
-
- /**
- * @return string
- */
- public function getHeader() {
- return "<{$this->namespacePrefix}:eventSet ".
- "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
- "version=\"0.3\" ".
- "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
- ">" . PHP_EOL;
- }
-
- /**
- * Formats a {@link LoggingEvent} in conformance with the log4php.dtd.
- *
- * @param LoggingEvent $event
- * @return string
- */
- public function format(LoggingEvent $event) {
- $ns = $this->namespacePrefix;
-
- $loggerName = $event->getLoggerName();
- $timeStamp = number_format((float)($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;
- }
-
- /**
- * @return string
- */
- public function getFooter() {
- return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
- }
-
-
- /**
- * Whether or not file name and line number will be included in the output.
- * @return boolean
- */
- public function getLocationInfo() {
- return $this->locationInfo;
- }
-
- /**
- * The {@link $locationInfo} option takes a boolean value. By default,
- * it is set to false which means there will be no location
- * information output by this layout. If the the option is set to
- * true, then the file name and line number of the statement at the
- * origin of the log statement will be output.
- */
- public function setLocationInfo($flag) {
- $this->setBoolean('locationInfo', $flag);
- }
-
- /**
- * @return boolean
- */
- public function getLog4jNamespace() {
- return $this->log4jNamespace;
- }
-
- /**
- * @param boolean
- */
- public function setLog4jNamespace($flag) {
- $this->setBoolean('log4jNamespace', $flag);
- }
-
- /**
- * Encases a string in CDATA tags, and escapes any existing CDATA end
- * tags already present in the string.
- * @param string $string
- */
- private function encodeCDATA($string) {
- $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
- return self::CDATA_START . $string . self::CDATA_END;
- }
+class XmlLayout extends AbstractLayout
+{
+ const LOG4J_NS_PREFIX ='log4j';
+ const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
+
+ const LOG4PHP_NS_PREFIX = 'log4php';
+ const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
+
+ const CDATA_START = '<![CDATA[';
+ const CDATA_END = ']]>';
+ const CDATA_PSEUDO_END = ']]>';
+ const CDATA_EMBEDDED_END = ']]>]]><![CDATA[';
+
+ /**
+ * If set to true then the file name and line number of the origin of the
+ * log statement will be output.
+ * @var boolean
+ */
+ protected $locationInfo = true;
+
+ /**
+ * If set to true, log4j namespace will be used instead of the log4php
+ * namespace.
+ * @var boolean
+ */
+ protected $log4jNamespace = false;
+
+ /** The namespace in use. */
+ protected $namespace = self::LOG4PHP_NS;
+
+ /** The namespace prefix in use */
+ protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
+
+ public function activateOptions()
+ {
+ if ($this->getLog4jNamespace()) {
+ $this->namespace = self::LOG4J_NS;
+ $this->namespacePrefix = self::LOG4J_NS_PREFIX;
+ } else {
+ $this->namespace = self::LOG4PHP_NS;
+ $this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function getHeader()
+ {
+ return "<{$this->namespacePrefix}:eventSet ".
+ "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
+ "version=\"0.3\" ".
+ "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
+ ">" . PHP_EOL;
+ }
+
+ /**
+ * Formats a {@link LoggingEvent} in conformance with the log4php.dtd.
+ *
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event)
+ {
+ $ns = $this->namespacePrefix;
+
+ $loggerName = $event->getLoggerName();
+ $timeStamp = number_format((float) ($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;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFooter()
+ {
+ return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
+ }
+
+ /**
+ * Whether or not file name and line number will be included in the output.
+ * @return boolean
+ */
+ public function getLocationInfo()
+ {
+ return $this->locationInfo;
+ }
+
+ /**
+ * The {@link $locationInfo} option takes a boolean value. By default,
+ * it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement at the
+ * origin of the log statement will be output.
+ */
+ public function setLocationInfo($flag)
+ {
+ $this->setBoolean('locationInfo', $flag);
+ }
+
+ /**
+ * @return boolean
+ */
+ public function getLog4jNamespace()
+ {
+ return $this->log4jNamespace;
+ }
+
+ /**
+ * @param boolean
+ */
+ public function setLog4jNamespace($flag)
+ {
+ $this->setBoolean('log4jNamespace', $flag);
+ }
+
+ /**
+ * Encases a string in CDATA tags, and escapes any existing CDATA end
+ * tags already present in the string.
+ * @param string $string
+ */
+ private function encodeCDATA($string)
+ {
+ $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
+
+ return self::CDATA_START . $string . self::CDATA_END;
+ }
}
-
[31/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/FileAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/FileAppenderTest.php b/tests/src/Appenders/FileAppenderTest.php
index e8ed539..2a0021d 100644
--- a/tests/src/Appenders/FileAppenderTest.php
+++ b/tests/src/Appenders/FileAppenderTest.php
@@ -30,110 +30,118 @@ use Apache\Log4php\Tests\TestHelper;
/**
* @group appenders
*/
-class FileAppenderTest extends \PHPUnit_Framework_TestCase {
-
- private $config1 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'FileAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- ),
- 'params' => array()
- )
- )
- );
-
- private $testPath;
-
- public function __construct() {
- $this->testPath = PHPUNIT_TEMP_DIR . '/TEST.txt';
- }
-
- public function setUp() {
- Logger::resetConfiguration();
- if(file_exists($this->testPath)) {
- unlink($this->testPath);
- }
- }
-
- public function tearDown() {
- Logger::resetConfiguration();
- if(file_exists($this->testPath)) {
- unlink($this->testPath);
- }
- }
-
- public function testRequiresLayout() {
- $appender = new FileAppender();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testActivationDoesNotCreateTheFile() {
- $path = PHPUNIT_TEMP_DIR . "/doesnotexisthopefully.log";
- @unlink($path);
- $appender = new FileAppender();
- $appender->setFile($path);
- $appender->activateOptions();
-
- self::assertFalse(file_exists($path));
-
- $event = TestHelper::getInfoEvent('bla');
- $appender->append($event);
-
- self::assertTrue(file_exists($path));
- }
-
- public function testSimpleLogging() {
- $config = $this->config1;
- $config['appenders']['default']['params']['file'] = $this->testPath;
-
- Logger::configure($config);
-
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- $expected = "INFO - This is a test" . PHP_EOL;
- $actual = file_get_contents($this->testPath);
- $this->assertSame($expected, $actual);
- }
-
- public function testAppendFlagTrue() {
- $config = $this->config1;
- $config['appenders']['default']['params']['file'] = $this->testPath;
- $config['appenders']['default']['params']['append'] = true;
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- $expected = "INFO - This is a test" . PHP_EOL . "INFO - This is a test" . PHP_EOL;
- $actual = file_get_contents($this->testPath);
- $this->assertSame($expected, $actual);
- }
-
- public function testAppendFlagFalse() {
- $config = $this->config1;
- $config['appenders']['default']['params']['file'] = $this->testPath;
- $config['appenders']['default']['params']['append'] = false;
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- $expected = "INFO - This is a test" . PHP_EOL;
- $actual = file_get_contents($this->testPath);
- $this->assertSame($expected, $actual);
- }
+class FileAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ private $config1 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'FileAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array()
+ )
+ )
+ );
+
+ private $testPath;
+
+ public function __construct()
+ {
+ $this->testPath = PHPUNIT_TEMP_DIR . '/TEST.txt';
+ }
+
+ public function setUp()
+ {
+ Logger::resetConfiguration();
+ if (file_exists($this->testPath)) {
+ unlink($this->testPath);
+ }
+ }
+
+ public function tearDown()
+ {
+ Logger::resetConfiguration();
+ if (file_exists($this->testPath)) {
+ unlink($this->testPath);
+ }
+ }
+
+ public function testRequiresLayout()
+ {
+ $appender = new FileAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testActivationDoesNotCreateTheFile()
+ {
+ $path = PHPUNIT_TEMP_DIR . "/doesnotexisthopefully.log";
+ @unlink($path);
+ $appender = new FileAppender();
+ $appender->setFile($path);
+ $appender->activateOptions();
+
+ self::assertFalse(file_exists($path));
+
+ $event = TestHelper::getInfoEvent('bla');
+ $appender->append($event);
+
+ self::assertTrue(file_exists($path));
+ }
+
+ public function testSimpleLogging()
+ {
+ $config = $this->config1;
+ $config['appenders']['default']['params']['file'] = $this->testPath;
+
+ Logger::configure($config);
+
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ $expected = "INFO - This is a test" . PHP_EOL;
+ $actual = file_get_contents($this->testPath);
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testAppendFlagTrue()
+ {
+ $config = $this->config1;
+ $config['appenders']['default']['params']['file'] = $this->testPath;
+ $config['appenders']['default']['params']['append'] = true;
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ $expected = "INFO - This is a test" . PHP_EOL . "INFO - This is a test" . PHP_EOL;
+ $actual = file_get_contents($this->testPath);
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testAppendFlagFalse()
+ {
+ $config = $this->config1;
+ $config['appenders']['default']['params']['file'] = $this->testPath;
+ $config['appenders']['default']['params']['append'] = false;
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ $expected = "INFO - This is a test" . PHP_EOL;
+ $actual = file_get_contents($this->testPath);
+ $this->assertSame($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/MailAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/MailAppenderTest.php b/tests/src/Appenders/MailAppenderTest.php
index 73c7e83..c317b66 100644
--- a/tests/src/Appenders/MailAppenderTest.php
+++ b/tests/src/Appenders/MailAppenderTest.php
@@ -31,34 +31,36 @@ use Apache\Log4php\LoggingEvent;
/**
* @group appenders
*/
-class MailAppenderTest extends \PHPUnit_Framework_TestCase {
-
- public function testRequiresLayout() {
- $appender = new MailAppender();
- self::assertTrue($appender->requiresLayout());
- }
+class MailAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ public function testRequiresLayout()
+ {
+ $appender = new MailAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
- public function testMail() {
- $appender = new MailAppender("myname ");
+ public function testMail()
+ {
+ $appender = new MailAppender("myname ");
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
- $appender->setDry(true);
- $appender->setTo('test@example.com');
- $appender->setFrom('Testsender');
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->setDry(true);
+ $appender->setTo('test@example.com');
+ $appender->setFrom('Testsender');
- $appender->activateOptions();
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $event2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage2");
+ $appender->activateOptions();
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $event2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage2");
- ob_start();
- $appender->append($event);
- $appender->append($event2);
- $appender->close();
- $v = ob_get_contents();
- ob_end_clean();
+ ob_start();
+ $appender->append($event);
+ $appender->append($event2);
+ $appender->close();
+ $v = ob_get_contents();
+ ob_end_clean();
- $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with content: ERROR - testmessage".PHP_EOL."ERROR - testmessage2".PHP_EOL;
- self::assertEquals($e, $v);
+ $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with content: ERROR - testmessage".PHP_EOL."ERROR - testmessage2".PHP_EOL;
+ self::assertEquals($e, $v);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/MailEventAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/MailEventAppenderTest.php b/tests/src/Appenders/MailEventAppenderTest.php
index 2199f83..51f1957 100644
--- a/tests/src/Appenders/MailEventAppenderTest.php
+++ b/tests/src/Appenders/MailEventAppenderTest.php
@@ -31,56 +31,60 @@ use Apache\Log4php\LoggingEvent;
/**
* @group appenders
*/
-class MailEventAppenderTest extends \PHPUnit_Framework_TestCase {
+class MailEventAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ public function testRequiresLayout()
+ {
+ $appender = new MailEventAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
- public function testRequiresLayout() {
- $appender = new MailEventAppender();
- self::assertTrue($appender->requiresLayout());
- }
+ public function testMail()
+ {
+ $appender = new MailEventAppender("myname");
- public function testMail() {
- $appender = new MailEventAppender("myname");
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->setDry(true);
+ $appender->setTo('test@example.com');
+ $appender->setFrom('Testsender');
- $layout = new SimpleLayout();
- $appender->setLayout($layout);
- $appender->setDry(true);
- $appender->setTo('test@example.com');
- $appender->setFrom('Testsender');
+ $appender->activateOptions();
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $appender->activateOptions();
- $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ ob_start();
+ $appender->append($event);
+ $v = ob_get_contents();
+ ob_end_clean();
- ob_start();
- $appender->append($event);
- $v = ob_get_contents();
- ob_end_clean();
+ $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with additional headers 'From: Testsender' and content: ERROR - testmessage".PHP_EOL;
+ self::assertEquals($e, $v);
+ $appender->close();
+ }
- $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with additional headers 'From: Testsender' and content: ERROR - testmessage".PHP_EOL;
- self::assertEquals($e, $v);
- $appender->close();
- }
+ /**
+ * Check an error is reported if 'to' is not set.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'to' not set.
+ */
+ public function testEmptyTo()
+ {
+ $appender = new MailEventAppender("myname");
+ $appender->setLayout(new SimpleLayout());
+ $appender->setFrom('info@example.com');
+ $appender->activateOptions();
+ }
- /**
- * Check an error is reported if 'to' is not set.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'to' not set.
- */
- public function testEmptyTo() {
- $appender = new MailEventAppender("myname");
- $appender->setLayout(new SimpleLayout());
- $appender->setFrom('info@example.com');
- $appender->activateOptions();
- }
-
- /**
- * Check an error is reported if 'from' is not set.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'from' not set.
- */
- public function testEmptyFrom() {
- $appender = new MailEventAppender("myname");
- $appender->setLayout(new SimpleLayout());
- $appender->setTo('info@example.com');
- $appender->activateOptions();
- }
+ /**
+ * Check an error is reported if 'from' is not set.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'from' not set.
+ */
+ public function testEmptyFrom()
+ {
+ $appender = new MailEventAppender("myname");
+ $appender->setLayout(new SimpleLayout());
+ $appender->setTo('info@example.com');
+ $appender->activateOptions();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/MongoDBAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/MongoDBAppenderTest.php b/tests/src/Appenders/MongoDBAppenderTest.php
index e4622dd..6194ff0 100644
--- a/tests/src/Appenders/MongoDBAppenderTest.php
+++ b/tests/src/Appenders/MongoDBAppenderTest.php
@@ -36,178 +36,192 @@ use Apache\Log4php\Tests\TestHelper;
*
* @group appenders
*/
-class MongoDBAppenderTest extends \PHPUnit_Framework_TestCase {
-
- protected $appender;
- protected $event;
-
- protected function setUp() {
- if (!extension_loaded('mongo')) {
- $this->markTestSkipped(
- 'The Mongo extension is not available.'
- );
- } else {
- $this->appender = new MongoDBAppender('mongo_appender');
- $this->event = TestHelper::getErrorEvent('mongo logging event', 'test_mongo');
- }
- }
-
- protected function tearDown() {
- unset($this->appender);
- }
-
- public function testHost() {
- $expected = 'mongodb://localhost';
- $this->appender->setHost($expected);
- $result = $this->appender->getHost();
- $this->assertEquals($expected, $result);
- }
-
- public function testPort() {
- $expected = 27017;
- $this->appender->setPort($expected);
- $result = $this->appender->getPort();
- $this->assertEquals($expected, $result);
- }
-
- public function testDatabaseName() {
- $expected = 'log4php_mongodb';
- $this->appender->setDatabaseName($expected);
- $result = $this->appender->getDatabaseName();
- $this->assertEquals($expected, $result);
- }
-
- public function testCollectionName() {
- $expected = 'logs';
- $this->appender->setCollectionName($expected);
- $result = $this->appender->getCollectionName();
- $this->assertEquals($expected, $result);
- }
-
- public function testUserName() {
- $expected = 'char0n';
- $this->appender->setUserName($expected);
- $result = $this->appender->getUserName();
- $this->assertEquals($expected, $result);
- }
-
- public function testPassword() {
- $expected = 'secret pass';
- $this->appender->setPassword($expected);
- $result = $this->appender->getPassword();
- $this->assertEquals($expected, $result);
- }
-
- public function testTimeout() {
- $expected = 4000;
- $this->appender->setTimeout($expected);
- $result = $this->appender->getTimeout();
- $this->assertEquals($expected, $result);
- }
-
- public function testActivateOptions() {
- $this->appender->activateOptions();
- $this->assertInstanceOf('Mongo', $this->appender->getConnection());
- $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
- }
-
- public function testActivateOptionsNoCredentials() {
- $this->appender->setUserName(null);
- $this->appender->setPassword(null);
- $this->appender->activateOptions();
- $this->assertInstanceOf('Mongo', $this->appender->getConnection());
- $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
- }
-
- public function testFormat() {
- $this->appender->activateOptions();
- $record = $this->logOne($this->event);
-
- $this->assertEquals('ERROR', $record['level']);
- $this->assertEquals('mongo logging event', $record['message']);
- $this->assertEquals('test_mongo', $record['loggerName']);
-
- $this->assertEquals('NA', $record['fileName']);
- $this->assertEquals('getLocationInformation', $record['method']);
- $this->assertEquals('NA', $record['lineNumber']);
- $this->assertEquals('Apache\\Log4php\\LoggingEvent', $record['className']);
-
- $this->assertTrue(is_int($record['thread']));
- $this->assertSame(getmypid(), $record['thread']);
- $this->assertTrue(is_int($record['lineNumber']) || $record['lineNumber'] == 'NA');
- }
-
- public function testFormatThrowableInfo() {
- $this->appender->activateOptions();
- $event = new LoggingEvent(
- 'testFqcn',
- new Logger('test.Logger'),
- Level::getLevelWarn(),
- 'test message',
- microtime(true),
- new \Exception('test exception', 1)
- );
-
- $record = $this->logOne($event);
-
- $this->assertArrayHasKey('exception', $record);
- $this->assertEquals(1, $record['exception']['code']);
- $this->assertEquals('test exception', $record['exception']['message']);
-
- $this->assertContains('[internal function]: ' . __CLASS__, $record['exception']['stackTrace']);
- }
-
- public function testFormatThrowableInfoWithInnerException() {
-
- // Skip test if PHP version is lower than 5.3.0 (no inner exception support)
- if (version_compare(PHP_VERSION, '5.3.0') < 0) {
- $this->markTestSkipped();
- }
-
- $this->appender->activateOptions();
- $event = new LoggingEvent(
- 'testFqcn',
- new Logger('test.Logger'),
- Level::getLevelWarn(),
- 'test message',
- microtime(true),
- new \Exception('test exception', 1, new \Exception('test exception inner', 2))
- );
-
- $record = $this->logOne($event);
-
- $this->assertArrayHasKey('exception', $record);
- $this->assertEquals(1, $record['exception']['code']);
- $this->assertEquals('test exception', $record['exception']['message']);
- $this->assertContains('[internal function]: ' . __CLASS__, $record['exception']['stackTrace']);
-
- $this->assertArrayHasKey('innerException', $record['exception']);
- $this->assertEquals(2, $record['exception']['innerException']['code']);
- $this->assertEquals('test exception inner', $record['exception']['innerException']['message']);
- }
-
-
- public function testClose() {
- $this->appender->activateOptions();
- $this->assertInstanceOf('Mongo', $this->appender->getConnection());
- $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
- $this->appender->close();
- $this->assertNull($this->appender->getConnection());
- $this->assertNull($this->appender->getCollection());
- }
-
- /**
- * Logs the event and returns the record from the database.
- * @param LoggingEvent $event
- * @return array
- */
- private function logOne($event)
- {
- $collection = $this->appender->getCollection();
- $collection->drop();
- $this->appender->append($event);
- $record = $collection->findOne();
- $this->assertNotNull($record, 'Could not read the record from the database.');
- return $record;
- }
+class MongoDBAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ protected $appender;
+ protected $event;
+
+ protected function setUp()
+ {
+ if (!extension_loaded('mongo')) {
+ $this->markTestSkipped(
+ 'The Mongo extension is not available.'
+ );
+ } else {
+ $this->appender = new MongoDBAppender('mongo_appender');
+ $this->event = TestHelper::getErrorEvent('mongo logging event', 'test_mongo');
+ }
+ }
+
+ protected function tearDown()
+ {
+ unset($this->appender);
+ }
+
+ public function testHost()
+ {
+ $expected = 'mongodb://localhost';
+ $this->appender->setHost($expected);
+ $result = $this->appender->getHost();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testPort()
+ {
+ $expected = 27017;
+ $this->appender->setPort($expected);
+ $result = $this->appender->getPort();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testDatabaseName()
+ {
+ $expected = 'log4php_mongodb';
+ $this->appender->setDatabaseName($expected);
+ $result = $this->appender->getDatabaseName();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testCollectionName()
+ {
+ $expected = 'logs';
+ $this->appender->setCollectionName($expected);
+ $result = $this->appender->getCollectionName();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testUserName()
+ {
+ $expected = 'char0n';
+ $this->appender->setUserName($expected);
+ $result = $this->appender->getUserName();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testPassword()
+ {
+ $expected = 'secret pass';
+ $this->appender->setPassword($expected);
+ $result = $this->appender->getPassword();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testTimeout()
+ {
+ $expected = 4000;
+ $this->appender->setTimeout($expected);
+ $result = $this->appender->getTimeout();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testActivateOptions()
+ {
+ $this->appender->activateOptions();
+ $this->assertInstanceOf('Mongo', $this->appender->getConnection());
+ $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
+ }
+
+ public function testActivateOptionsNoCredentials()
+ {
+ $this->appender->setUserName(null);
+ $this->appender->setPassword(null);
+ $this->appender->activateOptions();
+ $this->assertInstanceOf('Mongo', $this->appender->getConnection());
+ $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
+ }
+
+ public function testFormat()
+ {
+ $this->appender->activateOptions();
+ $record = $this->logOne($this->event);
+
+ $this->assertEquals('ERROR', $record['level']);
+ $this->assertEquals('mongo logging event', $record['message']);
+ $this->assertEquals('test_mongo', $record['loggerName']);
+
+ $this->assertEquals('NA', $record['fileName']);
+ $this->assertEquals('getLocationInformation', $record['method']);
+ $this->assertEquals('NA', $record['lineNumber']);
+ $this->assertEquals('Apache\\Log4php\\LoggingEvent', $record['className']);
+
+ $this->assertTrue(is_int($record['thread']));
+ $this->assertSame(getmypid(), $record['thread']);
+ $this->assertTrue(is_int($record['lineNumber']) || $record['lineNumber'] == 'NA');
+ }
+
+ public function testFormatThrowableInfo()
+ {
+ $this->appender->activateOptions();
+ $event = new LoggingEvent(
+ 'testFqcn',
+ new Logger('test.Logger'),
+ Level::getLevelWarn(),
+ 'test message',
+ microtime(true),
+ new \Exception('test exception', 1)
+ );
+
+ $record = $this->logOne($event);
+
+ $this->assertArrayHasKey('exception', $record);
+ $this->assertEquals(1, $record['exception']['code']);
+ $this->assertEquals('test exception', $record['exception']['message']);
+
+ $this->assertContains('[internal function]: ' . __CLASS__, $record['exception']['stackTrace']);
+ }
+
+ public function testFormatThrowableInfoWithInnerException()
+ {
+ // Skip test if PHP version is lower than 5.3.0 (no inner exception support)
+ if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ $this->markTestSkipped();
+ }
+
+ $this->appender->activateOptions();
+ $event = new LoggingEvent(
+ 'testFqcn',
+ new Logger('test.Logger'),
+ Level::getLevelWarn(),
+ 'test message',
+ microtime(true),
+ new \Exception('test exception', 1, new \Exception('test exception inner', 2))
+ );
+
+ $record = $this->logOne($event);
+
+ $this->assertArrayHasKey('exception', $record);
+ $this->assertEquals(1, $record['exception']['code']);
+ $this->assertEquals('test exception', $record['exception']['message']);
+ $this->assertContains('[internal function]: ' . __CLASS__, $record['exception']['stackTrace']);
+
+ $this->assertArrayHasKey('innerException', $record['exception']);
+ $this->assertEquals(2, $record['exception']['innerException']['code']);
+ $this->assertEquals('test exception inner', $record['exception']['innerException']['message']);
+ }
+
+ public function testClose()
+ {
+ $this->appender->activateOptions();
+ $this->assertInstanceOf('Mongo', $this->appender->getConnection());
+ $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
+ $this->appender->close();
+ $this->assertNull($this->appender->getConnection());
+ $this->assertNull($this->appender->getCollection());
+ }
+
+ /**
+ * Logs the event and returns the record from the database.
+ * @param LoggingEvent $event
+ * @return array
+ */
+ private function logOne($event)
+ {
+ $collection = $this->appender->getCollection();
+ $collection->drop();
+ $this->appender->append($event);
+ $record = $collection->findOne();
+ $this->assertNotNull($record, 'Could not read the record from the database.');
+
+ return $record;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/NullAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/NullAppenderTest.php b/tests/src/Appenders/NullAppenderTest.php
index 5c7a96e..dfde21f 100644
--- a/tests/src/Appenders/NullAppenderTest.php
+++ b/tests/src/Appenders/NullAppenderTest.php
@@ -30,22 +30,25 @@ use Apache\Log4php\LoggingEvent;
/**
* @group appenders
*/
-class NullAppenderTest extends \PHPUnit_Framework_TestCase {
- /**
- * The Null appender does nothing - nothing to assert.
- * Just here for the sake of completness and a good testing ratio :-)
- */
- public function testActivateOptions() {
+class NullAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * The Null appender does nothing - nothing to assert.
+ * Just here for the sake of completness and a good testing ratio :-)
+ */
+ public function testActivateOptions()
+ {
$event = new LoggingEvent("LoggerAppenderNullTest", new Logger("TEST"), Level::getLevelInfo(), "testmessage");
- $appender = new NullAppender("TEST");
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
+ $appender = new NullAppender("TEST");
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
}
- public function testRequiresLayout() {
- $appender = new NullAppender();
- self::assertFalse($appender->requiresLayout());
- }
+ public function testRequiresLayout()
+ {
+ $appender = new NullAppender();
+ self::assertFalse($appender->requiresLayout());
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/PDOAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/PDOAppenderTest.php b/tests/src/Appenders/PDOAppenderTest.php
index b325e04..2f82ee6 100644
--- a/tests/src/Appenders/PDOAppenderTest.php
+++ b/tests/src/Appenders/PDOAppenderTest.php
@@ -32,139 +32,144 @@ use PDO;
/**
* @group appenders
*/
-class PDOAppenderTest extends \PHPUnit_Framework_TestCase {
-
- const FILENAME = 'pdotest.sqlite';
- private static $dsn;
- private static $file;
-
- public static function setUpBeforeClass() {
-
- self::$file = PHPUNIT_TEMP_DIR . '/' . self::FILENAME;
- self::$dsn = 'sqlite:' . self::$file;
-
- if(extension_loaded('pdo_sqlite')) {
- $drop = 'DROP TABLE IF EXISTS log4php_log;';
- $create = 'CREATE TABLE log4php_log (
- timestamp VARCHAR(256),
- logger VARCHAR(256),
- level VARCHAR(32),
- message VARCHAR(4000),
- thread INTEGER,
- file VARCHAR(255),
- line VARCHAR(10)
- );';
-
- $pdo = new PDO(self::$dsn);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $pdo->exec($drop);
- $pdo->exec($create);
- }
- }
-
- /** To start with an empty database for each single test. */
- public function setUp() {
- if(!extension_loaded('pdo_sqlite')) {
- self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
- }
- }
-
- /** Clean up after the last test was run. */
- public static function tearDownAfterClass() {
- @unlink(self::$file);
- }
-
- public function testRequiresLayout() {
- $appender = new PDOAppender();
- self::assertFalse($appender->requiresLayout());
- }
-
- /** Tests new-style logging using prepared statements and the default SQL definition. */
- public function testSimpleWithDefaults() {
- // Log event
- $event = new LoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $appender = new PDOAppender("myname");
- $appender->setDSN(self::$dsn);
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- // Test the default pattern
- $db = new PDO(self::$dsn);
- $query = "SELECT * FROM log4php_log";
- $sth = $db->query($query);
- $row = $sth->fetch(PDO::FETCH_NUM);
-
- self::assertTrue(is_array($row), "No rows found.");
- self::assertEquals(7, count($row));
- self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row[0])); // datetime
- self::assertEquals('TEST', $row[1]); // logger name
- self::assertEquals('ERROR', $row[2]); // level
- self::assertEquals('testmessage', $row[3]); // message
- if (function_exists('posix_getpid')) {
- self::assertEquals(posix_getpid(), $row[4]); // process id
- }
- self::assertEquals('NA', $row[5]); // file, NA due to phpunit magic
- self::assertEquals('NA', $row[6]); // line, NA due to phpunit magic
- }
-
-
- /** Tests new style prepared statment logging with customized SQL. */
- public function testCustomizedSql() {
-
- $dateFormat = "Y-m-d H:i:s";
-
- // Prepare appender
- $appender = new PDOAppender("myname");
- $appender->setDSN(self::$dsn);
- $appender->setInsertSql("INSERT INTO log4php_log (file, line, thread, timestamp, logger, level, message) VALUES (?,?,?,?,?,?,?)");
- $appender->setInsertPattern("%F,%L,%t,%d\{$dateFormat\},%c,%p,%m");
- $appender->activateOptions();
-
- // Action!
- $event = new LoggingEvent("LoggerAppenderPDOTest2", new Logger("TEST"), Level::getLevelError(), "testmessage");
- $appender->append($event);
-
- // Check
- $db = new PDO(self::$dsn);
- $result = $db->query("SELECT * FROM log4php_log");
- $row = $result->fetch(PDO::FETCH_OBJ);
- self::assertTrue(is_object($row));
- self::assertEquals("NA", $row->file); // "NA" due to phpunit magic
- self::assertEquals("NA", $row->line); // "NA" due to phpunit magic
- if (function_exists('posix_getpid')) {
- self::assertEquals(posix_getpid(), $row->thread);
- }
- self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row->timestamp));
- self::assertEquals('TEST', $row->logger);
- self::assertEquals('ERROR', $row->level);
- self::assertEquals('testmessage', $row->message);
- }
-
- /**
- * Tests a warning is shown when connecting to invalid dns.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage invalid data source name
- */
- public function testException() {
- $dsn = 'doenotexist';
- $appender = new PDOAppender("myname");
- $appender->setDSN($dsn);
- $appender->activateOptions();
- }
-
- /**
- * Check whether close() actually closes the database connection.
- */
- public function testClose() {
- $event = new LoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
-
- $appender = new PDOAppender("myname");
- $appender->setDSN(self::$dsn);
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- self::assertNull($appender->getDatabaseHandle());
- }
+class PDOAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ const FILENAME = 'pdotest.sqlite';
+ private static $dsn;
+ private static $file;
+
+ public static function setUpBeforeClass()
+ {
+ self::$file = PHPUNIT_TEMP_DIR . '/' . self::FILENAME;
+ self::$dsn = 'sqlite:' . self::$file;
+
+ if (extension_loaded('pdo_sqlite')) {
+ $drop = 'DROP TABLE IF EXISTS log4php_log;';
+ $create = 'CREATE TABLE log4php_log (
+ timestamp VARCHAR(256),
+ logger VARCHAR(256),
+ level VARCHAR(32),
+ message VARCHAR(4000),
+ thread INTEGER,
+ file VARCHAR(255),
+ line VARCHAR(10)
+ );';
+
+ $pdo = new PDO(self::$dsn);
+ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $pdo->exec($drop);
+ $pdo->exec($create);
+ }
+ }
+
+ /** To start with an empty database for each single test. */
+ public function setUp()
+ {
+ if (!extension_loaded('pdo_sqlite')) {
+ self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
+ }
+ }
+
+ /** Clean up after the last test was run. */
+ public static function tearDownAfterClass()
+ {
+ @unlink(self::$file);
+ }
+
+ public function testRequiresLayout()
+ {
+ $appender = new PDOAppender();
+ self::assertFalse($appender->requiresLayout());
+ }
+
+ /** Tests new-style logging using prepared statements and the default SQL definition. */
+ public function testSimpleWithDefaults()
+ {
+ // Log event
+ $event = new LoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $appender = new PDOAppender("myname");
+ $appender->setDSN(self::$dsn);
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ // Test the default pattern
+ $db = new PDO(self::$dsn);
+ $query = "SELECT * FROM log4php_log";
+ $sth = $db->query($query);
+ $row = $sth->fetch(PDO::FETCH_NUM);
+
+ self::assertTrue(is_array($row), "No rows found.");
+ self::assertEquals(7, count($row));
+ self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row[0])); // datetime
+ self::assertEquals('TEST', $row[1]); // logger name
+ self::assertEquals('ERROR', $row[2]); // level
+ self::assertEquals('testmessage', $row[3]); // message
+ if (function_exists('posix_getpid')) {
+ self::assertEquals(posix_getpid(), $row[4]); // process id
+ }
+ self::assertEquals('NA', $row[5]); // file, NA due to phpunit magic
+ self::assertEquals('NA', $row[6]); // line, NA due to phpunit magic
+ }
+
+ /** Tests new style prepared statment logging with customized SQL. */
+ public function testCustomizedSql()
+ {
+ $dateFormat = "Y-m-d H:i:s";
+
+ // Prepare appender
+ $appender = new PDOAppender("myname");
+ $appender->setDSN(self::$dsn);
+ $appender->setInsertSql("INSERT INTO log4php_log (file, line, thread, timestamp, logger, level, message) VALUES (?,?,?,?,?,?,?)");
+ $appender->setInsertPattern("%F,%L,%t,%d\{$dateFormat\},%c,%p,%m");
+ $appender->activateOptions();
+
+ // Action!
+ $event = new LoggingEvent("LoggerAppenderPDOTest2", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $appender->append($event);
+
+ // Check
+ $db = new PDO(self::$dsn);
+ $result = $db->query("SELECT * FROM log4php_log");
+ $row = $result->fetch(PDO::FETCH_OBJ);
+ self::assertTrue(is_object($row));
+ self::assertEquals("NA", $row->file); // "NA" due to phpunit magic
+ self::assertEquals("NA", $row->line); // "NA" due to phpunit magic
+ if (function_exists('posix_getpid')) {
+ self::assertEquals(posix_getpid(), $row->thread);
+ }
+ self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row->timestamp));
+ self::assertEquals('TEST', $row->logger);
+ self::assertEquals('ERROR', $row->level);
+ self::assertEquals('testmessage', $row->message);
+ }
+
+ /**
+ * Tests a warning is shown when connecting to invalid dns.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage invalid data source name
+ */
+ public function testException()
+ {
+ $dsn = 'doenotexist';
+ $appender = new PDOAppender("myname");
+ $appender->setDSN($dsn);
+ $appender->activateOptions();
+ }
+
+ /**
+ * Check whether close() actually closes the database connection.
+ */
+ public function testClose()
+ {
+ $event = new LoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $appender = new PDOAppender("myname");
+ $appender->setDSN(self::$dsn);
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ self::assertNull($appender->getDatabaseHandle());
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/PhpAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/PhpAppenderTest.php b/tests/src/Appenders/PhpAppenderTest.php
index 0653f65..7fb0ddc 100644
--- a/tests/src/Appenders/PhpAppenderTest.php
+++ b/tests/src/Appenders/PhpAppenderTest.php
@@ -28,71 +28,74 @@ use Apache\Log4php\Logger;
/**
* @group appenders
*/
-class PhpAppenderTest extends \PHPUnit_Framework_TestCase {
-
- public static $expectedMessage;
-
- public static $expectedError;
-
- private $config = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- 'level' => 'trace'
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'PhpAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout'
- ),
- )
- )
- );
-
- protected function setUp() {
- $that = $this; // hack for PHP 5.3
- set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
- $that::assertEquals($that::$expectedError, $errno);
- $that::assertEquals($that::$expectedMessage, $errstr);
- });
- }
-
- public function testRequiresLayout() {
- $appender = new PhpAppender();
- $this->assertTrue($appender->requiresLayout());
- }
+class PhpAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ public static $expectedMessage;
+
+ public static $expectedError;
+
+ private $config = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ 'level' => 'trace'
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'PhpAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ )
+ )
+ );
+
+ protected function setUp()
+ {
+ $that = $this; // hack for PHP 5.3
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
+ $that::assertEquals($that::$expectedError, $errno);
+ $that::assertEquals($that::$expectedMessage, $errstr);
+ });
+ }
- public function testPhp() {
- Logger::configure($this->config);
- $logger = Logger::getRootLogger();
+ public function testRequiresLayout()
+ {
+ $appender = new PhpAppender();
+ $this->assertTrue($appender->requiresLayout());
+ }
+ public function testPhp()
+ {
+ Logger::configure($this->config);
+ $logger = Logger::getRootLogger();
- self::$expectedError = E_USER_ERROR;
- self::$expectedMessage = "FATAL - This is a test" . PHP_EOL;
- $logger->fatal("This is a test");
+ self::$expectedError = E_USER_ERROR;
+ self::$expectedMessage = "FATAL - This is a test" . PHP_EOL;
+ $logger->fatal("This is a test");
- self::$expectedError = E_USER_ERROR;
- self::$expectedMessage = "ERROR - This is a test" . PHP_EOL;
- $logger->error("This is a test");
+ self::$expectedError = E_USER_ERROR;
+ self::$expectedMessage = "ERROR - This is a test" . PHP_EOL;
+ $logger->error("This is a test");
- self::$expectedError = E_USER_WARNING;
- self::$expectedMessage = "WARN - This is a test" . PHP_EOL;
- $logger->warn("This is a test");
+ self::$expectedError = E_USER_WARNING;
+ self::$expectedMessage = "WARN - This is a test" . PHP_EOL;
+ $logger->warn("This is a test");
- self::$expectedError = E_USER_NOTICE;
- self::$expectedMessage = "INFO - This is a test" . PHP_EOL;
- $logger->info("This is a test");
+ self::$expectedError = E_USER_NOTICE;
+ self::$expectedMessage = "INFO - This is a test" . PHP_EOL;
+ $logger->info("This is a test");
- self::$expectedError = E_USER_NOTICE;
- self::$expectedMessage = "DEBUG - This is a test" . PHP_EOL;
- $logger->debug("This is a test");
+ self::$expectedError = E_USER_NOTICE;
+ self::$expectedMessage = "DEBUG - This is a test" . PHP_EOL;
+ $logger->debug("This is a test");
- self::$expectedError = E_USER_NOTICE;
- self::$expectedMessage = "TRACE - This is a test" . PHP_EOL;
- $logger->trace("This is a test");
+ self::$expectedError = E_USER_NOTICE;
+ self::$expectedMessage = "TRACE - This is a test" . PHP_EOL;
+ $logger->trace("This is a test");
}
- protected function tearDown() {
- restore_error_handler();
- }
+ protected function tearDown()
+ {
+ restore_error_handler();
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/RollingFileAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/RollingFileAppenderTest.php b/tests/src/Appenders/RollingFileAppenderTest.php
index d284f3c..725abc8 100644
--- a/tests/src/Appenders/RollingFileAppenderTest.php
+++ b/tests/src/Appenders/RollingFileAppenderTest.php
@@ -25,188 +25,196 @@ namespace Apache\Log4php\Tests\Appenders;
use Apache\Log4php\Appenders\RollingFileAppender;
use Apache\Log4php\Layouts\SimpleLayout;
use Apache\Log4php\Tests\TestHelper;
-use Apache\Log4php\LoggingEvent;
use Apache\Log4php\Logger;
-use Apache\Log4php\Level;
/**
* @group appenders
*/
-class RollingFileAppenderTest extends \PHPUnit_Framework_TestCase {
+class RollingFileAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ const WARNING_MASSAGE = 'WARN - my messageXYZ';
- const WARNING_MASSAGE = 'WARN - my messageXYZ';
+ protected function setUp()
+ {
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1');
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2');
+ }
- protected function setUp() {
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1');
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2');
- }
+ public function testRequiresLayout()
+ {
+ $appender = new RollingFileAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
- public function testRequiresLayout() {
- $appender = new RollingFileAppender();
- self::assertTrue($appender->requiresLayout());
- }
+ public function testMaxFileSize()
+ {
+ $appender = new RollingFileAppender("mylogger");
- public function testMaxFileSize() {
- $appender = new RollingFileAppender("mylogger");
+ $appender->setMaxFileSize('1KB');
+ self::assertEquals(1024, $appender->getMaxFileSize());
- $appender->setMaxFileSize('1KB');
- self::assertEquals(1024, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('2KB');
+ self::assertEquals(2048, $appender->getMaxFileSize());
- $appender->setMaxFileSize('2KB');
- self::assertEquals(2048, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('1MB');
+ self::assertEquals(1048576, $appender->getMaxFileSize());
- $appender->setMaxFileSize('1MB');
- self::assertEquals(1048576, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('3MB');
+ self::assertEquals(3145728, $appender->getMaxFileSize());
- $appender->setMaxFileSize('3MB');
- self::assertEquals(3145728, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('1GB');
+ self::assertEquals(1073741824, $appender->getMaxFileSize());
- $appender->setMaxFileSize('1GB');
- self::assertEquals(1073741824, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('10000');
+ self::assertEquals(10000, $appender->getMaxFileSize());
- $appender->setMaxFileSize('10000');
- self::assertEquals(10000, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('100.5');
+ self::assertEquals(100, $appender->getMaxFileSize());
- $appender->setMaxFileSize('100.5');
- self::assertEquals(100, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('1000.6');
+ self::assertEquals(1000, $appender->getMaxFileSize());
- $appender->setMaxFileSize('1000.6');
- self::assertEquals(1000, $appender->getMaxFileSize());
+ $appender->setMaxFileSize('1.5MB');
+ self::assertEquals(1572864, $appender->getMaxFileSize());
+ }
- $appender->setMaxFileSize('1.5MB');
- self::assertEquals(1572864, $appender->getMaxFileSize());
- }
+ /**
+ * @return RollingFileAppender
+ */
+ private function createRolloverAppender()
+ {
+ $layout = new SimpleLayout();
- /**
- * @return RollingFileAppender
- */
- private function createRolloverAppender() {
- $layout = new SimpleLayout();
+ $appender = new RollingFileAppender("mylogger");
+ $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
+ $appender->setLayout($layout);
+ $appender->setMaxFileSize('1KB');
+ $appender->setMaxBackupIndex(2);
+ $appender->activateOptions();
- $appender = new RollingFileAppender("mylogger");
- $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
- $appender->setLayout($layout);
- $appender->setMaxFileSize('1KB');
- $appender->setMaxBackupIndex(2);
- $appender->activateOptions();
+ return $appender;
+ }
- return $appender;
- }
+ public function testSimpleLogging()
+ {
+ $appender = $this->createRolloverAppender();
- public function testSimpleLogging() {
- $appender = $this->createRolloverAppender();
+ $event = TestHelper::getWarnEvent("my message123");
- $event = TestHelper::getWarnEvent("my message123");
+ for ($i = 0; $i < 1000; $i++) {
+ $appender->append($event);
+ }
- for($i = 0; $i < 1000; $i++) {
- $appender->append($event);
- }
+ $appender->append(TestHelper::getWarnEvent("my messageXYZ"));
- $appender->append(TestHelper::getWarnEvent("my messageXYZ"));
+ $appender->close();
- $appender->close();
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
+ $data = file($file);
+ $line = $data[count($data)-1];
+ $e = "WARN - my messageXYZ".PHP_EOL;
+ self::assertEquals($e, $line);
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
- $data = file($file);
- $line = $data[count($data)-1];
- $e = "WARN - my messageXYZ".PHP_EOL;
- self::assertEquals($e, $line);
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
+ $this->checkFileContent($file);
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
- $this->checkFileContent($file);
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
+ $this->checkFileContent($file);
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
- $this->checkFileContent($file);
+ // Should not roll over three times
+ $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'));
+ }
- // Should not roll over three times
- $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'));
- }
+ public function testLoggingViaLogger()
+ {
+ $logger = Logger::getLogger('mycat');
+ $logger->setAdditivity(false);
- public function testLoggingViaLogger() {
- $logger = Logger::getLogger('mycat');
- $logger->setAdditivity(false);
+ $appender = $this->createRolloverAppender();
- $appender = $this->createRolloverAppender();
+ $logger->addAppender($appender);
- $logger->addAppender($appender);
+ for ($i = 0; $i < 1000; $i++) {
+ $logger->warn("my message123");
+ }
- for($i = 0; $i < 1000; $i++) {
- $logger->warn("my message123");
- }
+ $logger->warn("my messageXYZ");
- $logger->warn("my messageXYZ");
+ $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt';
+ $data = file($file);
- $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt';
- $data = file($file);
+ $line = $data[count($data)-1];
+ $e = "WARN - my messageXYZ".PHP_EOL;
+ self::assertEquals($e, $line);
- $line = $data[count($data)-1];
- $e = "WARN - my messageXYZ".PHP_EOL;
- self::assertEquals($e, $line);
+ $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1';
+ $this->checkFileContent($file);
- $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1';
- $this->checkFileContent($file);
+ $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2';
+ $this->checkFileContent($file);
- $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2';
- $this->checkFileContent($file);
+ $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'), 'should not roll over three times');
+ }
- $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'), 'should not roll over three times');
- }
+ public function testRolloverWithCompression()
+ {
+ $logger = Logger::getLogger('mycat');
+ $logger->setAdditivity(false);
- public function testRolloverWithCompression() {
- $logger = Logger::getLogger('mycat');
- $logger->setAdditivity(false);
+ $appender = $this->createRolloverAppender();
+ $appender->setCompress(true);
- $appender = $this->createRolloverAppender();
- $appender->setCompress(true);
+ $logger->addAppender($appender);
- $logger->addAppender($appender);
+ for ($i = 0; $i < 1000; $i++) {
+ $logger->warn(self::WARNING_MASSAGE. $i);
+ }
- for($i = 0; $i < 1000; $i++) {
- $logger->warn(self::WARNING_MASSAGE. $i);
- }
+ $logger->warn("my messageXYZ");
- $logger->warn("my messageXYZ");
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
+ $data = file($file);
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
- $data = file($file);
+ $line = $data[count($data)-1];
+ $e = self::WARNING_MASSAGE.PHP_EOL;
+ self::assertEquals($e, $line);
- $line = $data[count($data)-1];
- $e = self::WARNING_MASSAGE.PHP_EOL;
- self::assertEquals($e, $line);
+ $firstCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1.gz';
+ $this->assertTrue(file_exists($firstCompressedRollingFile),'TEST-rolling.txt.1.gz not found');
- $firstCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1.gz';
- $this->assertTrue(file_exists($firstCompressedRollingFile),'TEST-rolling.txt.1.gz not found');
+ $firstUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
+ $this->assertFalse(file_exists($firstUncompressedRollingField),'TEST-rolling.txt.1 should be replaced by compressed');
- $firstUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
- $this->assertFalse(file_exists($firstUncompressedRollingField),'TEST-rolling.txt.1 should be replaced by compressed');
+ $secondCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2.gz';
+ $this->assertTrue(file_exists($secondCompressedRollingFile), 'TEST-rolling.txt.2.gz not found');
- $secondCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2.gz';
- $this->assertTrue(file_exists($secondCompressedRollingFile), 'TEST-rolling.txt.2.gz not found');
+ $secondUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
+ $this->assertFalse(file_exists($secondUncompressedRollingField),'TEST-rolling.txt.2 should be replaced by compressed');
- $secondUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
- $this->assertFalse(file_exists($secondUncompressedRollingField),'TEST-rolling.txt.2 should be replaced by compressed');
+ }
- }
+ private function checkFileContent($file)
+ {
+ $data = file($file);
+ $this->checkText($data);
+ }
- private function checkFileContent($file) {
- $data = file($file);
- $this->checkText($data);
- }
+ private function checkText($text)
+ {
+ $line = $text[count($text)-1];
+ $e = "WARN - my message123".PHP_EOL;
+ foreach ($text as $r) {
+ self::assertEquals($e, $r);
+ }
+ }
- private function checkText($text) {
- $line = $text[count($text)-1];
- $e = "WARN - my message123".PHP_EOL;
- foreach($text as $r) {
- self::assertEquals($e, $r);
- }
- }
-
- protected function tearDown() {
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1.gz');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2.gz');
- }
+ protected function tearDown()
+ {
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1.gz');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2.gz');
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/SocketAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/SocketAppenderTest.php b/tests/src/Appenders/SocketAppenderTest.php
index 9cd1482..27c9ef1 100644
--- a/tests/src/Appenders/SocketAppenderTest.php
+++ b/tests/src/Appenders/SocketAppenderTest.php
@@ -28,124 +28,132 @@ use Apache\Log4php\Logger;
/**
* @group appenders
*/
-class SocketAppenderTest extends \PHPUnit_Framework_TestCase {
-
- /** Port on which the socket server will run. */
- const SOCKET_PORT = 12345;
-
- /** The socket server process resource. */
- private $server;
-
- /** The pipes array for the server process. */
- private $pipes;
-
- public function setUp() {
- Logger::clear();
- }
-
- public function tearDown() {
- Logger::clear();
- }
-
- public function testRequiresLayout() {
- $appender = new SocketAppender();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testLogging()
- {
- Logger::configure(array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'SocketAppender',
- 'params' => array(
- 'remoteHost' => 'localhost',
- 'port' => self::SOCKET_PORT
- ),
- 'layout' => array(
- 'class' => 'SimpleLayout'
- )
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- ));
-
- $this->startServer();
-
- $logger = Logger::getLogger("myLogger");
- $logger->trace("This message is a test");
- $logger->debug("This message is a test");
- $logger->info("This message is a test");
- $logger->warn("This message is a test");
- $logger->error("This message is a test");
- $logger->fatal("This message is a test");
-
- $actual = $this->getPlayback();
- $this->stopServer();
-
- $expected = "DEBUG - This message is a test" .
- "INFO - This message is a test" .
- "WARN - This message is a test" .
- "ERROR - This message is a test" .
- "FATAL - This message is a test";
-
- $this->assertEquals($expected, $actual);
- }
-
- /** Starts a socket server in a separate process. */
- private function startServer() {
- $serverLog = PHPUNIT_TEMP_DIR . '/socketServer.log';
- $descriptorspec = array(
- 0 => array("pipe", "r"), // stdin
- 1 => array("file", $serverLog, "a"),// stdout
- 2 => array("file", $serverLog, "a") // stderr
- );
-
- $cmd = "php " . dirname(__FILE__) . '/socketServer.php';
- $this->server = proc_open($cmd, $descriptorspec, $this->pipes);
- if ($this->server === false) {
- throw new Exception("Failed starting the socket server process.");
- }
-
- // Sleep a bit to allow server to start
- usleep(200000);
-
- // Verify the server is running
- $status = proc_get_status($this->server);
- if (!$status['running']) {
- throw new Exception("Socket server process failed to start. Check the log at [$serverLog].");
- }
- }
-
- /** Sends a message to the socket server and returns the reply. */
- private function socketSend($msg) {
- $sock = fsockopen('localhost', self::SOCKET_PORT, $errno, $errstr);
- if ($sock === false) {
- throw new Exception("Unable to open socket. Error: [$errno] $errstr");
- }
-
- fputs($sock, "$msg\n");
- $reply = '';
- while(!feof($sock)) {
- $reply .= fgets($sock);
- }
- fclose($sock);
- return trim($reply);
- }
-
- /** Retrieves a playback of all sent messages from the socket server. */
- private function getPlayback() {
- return $this->socketSend('playback');
- }
-
- /** Stops the socket server and closes the process. */
- private function stopServer() {
- $this->socketSend('shutdown');
- foreach($this->pipes as $pipe) {
- fclose($pipe);
- }
- proc_close($this->server);
- }
+class SocketAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ /** Port on which the socket server will run. */
+ const SOCKET_PORT = 12345;
+
+ /** The socket server process resource. */
+ private $server;
+
+ /** The pipes array for the server process. */
+ private $pipes;
+
+ public function setUp()
+ {
+ Logger::clear();
+ }
+
+ public function tearDown()
+ {
+ Logger::clear();
+ }
+
+ public function testRequiresLayout()
+ {
+ $appender = new SocketAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testLogging()
+ {
+ Logger::configure(array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'SocketAppender',
+ 'params' => array(
+ 'remoteHost' => 'localhost',
+ 'port' => self::SOCKET_PORT
+ ),
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ ),
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ ));
+
+ $this->startServer();
+
+ $logger = Logger::getLogger("myLogger");
+ $logger->trace("This message is a test");
+ $logger->debug("This message is a test");
+ $logger->info("This message is a test");
+ $logger->warn("This message is a test");
+ $logger->error("This message is a test");
+ $logger->fatal("This message is a test");
+
+ $actual = $this->getPlayback();
+ $this->stopServer();
+
+ $expected = "DEBUG - This message is a test" .
+ "INFO - This message is a test" .
+ "WARN - This message is a test" .
+ "ERROR - This message is a test" .
+ "FATAL - This message is a test";
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /** Starts a socket server in a separate process. */
+ private function startServer()
+ {
+ $serverLog = PHPUNIT_TEMP_DIR . '/socketServer.log';
+ $descriptorspec = array(
+ 0 => array("pipe", "r"), // stdin
+ 1 => array("file", $serverLog, "a"),// stdout
+ 2 => array("file", $serverLog, "a") // stderr
+ );
+
+ $cmd = "php " . dirname(__FILE__) . '/socketServer.php';
+ $this->server = proc_open($cmd, $descriptorspec, $this->pipes);
+ if ($this->server === false) {
+ throw new Exception("Failed starting the socket server process.");
+ }
+
+ // Sleep a bit to allow server to start
+ usleep(200000);
+
+ // Verify the server is running
+ $status = proc_get_status($this->server);
+ if (!$status['running']) {
+ throw new Exception("Socket server process failed to start. Check the log at [$serverLog].");
+ }
+ }
+
+ /** Sends a message to the socket server and returns the reply. */
+ private function socketSend($msg)
+ {
+ $sock = fsockopen('localhost', self::SOCKET_PORT, $errno, $errstr);
+ if ($sock === false) {
+ throw new Exception("Unable to open socket. Error: [$errno] $errstr");
+ }
+
+ fputs($sock, "$msg\n");
+ $reply = '';
+ while (!feof($sock)) {
+ $reply .= fgets($sock);
+ }
+ fclose($sock);
+
+ return trim($reply);
+ }
+
+ /** Retrieves a playback of all sent messages from the socket server. */
+ private function getPlayback()
+ {
+ return $this->socketSend('playback');
+ }
+
+ /** Stops the socket server and closes the process. */
+ private function stopServer()
+ {
+ $this->socketSend('shutdown');
+ foreach ($this->pipes as $pipe) {
+ fclose($pipe);
+ }
+ proc_close($this->server);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/SyslogAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/SyslogAppenderTest.php b/tests/src/Appenders/SyslogAppenderTest.php
index 91b1568..0d13108 100644
--- a/tests/src/Appenders/SyslogAppenderTest.php
+++ b/tests/src/Appenders/SyslogAppenderTest.php
@@ -38,216 +38,224 @@ use Apache\Log4php\LoggingEvent;
*
* @group appenders
*/
-class SyslogAppenderTest extends \PHPUnit_Framework_TestCase {
-
- public function testSettersGetters() {
-
- // Setters should accept any value, without validation
- $expected = "Random string value";
-
- $appender = new SyslogAppender();
- $appender->setIdent($expected);
- $appender->setFacility($expected);
- $appender->setOverridePriority($expected);
- $appender->setPriority($expected);
- $appender->setOption($expected);
-
- $actuals = array(
- $appender->getIdent(),
- $appender->getFacility(),
- $appender->getOverridePriority(),
- $appender->getPriority(),
- $appender->getOption()
- );
-
- foreach($actuals as $actual) {
- $this->assertSame($expected, $actual);
- }
- }
-
- public function testRequiresLayout() {
- $appender = new SyslogAppender();
- $this->assertTrue($appender->requiresLayout());
- }
-
- public function testLogging() {
- $appender = new SyslogAppender("myname");
- $appender->setLayout(new SimpleLayout());
- $appender->activateOptions();
-
- $event = new LoggingEvent(__CLASS__, new Logger("TestLogger"), Level::getLevelError(), "testmessage");
- $appender->append($event);
- }
-
- /** Tests parsing of "option" parameter. */
- public function testOption() {
- $options = array(
- 'CONS' => LOG_CONS,
- 'NDELAY' => LOG_NDELAY,
- 'ODELAY' => LOG_ODELAY,
- 'PERROR' => LOG_PERROR,
- 'PID' => LOG_PID,
-
- // test some combinations
- 'CONS|NDELAY' => LOG_CONS | LOG_NDELAY,
- 'PID|PERROR' => LOG_PID | LOG_PERROR,
- 'CONS|PID|NDELAY' => LOG_CONS | LOG_PID | LOG_NDELAY
- );
-
- // Defaults
- $defaultStr = "PID|CONS";
- $default = LOG_PID | LOG_CONS;
-
- // This makes reading of a private property possible
- $property = new \ReflectionProperty('Apache\\Log4php\Appenders\\SyslogAppender', 'intOption');
- $property->setAccessible(true);
-
- // Check default value first
- $appender = new SyslogAppender();
- $appender->activateOptions();
- $actual = $property->getValue($appender);
- $this->assertSame($default, $actual, "Failed setting default option [$defaultStr]");
-
- foreach($options as $option => $expected) {
- $appender = new SyslogAppender();
- $appender->setOption($option);
- $appender->activateOptions();
-
- $actual = $property->getValue($appender);
- $this->assertSame($expected, $actual, "Failed setting option [$option].");
- }
- }
-
- /** Tests parsing of "priority" parameter. */
- public function testPriority() {
- $default = null;
- $defaultStr = 'null';
-
- $priorities = array(
- 'EMERG' => LOG_EMERG,
- 'ALERT' => LOG_ALERT,
- 'CRIT' => LOG_CRIT,
- 'ERR' => LOG_ERR,
- 'WARNING' => LOG_WARNING,
- 'NOTICE' => LOG_NOTICE,
- 'INFO' => LOG_INFO,
- 'DEBUG' => LOG_DEBUG
- );
-
- // This makes reading of a private property possible
- $property = new \ReflectionProperty('Apache\\Log4php\\Appenders\\SyslogAppender', 'intPriority');
- $property->setAccessible(true);
-
- // Check default value first
- $appender = new SyslogAppender();
- $appender->activateOptions();
- $actual = $property->getValue($appender);
- $this->assertSame($default, $actual, "Failed setting default priority [$defaultStr].");
-
- foreach($priorities as $priority => $expected) {
- $appender = new SyslogAppender();
- $appender->setPriority($priority);
- $appender->activateOptions();
-
- $actual = $property->getValue($appender);
- $this->assertSame($expected, $actual, "Failed setting priority [$priority].");
- }
- }
-
- /** Tests parsing of "facility" parameter. */
- public function testFacility() {
- // Default value is the same on all OSs
- $default = LOG_USER;
- $defaultStr = 'USER';
-
- // All possible facility strings (some of which might not exist depending on the OS)
- $strings = array(
- 'KERN', 'USER', 'MAIL', 'DAEMON', 'AUTH',
- 'SYSLOG', 'LPR', 'NEWS', 'UUCP', 'CRON', 'AUTHPRIV',
- 'LOCAL0', 'LOCAL1', 'LOCAL2', 'LOCAL3', 'LOCAL4',
- 'LOCAL5', 'LOCAL6', 'LOCAL7',
- );
-
- // Only test facilities which exist on this OS
- $facilities = array();
- foreach($strings as $string) {
- $const = "LOG_$string";
- if (defined($const)) {
- $facilities[$string] = constant($const);
- }
- }
-
- // This makes reading of a private property possible
- $property = new \ReflectionProperty('Apache\\Log4php\\Appenders\\SyslogAppender', 'intFacility');
- $property->setAccessible(true);
-
- // Check default value first
- $appender = new SyslogAppender();
- $appender->activateOptions();
- $actual = $property->getValue($appender);
- $this->assertSame($default, $default, "Failed setting default facility [$defaultStr].");
-
- foreach($facilities as $facility => $expected) {
- $appender = new SyslogAppender();
- $appender->setFacility($facility);
- $appender->activateOptions();
-
- $actual = $property->getValue($appender);
- $this->assertSame($expected, $actual, "Failed setting priority [$facility].");
- }
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- */
- public function testInvalidOption() {
- $appender = new SyslogAppender();
- $appender->setOption('CONS|XYZ');
- $appender->activateOptions();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- */
- public function testInvalidPriority() {
- $appender = new SyslogAppender();
- $appender->setPriority('XYZ');
- $appender->activateOptions();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- */
- public function testInvalidFacility() {
- $appender = new SyslogAppender();
- $appender->setFacility('XYZ');
- $appender->activateOptions();
- }
-
-
- public function testPriorityOverride() {
- $appender = new SyslogAppender();
- $appender->setPriority('EMERG');
- $appender->setOverridePriority(true);
- $appender->activateOptions();
-
- $levels = array(
- Level::getLevelTrace(),
- Level::getLevelDebug(),
- Level::getLevelInfo(),
- Level::getLevelWarn(),
- Level::getLevelError(),
- Level::getLevelFatal(),
- );
-
- $expected = LOG_EMERG;
-
- $method = new \ReflectionMethod('Apache\\Log4php\\Appenders\\SyslogAppender', 'getSyslogPriority');
- $method->setAccessible(true);
-
- foreach($levels as $level) {
- $actual = $method->invoke($appender, $level);
- $this->assertSame($expected, $actual);
- }
- }
+class SyslogAppenderTest extends \PHPUnit_Framework_TestCase
+{
+ public function testSettersGetters()
+ {
+ // Setters should accept any value, without validation
+ $expected = "Random string value";
+
+ $appender = new SyslogAppender();
+ $appender->setIdent($expected);
+ $appender->setFacility($expected);
+ $appender->setOverridePriority($expected);
+ $appender->setPriority($expected);
+ $appender->setOption($expected);
+
+ $actuals = array(
+ $appender->getIdent(),
+ $appender->getFacility(),
+ $appender->getOverridePriority(),
+ $appender->getPriority(),
+ $appender->getOption()
+ );
+
+ foreach ($actuals as $actual) {
+ $this->assertSame($expected, $actual);
+ }
+ }
+
+ public function testRequiresLayout()
+ {
+ $appender = new SyslogAppender();
+ $this->assertTrue($appender->requiresLayout());
+ }
+
+ public function testLogging()
+ {
+ $appender = new SyslogAppender("myname");
+ $appender->setLayout(new SimpleLayout());
+ $appender->activateOptions();
+
+ $event = new LoggingEvent(__CLASS__, new Logger("TestLogger"), Level::getLevelError(), "testmessage");
+ $appender->append($event);
+ }
+
+ /** Tests parsing of "option" parameter. */
+ public function testOption()
+ {
+ $options = array(
+ 'CONS' => LOG_CONS,
+ 'NDELAY' => LOG_NDELAY,
+ 'ODELAY' => LOG_ODELAY,
+ 'PERROR' => LOG_PERROR,
+ 'PID' => LOG_PID,
+
+ // test some combinations
+ 'CONS|NDELAY' => LOG_CONS | LOG_NDELAY,
+ 'PID|PERROR' => LOG_PID | LOG_PERROR,
+ 'CONS|PID|NDELAY' => LOG_CONS | LOG_PID | LOG_NDELAY
+ );
+
+ // Defaults
+ $defaultStr = "PID|CONS";
+ $default = LOG_PID | LOG_CONS;
+
+ // This makes reading of a private property possible
+ $property = new \ReflectionProperty('Apache\\Log4php\Appenders\\SyslogAppender', 'intOption');
+ $property->setAccessible(true);
+
+ // Check default value first
+ $appender = new SyslogAppender();
+ $appender->activateOptions();
+ $actual = $property->getValue($appender);
+ $this->assertSame($default, $actual, "Failed setting default option [$defaultStr]");
+
+ foreach ($options as $option => $expected) {
+ $appender = new SyslogAppender();
+ $appender->setOption($option);
+ $appender->activateOptions();
+
+ $actual = $property->getValue($appender);
+ $this->assertSame($expected, $actual, "Failed setting option [$option].");
+ }
+ }
+
+ /** Tests parsing of "priority" parameter. */
+ public function testPriority()
+ {
+ $default = null;
+ $defaultStr = 'null';
+
+ $priorities = array(
+ 'EMERG' => LOG_EMERG,
+ 'ALERT' => LOG_ALERT,
+ 'CRIT' => LOG_CRIT,
+ 'ERR' => LOG_ERR,
+ 'WARNING' => LOG_WARNING,
+ 'NOTICE' => LOG_NOTICE,
+ 'INFO' => LOG_INFO,
+ 'DEBUG' => LOG_DEBUG
+ );
+
+ // This makes reading of a private property possible
+ $property = new \ReflectionProperty('Apache\\Log4php\\Appenders\\SyslogAppender', 'intPriority');
+ $property->setAccessible(true);
+
+ // Check default value first
+ $appender = new SyslogAppender();
+ $appender->activateOptions();
+ $actual = $property->getValue($appender);
+ $this->assertSame($default, $actual, "Failed setting default priority [$defaultStr].");
+
+ foreach ($priorities as $priority => $expected) {
+ $appender = new SyslogAppender();
+ $appender->setPriority($priority);
+ $appender->activateOptions();
+
+ $actual = $property->getValue($appender);
+ $this->assertSame($expected, $actual, "Failed setting priority [$priority].");
+ }
+ }
+
+ /** Tests parsing of "facility" parameter. */
+ public function testFacility()
+ {
+ // Default value is the same on all OSs
+ $default = LOG_USER;
+ $defaultStr = 'USER';
+
+ // All possible facility strings (some of which might not exist depending on the OS)
+ $strings = array(
+ 'KERN', 'USER', 'MAIL', 'DAEMON', 'AUTH',
+ 'SYSLOG', 'LPR', 'NEWS', 'UUCP', 'CRON', 'AUTHPRIV',
+ 'LOCAL0', 'LOCAL1', 'LOCAL2', 'LOCAL3', 'LOCAL4',
+ 'LOCAL5', 'LOCAL6', 'LOCAL7',
+ );
+
+ // Only test facilities which exist on this OS
+ $facilities = array();
+ foreach ($strings as $string) {
+ $const = "LOG_$string";
+ if (defined($const)) {
+ $facilities[$string] = constant($const);
+ }
+ }
+
+ // This makes reading of a private property possible
+ $property = new \ReflectionProperty('Apache\\Log4php\\Appenders\\SyslogAppender', 'intFacility');
+ $property->setAccessible(true);
+
+ // Check default value first
+ $appender = new SyslogAppender();
+ $appender->activateOptions();
+ $actual = $property->getValue($appender);
+ $this->assertSame($default, $default, "Failed setting default facility [$defaultStr].");
+
+ foreach ($facilities as $facility => $expected) {
+ $appender = new SyslogAppender();
+ $appender->setFacility($facility);
+ $appender->activateOptions();
+
+ $actual = $property->getValue($appender);
+ $this->assertSame($expected, $actual, "Failed setting priority [$facility].");
+ }
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testInvalidOption()
+ {
+ $appender = new SyslogAppender();
+ $appender->setOption('CONS|XYZ');
+ $appender->activateOptions();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testInvalidPriority()
+ {
+ $appender = new SyslogAppender();
+ $appender->setPriority('XYZ');
+ $appender->activateOptions();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testInvalidFacility()
+ {
+ $appender = new SyslogAppender();
+ $appender->setFacility('XYZ');
+ $appender->activateOptions();
+ }
+
+ public function testPriorityOverride()
+ {
+ $appender = new SyslogAppender();
+ $appender->setPriority('EMERG');
+ $appender->setOverridePriority(true);
+ $appender->activateOptions();
+
+ $levels = array(
+ Level::getLevelTrace(),
+ Level::getLevelDebug(),
+ Level::getLevelInfo(),
+ Level::getLevelWarn(),
+ Level::getLevelError(),
+ Level::getLevelFatal(),
+ );
+
+ $expected = LOG_EMERG;
+
+ $method = new \ReflectionMethod('Apache\\Log4php\\Appenders\\SyslogAppender', 'getSyslogPriority');
+ $method->setAccessible(true);
+
+ foreach ($levels as $level) {
+ $actual = $method->invoke($appender, $level);
+ $this->assertSame($expected, $actual);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Appenders/socketServer.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/socketServer.php b/tests/src/Appenders/socketServer.php
index 19a7b7c..07c464e 100644
--- a/tests/src/Appenders/socketServer.php
+++ b/tests/src/Appenders/socketServer.php
@@ -32,19 +32,19 @@ set_time_limit(0);
// Create a socket
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($sock === false) {
- die("Failed creating socket: " . socket_strerror(socket_last_error()));
+ die("Failed creating socket: " . socket_strerror(socket_last_error()));
}
if (socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1) === false) {
- die("Failed setting socket options: " . socket_strerror(socket_last_error()));
+ die("Failed setting socket options: " . socket_strerror(socket_last_error()));
}
if (socket_bind($sock, 'localhost', SERVER_PORT) === false) {
- die("Failed binding socket: " . socket_strerror(socket_last_error()));
+ die("Failed binding socket: " . socket_strerror(socket_last_error()));
}
if (socket_listen($sock, 100) === false) {
- die("Failed binding socket: " . socket_strerror(socket_last_error()));
+ die("Failed binding socket: " . socket_strerror(socket_last_error()));
}
socket_getsockname($sock, $addr, $port);
@@ -53,43 +53,42 @@ myLog("Server Listening on $addr:$port");
// Buffer which will store incoming messages
$playback = "";
-while(true) {
- myLog("Waiting for incoming connections...");
-
- $msgsock = socket_accept($sock);
- if ($msgsock === false) {
- myLog("Failed accepting a connection: " . socket_strerror(socket_last_error()));
- break;
- }
-
- $buf = socket_read($msgsock, 2048, PHP_NORMAL_READ);
-
- myLog('Received: "' . trim($buf) . '"');
-
- // Shutdown command
- if (trim($buf) == 'shutdown') {
- myLog("Shutting down.");
- socket_close($msgsock);
- break;
- }
- // Playback command
- else if (trim($buf) == 'playback') {
- myLog("Returning playback: \"$playback\"");
- socket_write($msgsock, $playback);
- }
- // Default: add to playback buffer
- else {
- $playback .= trim($buf);
- }
-
- socket_close($msgsock);
+while (true) {
+ myLog("Waiting for incoming connections...");
+
+ $msgsock = socket_accept($sock);
+ if ($msgsock === false) {
+ myLog("Failed accepting a connection: " . socket_strerror(socket_last_error()));
+ break;
+ }
+
+ $buf = socket_read($msgsock, 2048, PHP_NORMAL_READ);
+
+ myLog('Received: "' . trim($buf) . '"');
+
+ // Shutdown command
+ if (trim($buf) == 'shutdown') {
+ myLog("Shutting down.");
+ socket_close($msgsock);
+ break;
+ }
+ // Playback command
+ else if (trim($buf) == 'playback') {
+ myLog("Returning playback: \"$playback\"");
+ socket_write($msgsock, $playback);
+ }
+ // Default: add to playback buffer
+ else {
+ $playback .= trim($buf);
+ }
+
+ socket_close($msgsock);
}
myLog("Closing socket.");
socket_close($sock);
-function myLog($msg) {
- echo date("Y-m-d H:i:s") . " $msg\n";
+function myLog($msg)
+{
+ echo date("Y-m-d H:i:s") . " $msg\n";
}
-
-?>
[42/43] git commit: Style fixes to make code conform to PSR-2 better
Posted by ih...@apache.org.
Style fixes to make code conform to PSR-2 better
Also wrapped lines to 120 chars, since it's a sane value, and phpcs
produces a warning for longer lines.
Made some errors less verbose to acomplish this.
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/378ce1a3
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/378ce1a3
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/378ce1a3
Branch: refs/heads/v3
Commit: 378ce1a3828440df364860f0da96403e1f7de0c9
Parents: b178d46
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 16:53:20 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 16:53:20 2013 +0100
----------------------------------------------------------------------
src/AppenderPool.php | 5 +-
src/Appenders/AbstractAppender.php | 10 ++--
src/Appenders/ConsoleAppender.php | 4 +-
src/Appenders/DailyFileAppender.php | 8 +--
src/Appenders/MailAppender.php | 6 +-
src/Appenders/MailEventAppender.php | 15 +++--
src/Appenders/MongoDBAppender.php | 8 ++-
src/Appenders/PdoAppender.php | 8 ++-
src/Appenders/RollingFileAppender.php | 12 ++--
src/Appenders/SyslogAppender.php | 5 +-
src/Configurable.php | 40 ++++++++++---
src/Configuration/DefaultConfigurator.php | 60 +++++++++++++-------
src/Configuration/adapters/AdapterInterface.php | 1 -
src/Configuration/adapters/IniAdapter.php | 39 +++++--------
src/Filters/AbstractFilter.php | 3 +-
src/Filters/StringMatchFilter.php | 2 +-
src/Helpers/OptionConverter.php | 30 +++++++---
src/Helpers/PatternParser.php | 5 +-
src/Layouts/HtmlLayout.php | 9 ++-
src/Layouts/XmlLayout.php | 11 ++--
src/Level.php | 55 +++++++++++-------
src/LocationInfo.php | 1 -
src/Logger.php | 24 ++++++--
src/LoggingEvent.php | 11 ++--
src/Pattern/AbstractConverter.php | 22 +++----
src/Pattern/ClassConverter.php | 8 +--
src/Pattern/LoggerConverter.php | 8 +--
src/Pattern/SuperglobalConverter.php | 8 +--
src/ReflectionUtils.php | 7 ++-
src/Renderers/RendererMap.php | 22 +++++--
tests/src/ConfiguratorTest.php | 2 +-
tests/src/Configurators/INIAdapterTest.php | 4 +-
tests/src/Renderers/RendererMapTest.php | 4 +-
33 files changed, 285 insertions(+), 172 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/AppenderPool.php
----------------------------------------------------------------------
diff --git a/src/AppenderPool.php b/src/AppenderPool.php
index abcb698..98034bb 100644
--- a/src/AppenderPool.php
+++ b/src/AppenderPool.php
@@ -52,7 +52,10 @@ class AppenderPool
}
if (isset(self::$appenders[$name])) {
- trigger_error("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Appender [$name] already exists in pool. Overwriting existing appender.",
+ E_USER_WARNING
+ );
}
self::$appenders[$name] = $appender;
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/AbstractAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/AbstractAppender.php b/src/Appenders/AbstractAppender.php
index e772b21..8a76d64 100644
--- a/src/Appenders/AbstractAppender.php
+++ b/src/Appenders/AbstractAppender.php
@@ -163,9 +163,12 @@ abstract class AbstractAppender extends Configurable
$filter = $this->getFirstFilter();
while ($filter !== null) {
switch ($filter->decide($event)) {
- case AbstractFilter::DENY: return;
- case AbstractFilter::ACCEPT: return $this->append($event);
- case AbstractFilter::NEUTRAL: $filter = $filter->getNext();
+ case AbstractFilter::DENY:
+ return;
+ case AbstractFilter::ACCEPT:
+ return $this->append($event);
+ case AbstractFilter::NEUTRAL:
+ $filter = $filter->getNext();
}
}
$this->append($event);
@@ -307,5 +310,4 @@ abstract class AbstractAppender extends Configurable
$id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
trigger_error("log4php: [$id]: $message", E_USER_WARNING);
}
-
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/ConsoleAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/ConsoleAppender.php b/src/Appenders/ConsoleAppender.php
index d32fd9e..13e89af 100644
--- a/src/Appenders/ConsoleAppender.php
+++ b/src/Appenders/ConsoleAppender.php
@@ -35,8 +35,8 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/console.html Appender documentation
*/
- class ConsoleAppender extends AbstractAppender
- {
+class ConsoleAppender extends AbstractAppender
+{
/** The standard otuput stream. */
const STDOUT = 'php://stdout';
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/DailyFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/DailyFileAppender.php b/src/Appenders/DailyFileAppender.php
index 3464246..81541b0 100644
--- a/src/Appenders/DailyFileAppender.php
+++ b/src/Appenders/DailyFileAppender.php
@@ -80,13 +80,11 @@ class DailyFileAppender extends FileAppender
{
$eventDate = $this->getDate($event->getTimestamp());
- // Initial setting of current date
if (!isset($this->currentDate)) {
+ // Initial setting of current date
$this->currentDate = $eventDate;
- }
-
- // Check if rollover is needed
- else if ($this->currentDate !== $eventDate) {
+ } elseif ($this->currentDate !== $eventDate) {
+ // Check if rollover is needed
$this->currentDate = $eventDate;
// Close the file if it's open.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/MailAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MailAppender.php b/src/Appenders/MailAppender.php
index d34dce1..916ba45 100644
--- a/src/Appenders/MailAppender.php
+++ b/src/Appenders/MailAppender.php
@@ -90,9 +90,11 @@ class MailAppender extends AbstractAppender
$subject = $this->subject;
if (!$this->dry) {
mail(
- $to, $subject,
+ $to,
+ $subject,
$this->layout->getHeader() . $this->body . $this->layout->getFooter(),
- "From: {$from}\r\n");
+ "From: {$from}\r\n"
+ );
} else {
echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/MailEventAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MailEventAppender.php b/src/Appenders/MailEventAppender.php
index 6a0ff70..291642c 100644
--- a/src/Appenders/MailEventAppender.php
+++ b/src/Appenders/MailEventAppender.php
@@ -118,9 +118,16 @@ class MailEventAppender extends AbstractAppender
$addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
if (!$this->dry) {
- $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
+ $result = mail(
+ $this->to,
+ $this->subject,
+ $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event),
+ $addHeader
+ );
} else {
- echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
+ echo "DRY MODE OF MAIL APP.: Send mail to: " . $this->to .
+ " with additional headers '" . trim($addHeader) .
+ "' and content: " . $this->layout->format($event);
}
ini_set('SMTP', $prevSmtpHost);
@@ -166,7 +173,7 @@ class MailEventAppender extends AbstractAppender
/** Sets the 'subject' parameter. */
public function setSubject($subject)
{
- $this->setString('subject', $subject);
+ $this->setString('subject', $subject);
}
/** Returns the 'subject' parameter. */
@@ -178,7 +185,7 @@ class MailEventAppender extends AbstractAppender
/** Sets the 'to' parameter. */
public function setTo($to)
{
- $this->setString('to', $to);
+ $this->setString('to', $to);
}
/** Returns the 'to' parameter. */
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/MongoDBAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MongoDBAppender.php b/src/Appenders/MongoDBAppender.php
index 0ff180b..c07e6b8 100644
--- a/src/Appenders/MongoDBAppender.php
+++ b/src/Appenders/MongoDBAppender.php
@@ -130,7 +130,10 @@ class MongoDBAppender extends AbstractAppender
public function activateOptions()
{
try {
- $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
+ $this->connection = new Mongo(
+ sprintf('%s:%d', $this->host, $this->port),
+ array('timeout' => $this->timeout)
+ );
$db = $this->connection->selectDB($this->databaseName);
if ($this->userName !== null && $this->password !== null) {
$authResult = $db->authenticate($this->userName, $this->password);
@@ -190,7 +193,8 @@ class MongoDBAppender extends AbstractAppender
if ($locationInfo != null) {
$document['fileName'] = $locationInfo->getFileName();
$document['method'] = $locationInfo->getMethodName();
- $document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
+ $document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ?
+ 'NA' : (int) $locationInfo->getLineNumber();
$document['className'] = $locationInfo->getClassName();
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/PdoAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/PdoAppender.php b/src/Appenders/PdoAppender.php
index 431b9d6..81ef3ad 100644
--- a/src/Appenders/PdoAppender.php
+++ b/src/Appenders/PdoAppender.php
@@ -71,7 +71,8 @@ class PdoAppender extends AbstractAppender
* The questionmarks are part of the prepared statement, and they must
* match the number of conversion specifiers in {@link insertPattern}.
*/
- protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
+ protected $insertSQL =
+ "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
/**
* A comma separated list of {@link LoggerPatternLayout} format strings
@@ -177,7 +178,10 @@ class PdoAppender extends AbstractAppender
// Close the appender if it's the last attempt
if ($attempt > $this->reconnectAttempts) {
- $this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
+ $this->warn(
+ "Failed writing to database after {$this->reconnectAttempts} reconnect attempts. " .
+ "Closing appender."
+ );
$this->close();
// Otherwise reconnect and try to write again
} else {
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/RollingFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/RollingFileAppender.php b/src/Appenders/RollingFileAppender.php
index 8e7024b..35af51a 100644
--- a/src/Appenders/RollingFileAppender.php
+++ b/src/Appenders/RollingFileAppender.php
@@ -104,12 +104,16 @@ class RollingFileAppender extends FileAppender
/**
* Implements the usual roll over behaviour.
*
- * If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
- * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
+ * If MaxBackupIndex is positive, then files File.1, ...,
+ * File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
+ * Moreover, File is renamed File.1 and closed. A new File is created to
+ * receive further log output.
*
- * If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
+ * If MaxBackupIndex is equal to zero, then the File is truncated with no
+ * backup files created.
*
- * Rollover must be called while the file is locked so that it is safe for concurrent access.
+ * Rollover must be called while the file is locked so that it is safe for
+ * concurrent access.
*
* @throws LoggerException If any part of the rollover procedure fails.
*/
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Appenders/SyslogAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/SyslogAppender.php b/src/Appenders/SyslogAppender.php
index b6fc0c0..8bb8904 100644
--- a/src/Appenders/SyslogAppender.php
+++ b/src/Appenders/SyslogAppender.php
@@ -286,7 +286,10 @@ class SyslogAppender extends AbstractAppender
if (defined($constant)) {
$value |= constant($constant);
} else {
- trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.",
+ E_USER_WARNING
+ );
}
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Configurable.php
----------------------------------------------------------------------
diff --git a/src/Configurable.php b/src/Configurable.php
index 6964408..246b105 100644
--- a/src/Configurable.php
+++ b/src/Configurable.php
@@ -39,7 +39,10 @@ abstract class Configurable
$this->$property = OptionConverter::toBooleanEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. " .
+ "Expected a boolean value. Property not changed."
+ );
}
}
@@ -50,7 +53,10 @@ abstract class Configurable
$this->$property = OptionConverter::toIntegerEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. Expected an integer. " .
+ "Property not changed."
+ );
}
}
@@ -61,7 +67,10 @@ abstract class Configurable
$this->$property = OptionConverter::toLevelEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. Expected a level value. " .
+ "Property not changed."
+ );
}
}
@@ -72,7 +81,10 @@ abstract class Configurable
$this->$property = OptionConverter::toPositiveIntegerEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. Expected a positive integer. " .
+ "Property not changed."
+ );
}
}
@@ -83,7 +95,10 @@ abstract class Configurable
$this->$property = OptionConverter::toFileSizeEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. Expected a file size value. " .
+ "Property not changed."
+ );
}
}
@@ -94,7 +109,10 @@ abstract class Configurable
$this->$property = OptionConverter::toNumericEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. Expected a number. " .
+ "Property not changed."
+ );
}
}
@@ -105,7 +123,10 @@ abstract class Configurable
if ($nullable) {
$this->$property= null;
} else {
- $this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
+ $this->warn(
+ "Null value given for '$property' property. Expected a string. " .
+ "Property not changed."
+ );
}
} else {
try {
@@ -113,7 +134,10 @@ abstract class Configurable
$this->$property = OptionConverter::substConstants($value);
} catch (Exception $ex) {
$value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
+ $this->warn(
+ "Invalid value given for '$property' property: [$value]. Expected a string. " .
+ "Property not changed."
+ );
}
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Configuration/DefaultConfigurator.php
----------------------------------------------------------------------
diff --git a/src/Configuration/DefaultConfigurator.php b/src/Configuration/DefaultConfigurator.php
index 7ef223b..7dd8dde 100644
--- a/src/Configuration/DefaultConfigurator.php
+++ b/src/Configuration/DefaultConfigurator.php
@@ -106,28 +106,22 @@ class DefaultConfigurator implements ConfiguratorInterface
*/
public function parse($input)
{
- // No input - use default configuration
if (!isset($input)) {
+ // No input - use default configuration
$config = self::$defaultConfiguration;
- }
-
- // Array input - contains configuration within the array
- else if (is_array($input)) {
+ } elseif (is_array($input)) {
+ // Array input - contains configuration within the array
$config = $input;
- }
-
- // String input - contains path to configuration file
- else if (is_string($input)) {
+ } elseif (is_string($input)) {
+ // String input - contains path to configuration file
try {
$config = $this->parseFile($input);
} catch (LoggerException $e) {
$this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
$config = self::$defaultConfiguration;
}
- }
-
- // Anything else is an error
- else {
+ } else {
+ // Anything else is an error
$this->warn("Invalid configuration param given. Reverting to default configuration.");
$config = self::$defaultConfiguration;
}
@@ -203,7 +197,10 @@ class DefaultConfigurator implements ConfiguratorInterface
if (isset($threshold)) {
$hierarchy->setThreshold($threshold);
} else {
- $this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
+ $this->warn(
+ "Invalid threshold value [{$config['threshold']}] specified. " .
+ "Ignoring threshold definition."
+ );
}
}
@@ -279,7 +276,10 @@ class DefaultConfigurator implements ConfiguratorInterface
// TODO: add this check to other places where it might be useful
if (!is_array($config)) {
$type = gettype($config);
- $this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
+ $this->warn(
+ "Invalid configuration provided for appender [$name]. Expected an array, found <$type>. " .
+ "Skipping appender definition."
+ );
return;
}
@@ -304,13 +304,19 @@ class DefaultConfigurator implements ConfiguratorInterface
}
if (!isset($appender)) {
- $this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
+ $this->warn(
+ "Invalid class [$class] given for appender [$name]. Class does not exist. " .
+ "Skipping appender definition."
+ );
return;
}
if (!($appender instanceof AbstractAppender)) {
- $this->warn("Invalid class [$class] given for appender [$name]. Not a valid Appender class. Skipping appender definition.");
+ $this->warn(
+ "Invalid class [$class] given for appender [$name]. Not a valid Appender class. " .
+ "Skipping appender definition."
+ );
return;
}
@@ -321,7 +327,10 @@ class DefaultConfigurator implements ConfiguratorInterface
if ($threshold instanceof Level) {
$appender->setThreshold($threshold);
} else {
- $this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
+ $this->warn(
+ "Invalid threshold value [{$config['threshold']}] specified for appender [$name]. " .
+ "Ignoring threshold definition."
+ );
}
}
@@ -372,7 +381,10 @@ class DefaultConfigurator implements ConfiguratorInterface
}
if (!isset($layout)) {
- $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
+ $this->warn(
+ "Nonexistant layout class [$class] specified for appender [$name]. " .
+ "Reverting to default layout."
+ );
return;
}
@@ -468,7 +480,10 @@ class DefaultConfigurator implements ConfiguratorInterface
if (isset($level)) {
$logger->setLevel($level);
} else {
- $this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
+ $this->warn(
+ "Invalid level value [{$config['level']}] specified for logger [$loggerName]. " .
+ "Ignoring level definition."
+ );
}
}
@@ -489,7 +504,10 @@ class DefaultConfigurator implements ConfiguratorInterface
$additivity = OptionConverter::toBooleanEx($config['additivity'], null);
$logger->setAdditivity($additivity);
} catch (LoggerException $ex) {
- $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
+ $this->warn(
+ "Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. " .
+ "Ignoring additivity setting."
+ );
}
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Configuration/adapters/AdapterInterface.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/AdapterInterface.php b/src/Configuration/adapters/AdapterInterface.php
index 15b565a..871bb9d 100644
--- a/src/Configuration/adapters/AdapterInterface.php
+++ b/src/Configuration/adapters/AdapterInterface.php
@@ -31,5 +31,4 @@ interface AdapterInterface
{
/** Converts the configuration file to PHP format usable by the configurator. */
public function convert($input);
-
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Configuration/adapters/IniAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/IniAdapter.php b/src/Configuration/adapters/IniAdapter.php
index 93a71d4..6110a10 100644
--- a/src/Configuration/adapters/IniAdapter.php
+++ b/src/Configuration/adapters/IniAdapter.php
@@ -99,25 +99,20 @@ class IniAdapter implements AdapterInterface
$appenders = array();
foreach ($properties as $key => $value) {
- // Parse loggers
+
if ($this->beginsWith($key, self::LOGGER_PREFIX)) {
+ // Parse loggers
$name = substr($key, strlen(self::LOGGER_PREFIX));
$this->parseLogger($value, $name);
- }
-
- // Parse additivity
- if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) {
+ } elseif ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) {
+ // Parse additivity
$name = substr($key, strlen(self::ADDITIVITY_PREFIX));
$this->config['loggers'][$name]['additivity'] = $value;
- }
-
- // Parse appenders
- else if ($this->beginsWith($key, self::APPENDER_PREFIX)) {
+ } elseif ($this->beginsWith($key, self::APPENDER_PREFIX)) {
+ // Parse appenders
$this->parseAppender($key, $value);
- }
-
- // Parse renderers
- else if ($this->beginsWith($key, self::RENDERER_PREFIX)) {
+ } elseif ($this->beginsWith($key, self::RENDERER_PREFIX)) {
+ // Parse renderers
$this->parseRenderer($key, $value);
}
}
@@ -238,16 +233,12 @@ class IniAdapter implements AdapterInterface
// The first part is always the appender name
$name = trim($parts[0]);
- // Only one part - this line defines the appender class
if ($count == 1) {
+ // Only one part - this line defines the appender class
$this->config['appenders'][$name]['class'] = $value;
-
return;
- }
-
- // Two parts - either a parameter, a threshold or layout class
- else if ($count == 2) {
-
+ } elseif ($count == 2) {
+ // Two parts - either a parameter, a threshold or layout class
if ($parts[1] == 'layout') {
$this->config['appenders'][$name]['layout']['class'] = $value;
@@ -261,10 +252,8 @@ class IniAdapter implements AdapterInterface
return;
}
- }
-
- // Three parts - this can only be a layout parameter
- else if ($count == 3) {
+ } elseif ($count == 3) {
+ // Three parts - this can only be a layout parameter
if ($parts[1] == 'layout') {
$this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
@@ -272,7 +261,7 @@ class IniAdapter implements AdapterInterface
}
}
- trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.", E_USER_WARNING);
+ trigger_error("log4php: Don't know how to parse line: \"$key = $value\". Skipping.", E_USER_WARNING);
}
/**
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Filters/AbstractFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/AbstractFilter.php b/src/Filters/AbstractFilter.php
index bdc167a..7f15e34 100644
--- a/src/Filters/AbstractFilter.php
+++ b/src/Filters/AbstractFilter.php
@@ -97,7 +97,7 @@ abstract class AbstractFilter extends Configurable
* the chain.
*
* @param LoggingEvent $event The {@link LoggingEvent} to decide upon.
- * @return integer {@link AbstractFilter::NEUTRAL} or {@link AbstractFilter::DENY}|{@link AbstractFilter::ACCEPT}
+ * @return integer {@link AbstractFilter::NEUTRAL} or {@link AbstractFilter::DENY} or {@link AbstractFilter::ACCEPT}
*/
public function decide(LoggingEvent $event)
{
@@ -128,5 +128,4 @@ abstract class AbstractFilter extends Configurable
{
return $this->next;
}
-
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Filters/StringMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/StringMatchFilter.php b/src/Filters/StringMatchFilter.php
index 5582317..f77976a 100644
--- a/src/Filters/StringMatchFilter.php
+++ b/src/Filters/StringMatchFilter.php
@@ -84,7 +84,7 @@ class StringMatchFilter extends AbstractFilter
return AbstractFilter::NEUTRAL;
}
- if (strpos($msg, $this->stringToMatch) !== false ) {
+ if (strpos($msg, $this->stringToMatch) !== false) {
return ($this->acceptOnMatch) ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Helpers/OptionConverter.php
----------------------------------------------------------------------
diff --git a/src/Helpers/OptionConverter.php b/src/Helpers/OptionConverter.php
index 868bed6..2888cb9 100644
--- a/src/Helpers/OptionConverter.php
+++ b/src/Helpers/OptionConverter.php
@@ -83,7 +83,8 @@ class OptionConverter
}
}
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
+ $value = var_export($value, true);
+ throw new LoggerException("Given value [$value] cannot be converted to boolean.");
}
/**
@@ -99,7 +100,8 @@ class OptionConverter
return (integer) $value;
}
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
+ $value = var_export($value, true);
+ throw new LoggerException("Given value [$value] cannot be converted to integer.");
}
/**
@@ -115,7 +117,8 @@ class OptionConverter
return (integer) $value;
}
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
+ $value = var_export($value, true);
+ throw new LoggerException("Given value [$value] cannot be converted to a positive integer.");
}
/** Converts the value to a level. Throws an exception if not possible. */
@@ -126,7 +129,8 @@ class OptionConverter
}
$level = Level::toLevel($value);
if ($level === null) {
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
+ $value = var_export($value, true);
+ throw new LoggerException("Given value [$value] cannot be converted to a logger level.");
}
return $level;
@@ -159,7 +163,8 @@ class OptionConverter
}
if (!is_string($value)) {
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
+ $value = var_export($value, true);
+ throw new LoggerException("Given value [$value] cannot be converted to a file size.");
}
$str = strtoupper(trim($value));
@@ -170,9 +175,15 @@ class OptionConverter
$unit = $matches[2];
switch ($unit) {
- case 'KB': $size *= pow(1024, 1); break;
- case 'MB': $size *= pow(1024, 2); break;
- case 'GB': $size *= pow(1024, 3); break;
+ case 'KB':
+ $size *= pow(1024, 1);
+ break;
+ case 'MB':
+ $size *= pow(1024, 2);
+ break;
+ case 'GB':
+ $size *= pow(1024, 3);
+ break;
}
return (integer) $size;
@@ -200,7 +211,8 @@ class OptionConverter
return (string) $value;
}
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
+ $value = var_export($value, true);
+ throw new LoggerException("Given value [$value] cannot be converted to string.");
}
/**
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Helpers/PatternParser.php
----------------------------------------------------------------------
diff --git a/src/Helpers/PatternParser.php b/src/Helpers/PatternParser.php
index 1d9b014..067acd6 100644
--- a/src/Helpers/PatternParser.php
+++ b/src/Helpers/PatternParser.php
@@ -230,7 +230,10 @@ class PatternParser
// Validate
$pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
if (!preg_match($pattern, $modifiers)) {
- trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.",
+ E_USER_WARNING
+ );
return $info;
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Layouts/HtmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/HtmlLayout.php b/src/Layouts/HtmlLayout.php
index be414d8..e14f5ac 100644
--- a/src/Layouts/HtmlLayout.php
+++ b/src/Layouts/HtmlLayout.php
@@ -152,7 +152,8 @@ class HtmlLayout extends AbstractLayout
$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 .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" ";
+ $sbuf .= "colspan=\"6\" title=\"Nested Diagnostic Context\">";
$sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
$sbuf .= "</td></tr>" . PHP_EOL;
}
@@ -165,7 +166,8 @@ class HtmlLayout extends AbstractLayout
*/
public function getHeader()
{
- $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
+ $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" ";
+ $sbuf .= "\"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
$sbuf .= "<html>" . PHP_EOL;
$sbuf .= "<head>" . PHP_EOL;
$sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
@@ -180,7 +182,8 @@ class HtmlLayout extends AbstractLayout
$sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
$sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
$sbuf .= "<br>" . PHP_EOL;
- $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
+ $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" ";
+ $sbuf .= "bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
$sbuf .= "<tr>" . PHP_EOL;
$sbuf .= "<th>Time</th>" . PHP_EOL;
$sbuf .= "<th>Thread</th>" . PHP_EOL;
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Layouts/XmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/XmlLayout.php b/src/Layouts/XmlLayout.php
index 9a503f8..191b9e8 100644
--- a/src/Layouts/XmlLayout.php
+++ b/src/Layouts/XmlLayout.php
@@ -107,7 +107,8 @@ class XmlLayout extends AbstractLayout
$thread = $event->getThreadName();
$level = $event->getLevel()->toString();
- $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
+ $buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" ";
+ $buf .= "timestamp=\"{$timeStamp}\">" . PHP_EOL;
$buf .= "<$ns:message>";
$buf .= $this->encodeCDATA($event->getRenderedMessage());
$buf .= "</$ns:message>".PHP_EOL;
@@ -122,7 +123,7 @@ class XmlLayout extends AbstractLayout
$mdcMap = $event->getMDCMap();
if (!empty($mdcMap)) {
$buf .= "<$ns:properties>".PHP_EOL;
- foreach ($mdcMap as $name=>$value) {
+ foreach ($mdcMap as $name => $value) {
$buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
}
$buf .= "</$ns:properties>".PHP_EOL;
@@ -175,10 +176,10 @@ class XmlLayout extends AbstractLayout
/**
* @return boolean
*/
- public function getLog4jNamespace()
- {
+ public function getLog4jNamespace()
+ {
return $this->log4jNamespace;
- }
+ }
/**
* @param boolean
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Level.php
----------------------------------------------------------------------
diff --git a/src/Level.php b/src/Level.php
index 0f7ce46..f13dcf9 100644
--- a/src/Level.php
+++ b/src/Level.php
@@ -252,29 +252,44 @@ class Level
public static function toLevel($arg, $defaultLevel = null)
{
if (is_int($arg)) {
- switch ($arg) {
- case self::ALL: return self::getLevelAll();
- case self::TRACE: return self::getLevelTrace();
- case self::DEBUG: return self::getLevelDebug();
- case self::INFO: return self::getLevelInfo();
- case self::WARN: return self::getLevelWarn();
- case self::ERROR: return self::getLevelError();
- case self::FATAL: return self::getLevelFatal();
- case self::OFF: return self::getLevelOff();
- default: return $defaultLevel;
+ if ($arg === self::ALL) {
+ return self::getLevelAll();
+ } elseif ($arg === self::TRACE) {
+ return self::getLevelTrace();
+ } elseif ($arg === self::DEBUG) {
+ return self::getLevelDebug();
+ } elseif ($arg === self::INFO) {
+ return self::getLevelInfo();
+ } elseif ($arg === self::WARN) {
+ return self::getLevelWarn();
+ } elseif ($arg === self::ERROR) {
+ return self::getLevelError();
+ } elseif ($arg === self::FATAL) {
+ return self::getLevelFatal();
+ } elseif ($arg === self::OFF) {
+ return self::getLevelOff();
}
} else {
- switch (strtoupper($arg)) {
- case 'ALL': return self::getLevelAll();
- case 'TRACE': return self::getLevelTrace();
- case 'DEBUG': return self::getLevelDebug();
- case 'INFO': return self::getLevelInfo();
- case 'WARN': return self::getLevelWarn();
- case 'ERROR': return self::getLevelError();
- case 'FATAL': return self::getLevelFatal();
- case 'OFF': return self::getLevelOff();
- default: return $defaultLevel;
+ $arg = strtoupper($arg);
+ if ($arg === 'ALL') {
+ return self::getLevelAll();
+ } elseif ($arg === 'TRACE') {
+ return self::getLevelTrace();
+ } elseif ($arg === 'DEBUG') {
+ return self::getLevelDebug();
+ } elseif ($arg === 'INFO') {
+ return self::getLevelInfo();
+ } elseif ($arg === 'WARN') {
+ return self::getLevelWarn();
+ } elseif ($arg === 'ERROR') {
+ return self::getLevelError();
+ } elseif ($arg === 'FATAL') {
+ return self::getLevelFatal();
+ } elseif ($arg === 'OFF') {
+ return self::getLevelOff();
}
}
+
+ return $defaultLevel;
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/LocationInfo.php
----------------------------------------------------------------------
diff --git a/src/LocationInfo.php b/src/LocationInfo.php
index 712091b..0c3becd 100644
--- a/src/LocationInfo.php
+++ b/src/LocationInfo.php
@@ -105,5 +105,4 @@ class LocationInfo
{
return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
}
-
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Logger.php
----------------------------------------------------------------------
diff --git a/src/Logger.php b/src/Logger.php
index fa504b1..f23bd08 100644
--- a/src/Logger.php
+++ b/src/Logger.php
@@ -603,7 +603,11 @@ class Logger
if ($configurator instanceof Configurator) {
return $configurator;
} else {
- trigger_error("log4php: Given configurator object [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Given configurator object [$configurator] does not implement Configurator interface. " .
+ "Reverting to default configurator.",
+ E_USER_WARNING
+ );
return new Configuration\DefaultConfigurator();
}
@@ -611,7 +615,11 @@ class Logger
if (is_string($configurator)) {
if (!class_exists($configurator)) {
- trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Given configurator class [$configurator] does not exist. " .
+ "Reverting to default configurator.",
+ E_USER_WARNING
+ );
return new Configuration\DefaultConfigurator();
}
@@ -619,7 +627,11 @@ class Logger
$instance = new $configurator();
if (!($instance instanceof Configurator)) {
- trigger_error("log4php: Specified configurator class [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Specified configurator class [$configurator] does not implement Configurator interface." .
+ " Reverting to default configurator.",
+ E_USER_WARNING
+ );
return new Configuration\DefaultConfigurator();
}
@@ -627,7 +639,11 @@ class Logger
return $instance;
}
- trigger_error("log4php: Invalid configurator specified. Expected either a string or a Configurator instance. Reverting to default configurator.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Invalid configurator specified. Expected either a string or a Configurator instance. " .
+ "Reverting to default configurator.",
+ E_USER_WARNING
+ );
return new Configuration\DefaultConfigurator();
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/LoggingEvent.php
----------------------------------------------------------------------
diff --git a/src/LoggingEvent.php b/src/LoggingEvent.php
index 4187224..8fa5d5f 100644
--- a/src/LoggingEvent.php
+++ b/src/LoggingEvent.php
@@ -143,10 +143,10 @@ class LoggingEvent
* Returns the full qualified classname.
* TODO: PHP does contain namespaces in 5.3. Those should be returned too,
*/
- public function getFullQualifiedClassname()
- {
- return $this->fqcn;
- }
+ public function getFullQualifiedClassname()
+ {
+ return $this->fqcn;
+ }
/**
* Set the location information for this logging event. The collected
@@ -182,7 +182,7 @@ class LoggingEvent
$hop = array_pop($trace);
}
$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
- if(isset($prevHop['function']) and
+ if (isset($prevHop['function']) and
$prevHop['function'] !== 'include' and
$prevHop['function'] !== 'include_once' and
$prevHop['function'] !== 'require' and
@@ -388,7 +388,6 @@ class LoggingEvent
'locationInfo',
);
}
-
}
LoggingEvent::getStartTime();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Pattern/AbstractConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/AbstractConverter.php b/src/Pattern/AbstractConverter.php
index c3760ab..4f9c46b 100644
--- a/src/Pattern/AbstractConverter.php
+++ b/src/Pattern/AbstractConverter.php
@@ -68,7 +68,10 @@ abstract class AbstractConverter
* Called in constructor. Converters which need to process the options
* can override this method.
*/
- public function activateOptions() { }
+ public function activateOptions()
+ {
+
+ }
/**
* Converts the logging event to the desired format. Derived pattern
@@ -108,17 +111,16 @@ abstract class AbstractConverter
$len = strlen($string);
- // Trim the string if needed
+ // Trim the string or add padding if needed
if ($len > $fi->max) {
+ // Trim
if ($fi->trimLeft) {
$sbuf .= substr($string, $len - $fi->max, $fi->max);
} else {
- $sbuf .= substr($string , 0, $fi->max);
+ $sbuf .= substr($string, 0, $fi->max);
}
- }
-
- // Add padding if needed
- else if ($len < $fi->min) {
+ } elseif ($len < $fi->min) {
+ // Pad
if ($fi->padLeft) {
$sbuf .= str_repeat(' ', $fi->min - $len);
$sbuf .= $string;
@@ -126,10 +128,8 @@ abstract class AbstractConverter
$sbuf .= $string;
$sbuf .= str_repeat(' ', $fi->min - $len);
}
- }
-
- // No action needed
- else {
+ } else {
+ // No action needed
$sbuf .= $string;
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Pattern/ClassConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/ClassConverter.php b/src/Pattern/ClassConverter.php
index 5adc46d..cb8d515 100644
--- a/src/Pattern/ClassConverter.php
+++ b/src/Pattern/ClassConverter.php
@@ -50,13 +50,11 @@ class ClassConverter extends AbstractConverter
if (!isset($this->cache[$name])) {
- // If length is set return shortened class name
if (isset($this->length)) {
+ // If length is set return shortened class name
$this->cache[$name] = Utils::shortenClassName($name, $this->length);
- }
-
- // If no length is specified return the full class name
- else {
+ } else {
+ // If no length is specified return the full class name
$this->cache[$name] = $name;
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Pattern/LoggerConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/LoggerConverter.php b/src/Pattern/LoggerConverter.php
index b436fee..0689601 100644
--- a/src/Pattern/LoggerConverter.php
+++ b/src/Pattern/LoggerConverter.php
@@ -52,13 +52,11 @@ class LoggerConverter extends AbstractConverter
if (!isset($this->cache[$name])) {
- // If length is set return shortened logger name
if (isset($this->length)) {
+ // If length is set return shortened logger name
$this->cache[$name] = Utils::shortenClassName($name, $this->length);
- }
-
- // If no length is specified return full logger name
- else {
+ } else {
+ // If no length is specified return full logger name
$this->cache[$name] = $name;
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Pattern/SuperglobalConverter.php
----------------------------------------------------------------------
diff --git a/src/Pattern/SuperglobalConverter.php b/src/Pattern/SuperglobalConverter.php
index 11431fb..3350044 100644
--- a/src/Pattern/SuperglobalConverter.php
+++ b/src/Pattern/SuperglobalConverter.php
@@ -80,15 +80,13 @@ abstract class SuperglobalConverter extends AbstractConverter
$source = ${$this->name};
- // When the key is set, display the matching value
if (isset($key)) {
+ // When the key is set, display the matching value
if (isset($source[$key])) {
$this->value = $source[$key];
}
- }
-
- // When the key is not set, display all values
- else {
+ } else {
+ // When the key is not set, display all values
$values = array();
foreach ($source as $key => $value) {
$values[] = "$key=$value";
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/ReflectionUtils.php
----------------------------------------------------------------------
diff --git a/src/ReflectionUtils.php b/src/ReflectionUtils.php
index dd9a4da..d5e488f 100644
--- a/src/ReflectionUtils.php
+++ b/src/ReflectionUtils.php
@@ -45,11 +45,12 @@ class ReflectionUtils
* go. The <code>properties</code> are parsed relative to a
* <code>prefix</code>.
*
+ * TODO: check, if this is really useful
+ *
* @param object $obj The object to configure.
* @param array $properties An array containing keys and values.
* @param string $prefix Only keys having the specified prefix will be set.
*/
- // TODO: check, if this is really useful
public static function setPropertiesByObject($obj, $properties, $prefix)
{
$pSetter = new ReflectionUtils($obj);
@@ -114,7 +115,8 @@ class ReflectionUtils
$method = "set" . ucfirst($name);
if (!method_exists($this->obj, $method)) {
- throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
+ $class = get_class($this->obj);
+ throw new Exception("Error setting log4php property $name to $value: no method $method in class $class.");
} else {
return call_user_func(array($this->obj, $method), $value);
}
@@ -159,5 +161,4 @@ class ReflectionUtils
return false;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/src/Renderers/RendererMap.php
----------------------------------------------------------------------
diff --git a/src/Renderers/RendererMap.php b/src/Renderers/RendererMap.php
index c3cec35..3cd86fb 100644
--- a/src/Renderers/RendererMap.php
+++ b/src/Renderers/RendererMap.php
@@ -69,14 +69,21 @@ class RendererMap
}
if (!isset($renderer)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Failed adding renderer. Rendering class [$renderingClass] not found.",
+ E_USER_WARNING
+ );
return;
}
// Check the class implements the right interface
if (!($renderer instanceof RendererInterface)) {
- trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Failed adding renderer. " .
+ "Rendering class [$renderingClass] does not implement RendererInterface.",
+ E_USER_WARNING
+ );
return;
}
@@ -101,7 +108,10 @@ class RendererMap
{
// Check the class exists
if (!class_exists($renderingClass)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.",
+ E_USER_WARNING
+ );
return;
}
@@ -111,7 +121,11 @@ class RendererMap
// Check the class implements the right interface
if (!($renderer instanceof RendererInterface)) {
- trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the RendererInterface interface.", E_USER_WARNING);
+ trigger_error(
+ "log4php: Failed setting default renderer. " .
+ "Rendering class [$renderingClass] does not implement RendererInterface.",
+ E_USER_WARNING
+ );
return;
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/tests/src/ConfiguratorTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ConfiguratorTest.php b/tests/src/ConfiguratorTest.php
index d38cc0c..2e234ee 100644
--- a/tests/src/ConfiguratorTest.php
+++ b/tests/src/ConfiguratorTest.php
@@ -202,7 +202,7 @@ class CostumDefaultRenderer implements RendererInterface
/**
* @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement RendererInterface.
*/
public function testInvalidRenderingClassSet()
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/tests/src/Configurators/INIAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/INIAdapterTest.php b/tests/src/Configurators/INIAdapterTest.php
index 5b950e4..31c8435 100644
--- a/tests/src/Configurators/INIAdapterTest.php
+++ b/tests/src/Configurators/INIAdapterTest.php
@@ -124,7 +124,7 @@ class INIAdapterTest extends \PHPUnit_Framework_TestCase
/**
* Test a warning is triggered when configurator doesn't understand a line.
* @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.layout.param.bla = LoggerLayoutTTCC". Skipping.
+ * @expectedExceptionMessage log4php: Don't know how to parse line: "log4php.appender.default.layout.param.bla = LoggerLayoutTTCC". Skipping.
*/
public function testInvalidLineWarning1()
{
@@ -136,7 +136,7 @@ class INIAdapterTest extends \PHPUnit_Framework_TestCase
/**
* Test a warning is triggered when configurator doesn't understand a line.
* @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.not-layout.param = LoggerLayoutTTCC". Skipping.
+ * @expectedExceptionMessage log4php: Don't know how to parse line: "log4php.appender.default.not-layout.param = LoggerLayoutTTCC". Skipping.
*/
public function testInvalidLineWarning2()
{
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/378ce1a3/tests/src/Renderers/RendererMapTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Renderers/RendererMapTest.php b/tests/src/Renderers/RendererMapTest.php
index 664bb71..8c3bf7e 100644
--- a/tests/src/Renderers/RendererMapTest.php
+++ b/tests/src/Renderers/RendererMapTest.php
@@ -126,7 +126,7 @@ class RendererMapTest extends \PHPUnit_Framework_TestCase
/**
* Try adding a class which does not implement RendererInterface as renderer.
* @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement RendererInterface.
*/
public function testAddRendererError2()
{
@@ -158,7 +158,7 @@ class RendererMapTest extends \PHPUnit_Framework_TestCase
/**
* Try setting a class which does not implement RendererInterface as default renderer.
* @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed setting default renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ * @expectedExceptionMessage Failed setting default renderer. Rendering class [stdClass] does not implement RendererInterface.
*/
public function testSetDefaultRendererError2()
{
[21/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerHierarchy.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerHierarchy.php b/src/main/php/LoggerHierarchy.php
deleted file mode 100644
index 55fe143..0000000
--- a/src/main/php/LoggerHierarchy.php
+++ /dev/null
@@ -1,257 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This class is specialized in retrieving loggers by name and also maintaining
- * the logger hierarchy. The logger hierarchy is dealing with the several Log-Levels
- * Logger can have. From log4j website:
- *
- * "A logger is said to be an ancestor of another logger if its name followed
- * by a dot is a prefix of the descendant logger name. A logger is said to be
- * a parent of a child logger if there are no ancestors between itself and the
- * descendant logger."
- *
- * Child Loggers do inherit their Log-Levels from their Ancestors. They can
- * increase their Log-Level compared to their Ancestors, but they cannot decrease it.
- *
- * <p>The casual user does not have to deal with this class directly.</p>
- *
- * <p>The structure of the logger hierarchy is maintained by the
- * getLogger method. The hierarchy is such that children link
- * to their parent but parents do not have any pointers to their
- * children. Moreover, loggers can be instantiated in any order, in
- * particular descendant before ancestor.</p>
- *
- * <p>In case a descendant is created before a particular ancestor,
- * then it creates a provision node for the ancestor and adds itself
- * to the provision node. Other descendants of the same ancestor add
- * themselves to the previously created provision node.</p>
- *
- * @version $Revision$
- * @package log4php
- */
-class LoggerHierarchy {
-
- /** Array holding all Logger instances. */
- protected $loggers = array();
-
- /**
- * The root logger.
- * @var RootLogger
- */
- protected $root;
-
- /**
- * The logger renderer map.
- * @var LoggerRendererMap
- */
- protected $rendererMap;
-
- /**
- * Main level threshold. Events with lower level will not be logged by any
- * logger, regardless of it's configuration.
- * @var LoggerLevel
- */
- protected $threshold;
-
- /**
- * Creates a new logger hierarchy.
- * @param LoggerRoot $root The root logger.
- */
- public function __construct(LoggerRoot $root) {
- $this->root = $root;
- $this->setThreshold(LoggerLevel::getLevelAll());
- $this->rendererMap = new LoggerRendererMap();
- }
-
- /**
- * Clears all loggers.
- */
- public function clear() {
- $this->loggers = array();
- }
-
- /**
- * Check if the named logger exists in the hierarchy.
- * @param string $name
- * @return boolean
- */
- public function exists($name) {
- return isset($this->loggers[$name]);
- }
-
- /**
- * Returns all the currently defined loggers in this hierarchy as an array.
- * @return array
- */
- public function getCurrentLoggers() {
- return array_values($this->loggers);
- }
-
- /**
- * Returns a named logger instance logger. If it doesn't exist, one is created.
- *
- * @param string $name Logger name
- * @return Logger Logger instance.
- */
- public function getLogger($name) {
- if(!isset($this->loggers[$name])) {
- $logger = new Logger($name);
-
- $nodes = explode('.', $name);
- $firstNode = array_shift($nodes);
-
- // if name is not a first node but another first node is their
- if($firstNode != $name and isset($this->loggers[$firstNode])) {
- $logger->setParent($this->loggers[$firstNode]);
- } else {
- // if there is no father, set root logger as father
- $logger->setParent($this->root);
- }
-
- // if there are more nodes than one
- if(count($nodes) > 0) {
- // find parent node
- foreach($nodes as $node) {
- $parentNode = "$firstNode.$node";
- if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
- $logger->setParent($this->loggers[$parentNode]);
- }
- $firstNode .= ".$node";
- }
- }
-
- $this->loggers[$name] = $logger;
- }
-
- return $this->loggers[$name];
- }
-
- /**
- * Returns the logger renderer map.
- * @return LoggerRendererMap
- */
- public function getRendererMap() {
- return $this->rendererMap;
- }
-
- /**
- * Returns the root logger.
- * @return LoggerRoot
- */
- public function getRootLogger() {
- return $this->root;
- }
-
- /**
- * Returns the main threshold level.
- * @return LoggerLevel
- */
- public function getThreshold() {
- return $this->threshold;
- }
-
- /**
- * Returns true if the hierarchy is disabled for given log level and false
- * otherwise.
- * @return boolean
- */
- public function isDisabled(LoggerLevel $level) {
- return ($this->threshold->toInt() > $level->toInt());
- }
-
- /**
- * Reset all values contained in this hierarchy instance to their
- * default.
- *
- * This removes all appenders from all loggers, sets
- * the level of all non-root loggers to <i>null</i>,
- * sets their additivity flag to <i>true</i> and sets the level
- * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
- *
- * <p>Existing loggers are not removed. They are just reset.
- *
- * <p>This method should be used sparingly and with care as it will
- * block all logging until it is completed.</p>
- */
- public function resetConfiguration() {
- $root = $this->getRootLogger();
-
- $root->setLevel(LoggerLevel::getLevelDebug());
- $this->setThreshold(LoggerLevel::getLevelAll());
- $this->shutDown();
-
- foreach($this->loggers as $logger) {
- $logger->setLevel(null);
- $logger->setAdditivity(true);
- $logger->removeAllAppenders();
- }
-
- $this->rendererMap->reset();
- LoggerAppenderPool::clear();
- }
-
- /**
- * Sets the main threshold level.
- * @param LoggerLevel $l
- */
- public function setThreshold(LoggerLevel $threshold) {
- $this->threshold = $threshold;
- }
-
- /**
- * Shutting down a hierarchy will <i>safely</i> close and remove
- * all appenders in all loggers including the root logger.
- *
- * The shutdown method is careful to close nested
- * appenders before closing regular appenders. This is allows
- * configurations where a regular appender is attached to a logger
- * and again to a nested appender.
- *
- * @todo Check if the last paragraph is correct.
- */
- public function shutdown() {
- $this->root->removeAllAppenders();
-
- foreach($this->loggers as $logger) {
- $logger->removeAllAppenders();
- }
- }
-
- /**
- * Prints the current Logger hierarchy tree. Useful for debugging.
- */
- public function printHierarchy() {
- $this->printHierarchyInner($this->getRootLogger(), 0);
- }
-
- private function printHierarchyInner(Logger $current, $level) {
- for ($i = 0; $i < $level; $i++) {
- echo ($i == $level - 1) ? "|--" : "| ";
- }
- echo $current->getName() . "\n";
-
- foreach($this->loggers as $logger) {
- if ($logger->getParent() == $current) {
- $this->printHierarchyInner($logger, $level + 1);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerLayout.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerLayout.php b/src/main/php/LoggerLayout.php
deleted file mode 100644
index dd10820..0000000
--- a/src/main/php/LoggerLayout.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Extend this abstract class to create your own log layout format.
- *
- * @version $Revision$
- * @package log4php
- */
-abstract class LoggerLayout extends LoggerConfigurable {
- /**
- * Activates options for this layout.
- * Override this method if you have options to be activated.
- */
- public function activateOptions() {
- return true;
- }
-
- /**
- * Override this method to create your own layout format.
- *
- * @param LoggerLoggingEvent
- * @return string
- */
- public function format(LoggerLoggingEvent $event) {
- return $event->getRenderedMessage();
- }
-
- /**
- * Returns the content type output by this layout.
- * @return string
- */
- public function getContentType() {
- return "text/plain";
- }
-
- /**
- * Returns the footer for the layout format.
- * @return string
- */
- public function getFooter() {
- return null;
- }
-
- /**
- * Returns the header for the layout format.
- * @return string
- */
- public function getHeader() {
- return null;
- }
-
- /** Triggers a warning for this layout with the given message. */
- protected function warn($message) {
- trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerLevel.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerLevel.php b/src/main/php/LoggerLevel.php
deleted file mode 100644
index bcab6b0..0000000
--- a/src/main/php/LoggerLevel.php
+++ /dev/null
@@ -1,256 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Defines the minimum set of levels recognized by the system, that is
- * <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
- * <i>WARN</i>, <i>INFO</i>, <i>DEBUG</i> and
- * <i>ALL</i>.
- *
- * <p>The <i>LoggerLevel</i> class may be subclassed to define a larger
- * level set.</p>
- *
- * @version $Revision$
- * @package log4php
- * @since 0.5
- */
-class LoggerLevel {
-
- const OFF = 2147483647;
- const FATAL = 50000;
- const ERROR = 40000;
- const WARN = 30000;
- const INFO = 20000;
- const DEBUG = 10000;
- const TRACE = 5000;
- const ALL = -2147483647;
-
- /** Integer level value. */
- private $level;
-
- /** Contains a list of instantiated levels. */
- private static $levelMap;
-
- /** String representation of the level. */
- private $levelStr;
-
- /**
- * Equivalent syslog level.
- * @var integer
- */
- private $syslogEquivalent;
-
- /**
- * Constructor
- *
- * @param integer $level
- * @param string $levelStr
- * @param integer $syslogEquivalent
- */
- private function __construct($level, $levelStr, $syslogEquivalent) {
- $this->level = $level;
- $this->levelStr = $levelStr;
- $this->syslogEquivalent = $syslogEquivalent;
- }
-
- /**
- * Compares two logger levels.
- *
- * @param LoggerLevels $other
- * @return boolean
- */
- public function equals($other) {
- if($other instanceof LoggerLevel) {
- if($this->level == $other->level) {
- return true;
- }
- } else {
- return false;
- }
- }
-
- /**
- * Returns an Off Level
- * @return LoggerLevel
- */
- public static function getLevelOff() {
- if(!isset(self::$levelMap[LoggerLevel::OFF])) {
- self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', LOG_ALERT);
- }
- return self::$levelMap[LoggerLevel::OFF];
- }
-
- /**
- * Returns a Fatal Level
- * @return LoggerLevel
- */
- public static function getLevelFatal() {
- if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
- self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
- }
- return self::$levelMap[LoggerLevel::FATAL];
- }
-
- /**
- * Returns an Error Level
- * @return LoggerLevel
- */
- public static function getLevelError() {
- if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
- self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', LOG_ERR);
- }
- return self::$levelMap[LoggerLevel::ERROR];
- }
-
- /**
- * Returns a Warn Level
- * @return LoggerLevel
- */
- public static function getLevelWarn() {
- if(!isset(self::$levelMap[LoggerLevel::WARN])) {
- self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', LOG_WARNING);
- }
- return self::$levelMap[LoggerLevel::WARN];
- }
-
- /**
- * Returns an Info Level
- * @return LoggerLevel
- */
- public static function getLevelInfo() {
- if(!isset(self::$levelMap[LoggerLevel::INFO])) {
- self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', LOG_INFO);
- }
- return self::$levelMap[LoggerLevel::INFO];
- }
-
- /**
- * Returns a Debug Level
- * @return LoggerLevel
- */
- public static function getLevelDebug() {
- if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
- self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
- }
- return self::$levelMap[LoggerLevel::DEBUG];
- }
-
- /**
- * Returns a Trace Level
- * @return LoggerLevel
- */
- public static function getLevelTrace() {
- if(!isset(self::$levelMap[LoggerLevel::TRACE])) {
- self::$levelMap[LoggerLevel::TRACE] = new LoggerLevel(LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
- }
- return self::$levelMap[LoggerLevel::TRACE];
- }
-
- /**
- * Returns an All Level
- * @return LoggerLevel
- */
- public static function getLevelAll() {
- if(!isset(self::$levelMap[LoggerLevel::ALL])) {
- self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', LOG_DEBUG);
- }
- return self::$levelMap[LoggerLevel::ALL];
- }
-
- /**
- * Return the syslog equivalent of this level as an integer.
- * @return integer
- */
- public function getSyslogEquivalent() {
- return $this->syslogEquivalent;
- }
-
- /**
- * Returns <i>true</i> if this level has a higher or equal
- * level than the level passed as argument, <i>false</i>
- * otherwise.
- *
- * @param LoggerLevel $other
- * @return boolean
- */
- public function isGreaterOrEqual($other) {
- return $this->level >= $other->level;
- }
-
- /**
- * Returns the string representation of this level.
- * @return string
- */
- public function toString() {
- return $this->levelStr;
- }
-
- /**
- * Returns the string representation of this level.
- * @return string
- */
- public function __toString() {
- return $this->toString();
- }
-
- /**
- * Returns the integer representation of this level.
- * @return integer
- */
- public function toInt() {
- return $this->level;
- }
-
- /**
- * Convert the input argument to a level. If the conversion fails, then
- * this method returns the provided default level.
- *
- * @param mixed $arg The value to convert to level.
- * @param LoggerLevel $default Value to return if conversion is not possible.
- * @return LoggerLevel
- */
- public static function toLevel($arg, $defaultLevel = null) {
- if(is_int($arg)) {
- switch($arg) {
- case self::ALL: return self::getLevelAll();
- case self::TRACE: return self::getLevelTrace();
- case self::DEBUG: return self::getLevelDebug();
- case self::INFO: return self::getLevelInfo();
- case self::WARN: return self::getLevelWarn();
- case self::ERROR: return self::getLevelError();
- case self::FATAL: return self::getLevelFatal();
- case self::OFF: return self::getLevelOff();
- default: return $defaultLevel;
- }
- } else {
- switch(strtoupper($arg)) {
- case 'ALL': return self::getLevelAll();
- case 'TRACE': return self::getLevelTrace();
- case 'DEBUG': return self::getLevelDebug();
- case 'INFO': return self::getLevelInfo();
- case 'WARN': return self::getLevelWarn();
- case 'ERROR': return self::getLevelError();
- case 'FATAL': return self::getLevelFatal();
- case 'OFF': return self::getLevelOff();
- default: return $defaultLevel;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerLocationInfo.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerLocationInfo.php b/src/main/php/LoggerLocationInfo.php
deleted file mode 100644
index 2ef7f75..0000000
--- a/src/main/php/LoggerLocationInfo.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The internal representation of caller location information.
- *
- * @version $Revision$
- * @package log4php
- * @since 0.3
- */
-class LoggerLocationInfo {
-
- /** The value to return when the location information is not available. */
- const LOCATION_INFO_NA = 'NA';
-
- /**
- * Caller line number.
- * @var integer
- */
- protected $lineNumber;
-
- /**
- * Caller file name.
- * @var string
- */
- protected $fileName;
-
- /**
- * Caller class name.
- * @var string
- */
- protected $className;
-
- /**
- * Caller method name.
- * @var string
- */
- protected $methodName;
-
- /**
- * All the information combined.
- * @var string
- */
- protected $fullInfo;
-
- /**
- * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
- *
- * @param array $trace
- * @param mixed $caller
- */
- public function __construct($trace, $fqcn = null) {
- $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
- $this->fileName = isset($trace['file']) ? $trace['file'] : null;
- $this->className = isset($trace['class']) ? $trace['class'] : null;
- $this->methodName = isset($trace['function']) ? $trace['function'] : null;
- $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
- '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
- }
-
- /** Returns the caller class name. */
- public function getClassName() {
- return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
- }
-
- /** Returns the caller file name. */
- public function getFileName() {
- return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
- }
-
- /** Returns the caller line number. */
- public function getLineNumber() {
- return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
- }
-
- /** Returns the caller method name. */
- public function getMethodName() {
- return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
- }
-
- /** Returns the full information of the caller. */
- public function getFullInfo() {
- return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerLoggingEvent.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerLoggingEvent.php b/src/main/php/LoggerLoggingEvent.php
deleted file mode 100644
index 29ba361..0000000
--- a/src/main/php/LoggerLoggingEvent.php
+++ /dev/null
@@ -1,368 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The internal representation of logging event.
- *
- * @version $Revision$
- * @package log4php
- */
-class LoggerLoggingEvent {
-
- private static $startTime;
-
- /**
- * @var string Fully Qualified Class Name of the calling category class.
- */
- private $fqcn;
-
- /**
- * @var Logger reference
- */
- private $logger;
-
- /**
- * The category (logger) name.
- * This field will be marked as private in future
- * releases. Please do not access it directly.
- * Use the {@link getLoggerName()} method instead.
- * @deprecated
- */
- private $categoryName;
-
- /**
- * Level of the logging event.
- * @var LoggerLevel
- */
- protected $level;
-
- /**
- * The nested diagnostic context (NDC) of logging event.
- * @var string
- */
- private $ndc;
-
- /**
- * Have we tried to do an NDC lookup? If we did, there is no need
- * to do it again. Note that its value is always false when
- * serialized. Thus, a receiving SocketNode will never use it's own
- * (incorrect) NDC. See also writeObject method.
- * @var boolean
- */
- private $ndcLookupRequired = true;
-
- /**
- * @var mixed The application supplied message of logging event.
- */
- private $message;
-
- /**
- * The application supplied message rendered through the log4php
- * objet rendering mechanism. At present renderedMessage == message.
- * @var string
- */
- private $renderedMessage;
-
- /**
- * The name of thread in which this logging event was generated.
- * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
- * @var mixed
- */
- private $threadName;
-
- /**
- * The number of seconds elapsed from 1/1/1970 until logging event
- * was created plus microseconds if available.
- * @var float
- */
- public $timeStamp;
-
- /**
- * @var LoggerLocationInfo Location information for the caller.
- */
- private $locationInfo;
-
- /**
- * @var LoggerThrowableInformation log4php internal representation of throwable
- */
- private $throwableInfo;
-
- /**
- * Instantiate a LoggingEvent from the supplied parameters.
- *
- * Except {@link $timeStamp} all the other fields of
- * LoggerLoggingEvent are filled when actually needed.
- *
- * @param string $fqcn name of the caller class.
- * @param mixed $logger The {@link Logger} category of this event or the logger name.
- * @param LoggerLevel $level The level of this event.
- * @param mixed $message The message of this event.
- * @param integer $timeStamp the timestamp of this logging event.
- * @param Exception $throwable The throwable associated with logging event
- */
- public function __construct($fqcn, $logger, LoggerLevel $level, $message, $timeStamp = null, $throwable = null) {
- $this->fqcn = $fqcn;
- if($logger instanceof Logger) {
- $this->logger = $logger;
- $this->categoryName = $logger->getName();
- } else {
- $this->categoryName = strval($logger);
- }
- $this->level = $level;
- $this->message = $message;
- if($timeStamp !== null && is_numeric($timeStamp)) {
- $this->timeStamp = $timeStamp;
- } else {
- $this->timeStamp = microtime(true);
- }
-
- if ($throwable !== null && $throwable instanceof Exception) {
- $this->throwableInfo = new LoggerThrowableInformation($throwable);
- }
- }
-
- /**
- * Returns the full qualified classname.
- * TODO: PHP does contain namespaces in 5.3. Those should be returned too,
- */
- public function getFullQualifiedClassname() {
- return $this->fqcn;
- }
-
- /**
- * Set the location information for this logging event. The collected
- * information is cached for future use.
- *
- * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
- * to collect informations about caller.</p>
- * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
- * @return LoggerLocationInfo
- */
- public function getLocationInformation() {
- if($this->locationInfo === null) {
-
- $locationInfo = array();
- $trace = debug_backtrace();
- $prevHop = null;
- // make a downsearch to identify the caller
- $hop = array_pop($trace);
- while($hop !== null) {
- if(isset($hop['class'])) {
- // we are sometimes in functions = no class available: avoid php warning here
- $className = strtolower($hop['class']);
- if(!empty($className) and ($className == 'logger' or
- strtolower(get_parent_class($className)) == 'logger')) {
- $locationInfo['line'] = $hop['line'];
- $locationInfo['file'] = $hop['file'];
- break;
- }
- }
- $prevHop = $hop;
- $hop = array_pop($trace);
- }
- $locationInfo['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') {
-
- $locationInfo['function'] = $prevHop['function'];
- } else {
- $locationInfo['function'] = 'main';
- }
-
- $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
- }
- return $this->locationInfo;
- }
-
- /**
- * Return the level of this event. Use this form instead of directly
- * accessing the {@link $level} field.
- * @return LoggerLevel
- */
- public function getLevel() {
- return $this->level;
- }
-
- /**
- * Returns the logger which created the event.
- * @return Logger
- */
- public function getLogger() {
- return $this->logger;
- }
-
- /**
- * Return the name of the logger. Use this form instead of directly
- * accessing the {@link $categoryName} field.
- * @return string
- */
- public function getLoggerName() {
- return $this->categoryName;
- }
-
- /**
- * Return the message for this logging event.
- * @return mixed
- */
- public function getMessage() {
- return $this->message;
- }
-
- /**
- * This method returns the NDC for this event. It will return the
- * correct content even if the event was generated in a different
- * thread or even on a different machine. The {@link LoggerNDC::get()} method
- * should <b>never</b> be called directly.
- * @return string
- */
- public function getNDC() {
- if($this->ndcLookupRequired) {
- $this->ndcLookupRequired = false;
- $this->ndc = LoggerNDC::get();
- }
- return $this->ndc;
- }
-
- /**
- * Returns the the context corresponding to the <code>key</code>
- * parameter.
- * @return string
- */
- public function getMDC($key) {
- return LoggerMDC::get($key);
- }
-
- /**
- * Returns the entire MDC context.
- * @return array
- */
- public function getMDCMap () {
- return LoggerMDC::getMap();
- }
-
- /**
- * Render message.
- * @return string
- */
- public function getRenderedMessage() {
- if($this->renderedMessage === null and $this->message !== null) {
- if(is_string($this->message)) {
- $this->renderedMessage = $this->message;
- } else {
- $rendererMap = Logger::getHierarchy()->getRendererMap();
- $this->renderedMessage= $rendererMap->findAndRender($this->message);
- }
- }
- return $this->renderedMessage;
- }
-
- /**
- * Returns the time when the application started, as a UNIX timestamp
- * with microseconds.
- * @return float
- */
- public static function getStartTime() {
- if(!isset(self::$startTime)) {
- self::$startTime = microtime(true);
- }
- return self::$startTime;
- }
-
- /**
- * @return float
- */
- public function getTimeStamp() {
- return $this->timeStamp;
- }
-
- /**
- * Returns the time in seconds passed from the beginning of execution to
- * the time the event was constructed.
- *
- * @return float Seconds with microseconds in decimals.
- */
- public function getRelativeTime() {
- return $this->timeStamp - self::$startTime;
- }
-
- /**
- * Returns the time in milliseconds passed from the beginning of execution
- * to the time the event was constructed.
- *
- * @deprecated This method has been replaced by getRelativeTime which
- * does not perform unneccesary multiplication and formatting.
- *
- * @return integer
- */
- public function getTime() {
- $eventTime = $this->getTimeStamp();
- $eventStartTime = LoggerLoggingEvent::getStartTime();
- return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
- }
-
- /**
- * @return mixed
- */
- public function getThreadName() {
- if ($this->threadName === null) {
- $this->threadName = (string)getmypid();
- }
- return $this->threadName;
- }
-
- /**
- * @return mixed LoggerThrowableInformation
- */
- public function getThrowableInformation() {
- return $this->throwableInfo;
- }
-
- /**
- * Serialize this object
- * @return string
- */
- public function toString() {
- serialize($this);
- }
-
- /**
- * Avoid serialization of the {@link $logger} object
- */
- public function __sleep() {
- return array(
- 'fqcn',
- 'categoryName',
- 'level',
- 'ndc',
- 'ndcLookupRequired',
- 'message',
- 'renderedMessage',
- 'threadName',
- 'timeStamp',
- 'locationInfo',
- );
- }
-
-}
-
-LoggerLoggingEvent::getStartTime();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerMDC.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerMDC.php b/src/main/php/LoggerMDC.php
deleted file mode 100644
index 05bb549..0000000
--- a/src/main/php/LoggerMDC.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The LoggerMDC class provides _mapped diagnostic contexts_.
- *
- * A Mapped Diagnostic Context, or MDC in short, is an instrument for
- * distinguishing interleaved log output from different sources. Log output
- * is typically interleaved when a server handles multiple clients
- * near-simultaneously.
- *
- * This class is similar to the {@link LoggerNDC} class except that
- * it is based on a map instead of a stack.
- *
- * @version $Revision$
- * @since 0.3
- * @package log4php
- */
-class LoggerMDC {
-
- /** Holds the context map. */
- private static $map = array();
-
- /**
- * Stores a context value as identified with the key parameter into the
- * context map.
- *
- * @param string $key the key
- * @param string $value the value
- */
- public static function put($key, $value) {
- self::$map[$key] = $value;
- }
-
- /**
- * Returns the context value identified by the key parameter.
- *
- * @param string $key The key.
- * @return string The context or an empty string if no context found
- * for given key.
- */
- public static function get($key) {
- return isset(self::$map[$key]) ? self::$map[$key] : '';
- }
-
- /**
- * Returns the contex map as an array.
- * @return array The MDC context map.
- */
- public static function getMap() {
- return self::$map;
- }
-
- /**
- * Removes the the context identified by the key parameter.
- *
- * Only affects user mappings, not $_ENV or $_SERVER.
- *
- * @param string $key The key to be removed.
- */
- public static function remove($key) {
- unset(self::$map[$key]);
- }
-
- /**
- * Clears the mapped diagnostic context.
- */
- public static function clear() {
- self::$map = array();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerNDC.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerNDC.php b/src/main/php/LoggerNDC.php
deleted file mode 100644
index 9c01620..0000000
--- a/src/main/php/LoggerNDC.php
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The NDC class implements <i>nested diagnostic contexts</i>.
- *
- * NDC was defined by Neil Harrison in the article "Patterns for Logging
- * Diagnostic Messages" part of the book <i>"Pattern Languages of
- * Program Design 3"</i> edited by Martin et al.
- *
- * A Nested Diagnostic Context, or NDC in short, is an instrument
- * to distinguish interleaved log output from different sources. Log
- * output is typically interleaved when a server handles multiple
- * clients near-simultaneously.
- *
- * This class is similar to the {@link LoggerMDC} class except that it is
- * based on a stack instead of a map.
- *
- * Interleaved log output can still be meaningful if each log entry
- * from different contexts had a distinctive stamp. This is where NDCs
- * come into play.
- *
- * <b>Note that NDCs are managed on a per thread basis</b>.
- *
- * NDC operations such as {@link push()}, {@link pop()},
- * {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
- * affect the NDC of the <i>current</i> thread only. NDCs of other
- * threads remain unaffected.
- *
- * For example, a servlet can build a per client request NDC
- * consisting the clients host name and other information contained in
- * the the request. <i>Cookies</i> are another source of distinctive
- * information. To build an NDC one uses the {@link push()}
- * operation.
- *
- * Simply put,
- *
- * - Contexts can be nested.
- * - When entering a context, call <kbd>LoggerNDC::push()</kbd>
- * As a side effect, if there is no nested diagnostic context for the
- * current thread, this method will create it.
- * - When leaving a context, call <kbd>LoggerNDC::pop()</kbd>
- * - <b>When exiting a thread make sure to call {@link remove()}</b>
- *
- * There is no penalty for forgetting to match each
- * <kbd>push</kbd> operation with a corresponding <kbd>pop</kbd>,
- * except the obvious mismatch between the real application context
- * and the context set in the NDC.
- *
- * If configured to do so, {@link LoggerPatternLayout} and {@link LoggerLayoutTTCC}
- * instances automatically retrieve the nested diagnostic
- * context for the current thread without any user intervention.
- * Hence, even if a servlet is serving multiple clients
- * simultaneously, the logs emanating from the same code (belonging to
- * the same category) can still be distinguished because each client
- * request will have a different NDC tag.
- *
- * Example:
- *
- * {@example ../../examples/php/ndc.php 19}<br>
- *
- * With the properties file:
- *
- * {@example ../../examples/resources/ndc.properties 18}<br>
- *
- * Will result in the following (notice the conn and client ids):
- *
- * <pre>
- * 2009-09-13 19:04:27 DEBUG root conn=1234: just received a new connection in src/examples/php/ndc.php at 23
- * 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: some more messages that can in src/examples/php/ndc.php at 25
- * 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: now related to a client in src/examples/php/ndc.php at 26
- * 2009-09-13 19:04:27 DEBUG root : back and waiting for new connections in src/examples/php/ndc.php at 29
- * </pre>
- *
- * @version $Revision$
- * @package log4php
- * @since 0.3
- */
-class LoggerNDC {
-
- /** This is the repository of NDC stack */
- private static $stack = array();
-
- /**
- * Clear any nested diagnostic information if any. This method is
- * useful in cases where the same thread can be potentially used
- * over and over in different unrelated contexts.
- *
- * <p>This method is equivalent to calling the {@link setMaxDepth()}
- * method with a zero <var>maxDepth</var> argument.
- */
- public static function clear() {
- self::$stack = array();
- }
-
- /**
- * Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead.
- * @return array
- */
- public static function get() {
- return implode(' ', self::$stack);
- }
-
- /**
- * Get the current nesting depth of this diagnostic context.
- *
- * @see setMaxDepth()
- * @return integer
- */
- public static function getDepth() {
- return count(self::$stack);
- }
-
- /**
- * Clients should call this method before leaving a diagnostic
- * context.
- *
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.</p>
- *
- * @return string The innermost diagnostic context.
- */
- public static function pop() {
- if(count(self::$stack) > 0) {
- return array_pop(self::$stack);
- } else {
- return '';
- }
- }
-
- /**
- * Looks at the last diagnostic context at the top of this NDC
- * without removing it.
- *
- * <p>The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.</p>
- * @return string The innermost diagnostic context.
- */
- public static function peek() {
- if(count(self::$stack) > 0) {
- return end(self::$stack);
- } else {
- return '';
- }
- }
-
- /**
- * Push new diagnostic context information for the current thread.
- *
- * <p>The contents of the <var>message</var> parameter is
- * determined solely by the client.
- *
- * @param string $message The new diagnostic context information.
- */
- public static function push($message) {
- array_push(self::$stack, (string)$message);
- }
-
- /**
- * Remove the diagnostic context for this thread.
- */
- public static function remove() {
- LoggerNDC::clear();
- }
-
- /**
- * 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()
- */
- public static function setMaxDepth($maxDepth) {
- $maxDepth = (int)$maxDepth;
- if(LoggerNDC::getDepth() > $maxDepth) {
- self::$stack = array_slice(self::$stack, 0, $maxDepth);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerReflectionUtils.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerReflectionUtils.php b/src/main/php/LoggerReflectionUtils.php
deleted file mode 100644
index e046185..0000000
--- a/src/main/php/LoggerReflectionUtils.php
+++ /dev/null
@@ -1,152 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Provides methods for reflective use on php objects
- * @package log4php
- */
-class LoggerReflectionUtils {
- /** the target object */
- private $obj;
-
- /**
- * Create a new LoggerReflectionUtils for the specified Object.
- * This is done in prepartion for invoking {@link setProperty()}
- * one or more times.
- * @param object &$obj the object for which to set properties
- */
- public function __construct($obj) {
- $this->obj = $obj;
- }
-
- /**
- * Set the properties of an object passed as a parameter in one
- * go. The <code>properties</code> are parsed relative to a
- * <code>prefix</code>.
- *
- * @param object $obj The object to configure.
- * @param array $properties An array containing keys and values.
- * @param string $prefix Only keys having the specified prefix will be set.
- */
- // TODO: check, if this is really useful
- public static function setPropertiesByObject($obj, $properties, $prefix) {
- $pSetter = new LoggerReflectionUtils($obj);
- return $pSetter->setProperties($properties, $prefix);
- }
-
-
- /**
- * Set the properites for the object that match the
- * <code>prefix</code> passed as parameter.
- *
- * Example:
- *
- * $arr['xxxname'] = 'Joe';
- * $arr['xxxmale'] = true;
- * and prefix xxx causes setName and setMale.
- *
- * @param array $properties An array containing keys and values.
- * @param string $prefix Only keys having the specified prefix will be set.
- */
- public function setProperties($properties, $prefix) {
- $len = strlen($prefix);
- reset($properties);
- while(list($key,) = each($properties)) {
- if(strpos($key, $prefix) === 0) {
- if(strpos($key, '.', ($len + 1)) > 0) {
- continue;
- }
- $value = $properties[$key];
- $key = substr($key, $len);
- if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
- continue;
- }
- $this->setProperty($key, $value);
- }
- }
- $this->activate();
- }
-
- /**
- * Set a property on this PropertySetter's Object. If successful, this
- * method will invoke a setter method on the underlying Object. The
- * setter is the one for the specified property name and the value is
- * determined partly from the setter argument type and partly from the
- * value specified in the call to this method.
- *
- * <p>If the setter expects a String no conversion is necessary.
- * If it expects an int, then an attempt is made to convert 'value'
- * to an int using new Integer(value). If the setter expects a boolean,
- * the conversion is by new Boolean(value).
- *
- * @param string $name name of the property
- * @param string $value String value of the property
- */
- public function setProperty($name, $value) {
- if($value === null) {
- return;
- }
-
- $method = "set" . ucfirst($name);
-
- if(!method_exists($this->obj, $method)) {
- throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
- } else {
- return call_user_func(array($this->obj, $method), $value);
- }
- }
-
- public function activate() {
- if(method_exists($this->obj, 'activateoptions')) {
- return call_user_func(array($this->obj, 'activateoptions'));
- }
- }
-
- /**
- * Creates an instances from the given class name.
- *
- * @param string $classname
- * @return an object from the class with the given classname
- */
- public static function createObject($class) {
- if(!empty($class)) {
- return new $class();
- }
- return null;
- }
-
- /**
- * @param object $object
- * @param string $name
- * @param mixed $value
- */
- public static function setter($object, $name, $value) {
- if (empty($name)) {
- return false;
- }
- $methodName = 'set'.ucfirst($name);
- if (method_exists($object, $methodName)) {
- return call_user_func(array($object, $methodName), $value);
- } else {
- return false;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerRoot.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerRoot.php b/src/main/php/LoggerRoot.php
deleted file mode 100644
index 315837d..0000000
--- a/src/main/php/LoggerRoot.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The root logger.
- *
- * @version $Revision$
- * @package log4php
- * @see Logger
- */
-class LoggerRoot extends Logger {
- /**
- * Constructor
- *
- * @param integer $level initial log level
- */
- public function __construct(LoggerLevel $level = null) {
- parent::__construct('root');
-
- if($level == null) {
- $level = LoggerLevel::getLevelAll();
- }
- $this->setLevel($level);
- }
-
- /**
- * @return LoggerLevel the level
- */
- public function getEffectiveLevel() {
- return $this->getLevel();
- }
-
- /**
- * Override level setter to prevent setting the root logger's level to
- * null. Root logger must always have a level.
- *
- * @param LoggerLevel $level
- */
- public function setLevel(LoggerLevel $level = null) {
- if (isset($level)) {
- parent::setLevel($level);
- } else {
- trigger_error("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING);
- }
- }
-
- /**
- * Override parent setter. Root logger cannot have a parent.
- * @param Logger $parent
- */
- public function setParent(Logger $parent) {
- trigger_error("log4php: LoggerRoot cannot have a parent.", E_USER_WARNING);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerThrowableInformation.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerThrowableInformation.php b/src/main/php/LoggerThrowableInformation.php
deleted file mode 100644
index 20bf758..0000000
--- a/src/main/php/LoggerThrowableInformation.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The internal representation of throwables.
- *
- * @package log4php
- * @since 2.1
- */
-class LoggerThrowableInformation {
-
- /** @var Exception Throwable to log */
- private $throwable;
-
- /** @var array Array of throwable messages */
- private $throwableArray;
-
- /**
- * Create a new instance
- *
- * @param $throwable - a throwable as a exception
- * @param $logger - Logger reference
- */
- public function __construct(Exception $throwable) {
- $this->throwable = $throwable;
- }
-
- /**
- * Return source exception
- *
- * @return Exception
- */
- public function getThrowable() {
- return $this->throwable;
- }
-
- /**
- * @desc Returns string representation of throwable
- *
- * @return array
- */
- public function getStringRepresentation() {
- if (!is_array($this->throwableArray)) {
- $renderer = new LoggerRendererException();
-
- $this->throwableArray = explode("\n", $renderer->render($this->throwable));
- }
-
- return $this->throwableArray;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderConsole.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderConsole.php b/src/main/php/appenders/LoggerAppenderConsole.php
deleted file mode 100644
index dd8bfd2..0000000
--- a/src/main/php/appenders/LoggerAppenderConsole.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderConsole appends log events either to the standard output
- * stream (php://stdout) or the standard error stream (php://stderr).
- *
- * **Note**: Use this Appender with command-line php scripts. On web scripts
- * this appender has no effects.
- *
- * This appender uses a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **target** - the target stream: "stdout" or "stderr"
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/console.html Appender documentation
- */
- class LoggerAppenderConsole extends LoggerAppender {
-
- /** The standard otuput stream. */
- const STDOUT = 'php://stdout';
-
- /** The standard error stream.*/
- const STDERR = 'php://stderr';
-
- /** The 'target' parameter. */
- protected $target = self::STDOUT;
-
- /**
- * Stream resource for the target stream.
- * @var resource
- */
- protected $fp = null;
-
- public function activateOptions() {
- $this->fp = fopen($this->target, 'w');
- if(is_resource($this->fp) && $this->layout !== null) {
- fwrite($this->fp, $this->layout->getHeader());
- }
- $this->closed = (bool)is_resource($this->fp) === false;
- }
-
-
- public function close() {
- if($this->closed != true) {
- if (is_resource($this->fp) && $this->layout !== null) {
- fwrite($this->fp, $this->layout->getFooter());
- fclose($this->fp);
- }
- $this->closed = true;
- }
- }
-
- public function append(LoggerLoggingEvent $event) {
- if (is_resource($this->fp) && $this->layout !== null) {
- fwrite($this->fp, $this->layout->format($event));
- }
- }
-
- /**
- * Sets the 'target' parameter.
- * @param string $target
- */
- public function setTarget($target) {
- $value = trim($target);
- if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
- $this->target = self::STDOUT;
- } elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
- $this->target = self::STDERR;
- } else {
- $target = var_export($target);
- $this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
- }
- }
-
- /**
- * Returns the value of the 'target' parameter.
- * @return string
- */
- public function getTarget() {
- return $this->target;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderDailyFile.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderDailyFile.php b/src/main/php/appenders/LoggerAppenderDailyFile.php
deleted file mode 100644
index 8dce015..0000000
--- a/src/main/php/appenders/LoggerAppenderDailyFile.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * An Appender that automatically creates a new logfile each day.
- *
- * The file is rolled over once a day. That means, for each day a new file
- * is created. A formatted version of the date pattern is used as to create
- * the file name using the {@link PHP_MANUAL#sprintf} function.
- *
- * This appender uses a layout.
- *
- * ##Configurable parameters:##
- *
- * - **datePattern** - Format for the date in the file path, follows formatting
- * rules used by the PHP date() function. Default value: "Ymd".
- * - **file** - Path to the target file. Should contain a %s which gets
- * substituted by the date.
- * - **append** - If set to true, the appender will append to the file,
- * otherwise the file contents will be overwritten. Defaults to true.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/daily-file.html Appender documentation
- */
-class LoggerAppenderDailyFile extends LoggerAppenderFile {
-
- /**
- * The 'datePattern' parameter.
- * Determines how date will be formatted in file name.
- * @var string
- */
- protected $datePattern = "Ymd";
-
- /**
- * Current date which was used when opening a file.
- * Used to determine if a rollover is needed when the date changes.
- * @var string
- */
- protected $currentDate;
-
- /** Additional validation for the date pattern. */
- public function activateOptions() {
- parent::activateOptions();
-
- if (empty($this->datePattern)) {
- $this->warn("Required parameter 'datePattern' not set. Closing appender.");
- $this->closed = true;
- return;
- }
- }
-
- /**
- * 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;
- }
-
- // Check if rollover is needed
- 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;
- }
-
- parent::append($event);
- }
-
- /** Renders the date using the configured <var>datePattern<var>. */
- protected function getDate($timestamp = null) {
- return date($this->datePattern, $timestamp);
- }
-
- /**
- * Determines target file. Replaces %s in file path with a date.
- */
- protected function getTargetFile() {
- return str_replace('%s', $this->currentDate, $this->file);
- }
-
- /**
- * Sets the 'datePattern' parameter.
- * @param string $datePattern
- */
- public function setDatePattern($datePattern) {
- $this->setString('datePattern', $datePattern);
- }
-
- /**
- * Returns the 'datePattern' parameter.
- * @return string
- */
- public function getDatePattern() {
- return $this->datePattern;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderEcho.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderEcho.php b/src/main/php/appenders/LoggerAppenderEcho.php
deleted file mode 100644
index eabeb1e..0000000
--- a/src/main/php/appenders/LoggerAppenderEcho.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderEcho uses the PHP echo() function to output events.
- *
- * This appender uses a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **htmlLineBreaks** - If set to true, a <br /> element will be inserted
- * before each line break in the logged message. Default is false.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/echo.html Appender documentation
- */
-class LoggerAppenderEcho extends LoggerAppender {
- /**
- * Used to mark first append. Set to false after first append.
- * @var boolean
- */
- protected $firstAppend = true;
-
- /**
- * If set to true, a <br /> element will be inserted before each line
- * break in the logged message. Default value is false. @var boolean
- */
- protected $htmlLineBreaks = false;
-
- public function close() {
- if($this->closed != true) {
- if(!$this->firstAppend) {
- echo $this->layout->getFooter();
- }
- }
- $this->closed = true;
- }
-
- public function append(LoggerLoggingEvent $event) {
- if($this->layout !== null) {
- if($this->firstAppend) {
- echo $this->layout->getHeader();
- $this->firstAppend = false;
- }
- $text = $this->layout->format($event);
-
- if ($this->htmlLineBreaks) {
- $text = nl2br($text);
- }
- echo $text;
- }
- }
-
- /**
- * Sets the 'htmlLineBreaks' parameter.
- * @param boolean $value
- */
- public function setHtmlLineBreaks($value) {
- $this->setBoolean('htmlLineBreaks', $value);
- }
-
- /**
- * Returns the 'htmlLineBreaks' parameter.
- * @returns boolean
- */
- public function getHtmlLineBreaks() {
- return $this->htmlLineBreaks;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderFile.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderFile.php b/src/main/php/appenders/LoggerAppenderFile.php
deleted file mode 100644
index f29cbe3..0000000
--- a/src/main/php/appenders/LoggerAppenderFile.php
+++ /dev/null
@@ -1,225 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderFile appends log events to a file.
- *
- * This appender uses a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **file** - Path to the target file. Relative paths are resolved based on
- * the working directory.
- * - **append** - If set to true, the appender will append to the file,
- * otherwise the file contents will be overwritten.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/file.html Appender documentation
- */
-class LoggerAppenderFile extends LoggerAppender {
-
- /**
- * If set to true, the file is locked before appending. This allows
- * concurrent access. However, appending without locking is faster so
- * it should be used where appropriate.
- *
- * TODO: make this a configurable parameter
- *
- * @var boolean
- */
- protected $locking = true;
-
- /**
- * If set to true, appends to file. Otherwise overwrites it.
- * @var boolean
- */
- protected $append = true;
-
- /**
- * Path to the target file.
- * @var string
- */
- protected $file;
-
- /**
- * The file resource.
- * @var resource
- */
- protected $fp;
-
- /**
- * Helper function which can be easily overriden by daily file appender.
- */
- protected function getTargetFile() {
- return $this->file;
- }
-
- /**
- * Acquires the target file resource, creates the destination folder if
- * necessary. Writes layout header to file.
- *
- * @return boolean FALSE if opening failed
- */
- protected function openFile() {
- $file = $this->getTargetFile();
-
- // Create the target folder if needed
- if(!is_file($file)) {
- $dir = dirname($file);
-
- if(!is_dir($dir)) {
- $success = mkdir($dir, 0777, true);
- if ($success === false) {
- $this->warn("Failed creating target directory [$dir]. Closing appender.");
- $this->closed = true;
- return false;
- }
- }
- }
-
- $mode = $this->append ? 'a' : 'w';
- $this->fp = fopen($file, $mode);
- if ($this->fp === false) {
- $this->warn("Failed opening target file. Closing appender.");
- $this->fp = null;
- $this->closed = true;
- return false;
- }
-
- // Required when appending with concurrent access
- if($this->append) {
- fseek($this->fp, 0, SEEK_END);
- }
-
- // Write the header
- $this->write($this->layout->getHeader());
- }
-
- /**
- * Writes a string to the target file. Opens file if not already open.
- * @param string $string Data to write.
- */
- protected function write($string) {
- // Lazy file open
- if(!isset($this->fp)) {
- if ($this->openFile() === false) {
- return; // Do not write if file open failed.
- }
- }
-
- if ($this->locking) {
- $this->writeWithLocking($string);
- } else {
- $this->writeWithoutLocking($string);
- }
- }
-
- protected function writeWithLocking($string) {
- if(flock($this->fp, LOCK_EX)) {
- if(fwrite($this->fp, $string) === false) {
- $this->warn("Failed writing to file. Closing appender.");
- $this->closed = true;
- }
- flock($this->fp, LOCK_UN);
- } else {
- $this->warn("Failed locking file for writing. Closing appender.");
- $this->closed = true;
- }
- }
-
- protected function writeWithoutLocking($string) {
- if(fwrite($this->fp, $string) === false) {
- $this->warn("Failed writing to file. Closing appender.");
- $this->closed = true;
- }
- }
-
- public function activateOptions() {
- if (empty($this->file)) {
- $this->warn("Required parameter 'file' not set. Closing appender.");
- $this->closed = true;
- return;
- }
- }
-
- public function close() {
- if (is_resource($this->fp)) {
- $this->write($this->layout->getFooter());
- fclose($this->fp);
- }
- $this->fp = null;
- $this->closed = true;
- }
-
- public function append(LoggerLoggingEvent $event) {
- $this->write($this->layout->format($event));
- }
-
- /**
- * Sets the 'file' parameter.
- * @param string $file
- */
- public function setFile($file) {
- $this->setString('file', $file);
- }
-
- /**
- * Returns the 'file' parameter.
- * @return string
- */
- public function getFile() {
- return $this->file;
- }
-
- /**
- * Returns the 'append' parameter.
- * @return boolean
- */
- public function getAppend() {
- return $this->append;
- }
-
- /**
- * Sets the 'append' parameter.
- * @param boolean $append
- */
- public function setAppend($append) {
- $this->setBoolean('append', $append);
- }
-
- /**
- * Sets the 'file' parmeter. Left for legacy reasons.
- * @param string $fileName
- * @deprecated Use setFile() instead.
- */
- public function setFileName($fileName) {
- $this->setFile($fileName);
- }
-
- /**
- * Returns the 'file' parmeter. Left for legacy reasons.
- * @return string
- * @deprecated Use getFile() instead.
- */
- public function getFileName() {
- return $this->getFile();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderFirePHP.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderFirePHP.php b/src/main/php/appenders/LoggerAppenderFirePHP.php
deleted file mode 100644
index b9ac76c..0000000
--- a/src/main/php/appenders/LoggerAppenderFirePHP.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Logs messages as HTTP headers using the FirePHP Insight API.
- *
- * This appender requires the FirePHP server library version 1.0 or later.
- *
- * ## Configurable parameters: ##
- *
- * - **target** - (string) The target to which messages will be sent. Possible options are
- * 'page' (default), 'request', 'package' and 'controller'. For more details,
- * see FirePHP documentation.
- *
- * This class was originally contributed by Bruce Ingalls (Bruce.Ingalls-at-gmail-dot-com).
- *
- * @link https://github.com/firephp/firephp FirePHP homepage.
- * @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Welcome FirePHP documentation.
- * @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Configuration/Constants FirePHP constants documentation.
- * @link http://logging.apache.org/log4php/docs/appenders/firephp.html Appender documentation
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @since 2.3
- */
-class LoggerAppenderFirePHP extends LoggerAppender {
-
- /**
- * Instance of the Insight console class.
- * @var Insight_Plugin_Console
- */
- protected $console;
-
- /**
- * The target for log messages. Possible values are: 'page' (default),
- * 'request', 'package' and 'contoller'.
- */
- protected $target = 'page';
-
- public function activateOptions() {
- if (method_exists('FirePHP', 'to')) {
- $this->console = FirePHP::to($this->target)->console();
- $this->closed = false;
- } else {
- $this->warn('FirePHP is not installed correctly. Closing appender.');
- }
- }
-
- public function append(LoggerLoggingEvent $event) {
- $msg = $event->getMessage();
-
- // Skip formatting for objects and arrays which are handled by FirePHP.
- if (!is_array($msg) && !is_object($msg)) {
- $msg = $this->getLayout()->format($event);
- }
-
- switch ($event->getLevel()->toInt()) {
- case LoggerLevel::TRACE:
- case LoggerLevel::DEBUG:
- $this->console->log($msg);
- break;
- case LoggerLevel::INFO:
- $this->console->info($msg);
- break;
- case LoggerLevel::WARN:
- $this->console->warn($msg);
- break;
- case LoggerLevel::ERROR:
- case LoggerLevel::FATAL:
- $this->console->error($msg);
- break;
- }
- }
-
- /** Returns the target. */
- public function getTarget() {
- return $this->target;
- }
-
- /** Sets the target. */
- public function setTarget($target) {
- $this->setString('target', $target);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderMail.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderMail.php b/src/main/php/appenders/LoggerAppenderMail.php
deleted file mode 100644
index efa3495..0000000
--- a/src/main/php/appenders/LoggerAppenderMail.php
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderMail appends log events via email.
- *
- * This appender does not send individual emails for each logging requests but
- * will collect them in a buffer and send them all in a single email once the
- * appender is closed (i.e. when the script exists). Because of this, it may
- * not appropriate for long running scripts, in which case
- * LoggerAppenderMailEvent might be a better choice.
- *
- * This appender uses a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **to** - Email address(es) to which the log will be sent. Multiple email
- * addresses may be specified by separating them with a comma.
- * - **from** - Email address which will be used in the From field.
- * - **subject** - Subject of the email message.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/mail.html Appender documentation
- */
-class LoggerAppenderMail extends LoggerAppender {
-
- /**
- * Email address to put in From field of the email.
- * @var string
- */
- protected $from = null;
-
- /**
- * The subject of the email.
- * @var string
- */
- protected $subject = 'Log4php Report';
-
- /**
- * One or more comma separated email addresses to which to send the email.
- * @var string
- */
- protected $to = null;
-
- /**
- * Indiciates whether this appender should run in dry mode.
- * @deprecated
- * @var boolean
- */
- protected $dry = false;
-
- /**
- * Buffer which holds the email contents before it is sent.
- * @var string
- */
- protected $body = '';
-
- public function append(LoggerLoggingEvent $event) {
- if($this->layout !== null) {
- $this->body .= $this->layout->format($event);
- }
- }
-
- public function close() {
- if($this->closed != true) {
- $from = $this->from;
- $to = $this->to;
-
- if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
- $subject = $this->subject;
- if(!$this->dry) {
- mail(
- $to, $subject,
- $this->layout->getHeader() . $this->body . $this->layout->getFooter(),
- "From: {$from}\r\n");
- } else {
- echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
- }
- }
- $this->closed = true;
- }
- }
-
- /** Sets the 'subject' parameter. */
- public function setSubject($subject) {
- $this->setString('subject', $subject);
- }
-
- /** Returns the 'subject' parameter. */
- public function getSubject() {
- return $this->subject;
- }
-
- /** Sets the 'to' parameter. */
- public function setTo($to) {
- $this->setString('to', $to);
- }
-
- /** Returns the 'to' parameter. */
- public function getTo() {
- return $this->to;
- }
-
- /** Sets the 'from' parameter. */
- public function setFrom($from) {
- $this->setString('from', $from);
- }
-
- /** Returns the 'from' parameter. */
- public function getFrom() {
- return $this->from;
- }
-
- /** Enables or disables dry mode. */
- public function setDry($dry) {
- $this->setBoolean('dry', $dry);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderMailEvent.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderMailEvent.php b/src/main/php/appenders/LoggerAppenderMailEvent.php
deleted file mode 100644
index f50adf8..0000000
--- a/src/main/php/appenders/LoggerAppenderMailEvent.php
+++ /dev/null
@@ -1,180 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderMailEvent appends individual log events via email.
- *
- * This appender is similar to LoggerAppenderMail, except that it sends each
- * each log event in an individual email message at the time when it occurs.
- *
- * This appender uses a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **to** - Email address(es) to which the log will be sent. Multiple email
- * addresses may be specified by separating them with a comma.
- * - **from** - Email address which will be used in the From field.
- * - **subject** - Subject of the email message.
- * - **smtpHost** - Used to override the SMTP server. Only works on Windows.
- * - **port** - Used to override the default SMTP server port. Only works on
- * Windows.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/mail-event.html Appender documentation
- */
-class LoggerAppenderMailEvent extends LoggerAppender {
-
- /**
- * Email address to put in From field of the email.
- * @var string
- */
- protected $from;
-
- /**
- * Mail server port (widnows only).
- * @var integer
- */
- protected $port = 25;
-
- /**
- * Mail server hostname (windows only).
- * @var string
- */
- protected $smtpHost;
-
- /**
- * The subject of the email.
- * @var string
- */
- protected $subject = 'Log4php Report';
-
- /**
- * One or more comma separated email addresses to which to send the email.
- * @var string
- */
- protected $to = null;
-
- /**
- * Indiciates whether this appender should run in dry mode.
- * @deprecated
- * @var boolean
- */
- protected $dry = false;
-
- public function activateOptions() {
- if (empty($this->to)) {
- $this->warn("Required parameter 'to' not set. Closing appender.");
- $this->close = true;
- return;
- }
-
- $sendmail_from = ini_get('sendmail_from');
- if (empty($this->from) and empty($sendmail_from)) {
- $this->warn("Required parameter 'from' not set. Closing appender.");
- $this->close = true;
- return;
- }
-
- $this->closed = false;
- }
-
- public function append(LoggerLoggingEvent $event) {
- $smtpHost = $this->smtpHost;
- $prevSmtpHost = ini_get('SMTP');
- if(!empty($smtpHost)) {
- ini_set('SMTP', $smtpHost);
- }
-
- $smtpPort = $this->port;
- $prevSmtpPort= ini_get('smtp_port');
- if($smtpPort > 0 and $smtpPort < 65535) {
- ini_set('smtp_port', $smtpPort);
- }
-
- // On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
-
- $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
-
- if(!$this->dry) {
- $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
- } else {
- echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
- }
-
- ini_set('SMTP', $prevSmtpHost);
- ini_set('smtp_port', $prevSmtpPort);
- }
-
- /** Sets the 'from' parameter. */
- public function setFrom($from) {
- $this->setString('from', $from);
- }
-
- /** Returns the 'from' parameter. */
- public function getFrom() {
- return $this->from;
- }
-
- /** Sets the 'port' parameter. */
- public function setPort($port) {
- $this->setPositiveInteger('port', $port);
- }
-
- /** Returns the 'port' parameter. */
- public function getPort() {
- return $this->port;
- }
-
- /** Sets the 'smtpHost' parameter. */
- public function setSmtpHost($smtpHost) {
- $this->setString('smtpHost', $smtpHost);
- }
-
- /** Returns the 'smtpHost' parameter. */
- public function getSmtpHost() {
- return $this->smtpHost;
- }
-
- /** Sets the 'subject' parameter. */
- public function setSubject($subject) {
- $this->setString('subject', $subject);
- }
-
- /** Returns the 'subject' parameter. */
- public function getSubject() {
- return $this->subject;
- }
-
- /** Sets the 'to' parameter. */
- public function setTo($to) {
- $this->setString('to', $to);
- }
-
- /** Returns the 'to' parameter. */
- public function getTo() {
- return $this->to;
- }
-
- /** Enables or disables dry mode. */
- public function setDry($dry) {
- $this->setBoolean('dry', $dry);
- }
-}
[39/43] git commit: Changed path to source files in apigen config
Posted by ih...@apache.org.
Changed path to source files in apigen config
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/759cd150
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/759cd150
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/759cd150
Branch: refs/heads/v3
Commit: 759cd150374b5d56f4460334ef2d7c9454883f09
Parents: 35dfd5d
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 14:42:28 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 14:42:28 2013 +0100
----------------------------------------------------------------------
apigen.neon | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/759cd150/apigen.neon
----------------------------------------------------------------------
diff --git a/apigen.neon b/apigen.neon
index e26db94..d4d7f85 100644
--- a/apigen.neon
+++ b/apigen.neon
@@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-source: src/main/php
-destination: target/site/apidocs
+source: src/
+destination: target/apidocs
charset: UTF-8
title: Apache log4php
progressbar: no
[25/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Helpers/FormattingInfo.php
----------------------------------------------------------------------
diff --git a/src/Helpers/FormattingInfo.php b/src/Helpers/FormattingInfo.php
new file mode 100644
index 0000000..9f2bb3b
--- /dev/null
+++ b/src/Helpers/FormattingInfo.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Helpers;
+
+/**
+ * This class encapsulates the information obtained when parsing
+ * formatting modifiers in conversion modifiers.
+ * @since 0.3
+ */
+class FormattingInfo {
+
+ /**
+ * Minimal output length. If output is shorter than this value, it will be
+ * padded with spaces.
+ */
+ public $min = 0;
+
+ /**
+ * Maximum output length. If output is longer than this value, it will be
+ * trimmed.
+ */
+ public $max = PHP_INT_MAX;
+
+ /**
+ * Whether to pad the string from the left. If set to false, the string
+ * will be padded from the right.
+ */
+ public $padLeft = true;
+
+ /**
+ * Whether to trim the string from the left. If set to false, the string
+ * will be trimmed from the right.
+ */
+ public $trimLeft = false;
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Helpers/OptionConverter.php
----------------------------------------------------------------------
diff --git a/src/Helpers/OptionConverter.php b/src/Helpers/OptionConverter.php
new file mode 100644
index 0000000..c496f02
--- /dev/null
+++ b/src/Helpers/OptionConverter.php
@@ -0,0 +1,225 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Helpers;
+
+use Apache\Log4php\Level;
+use Apache\Log4php\LoggerException;
+
+/**
+ * A convenience class to convert property values to specific types.
+ * @since 0.5
+ */
+class OptionConverter {
+
+ /** String values which are converted to boolean TRUE. */
+ private static $trueValues = array('1', 'true', 'yes', 'on');
+
+ /**
+ * String values which are converted to boolean FALSE.
+ *
+ * Note that an empty string must convert to false, because
+ * parse_ini_file() which is used for parsing configuration
+ * converts the value _false_ to an empty string.
+ */
+ private static $falseValues = array('0', 'false', 'no', 'off', '');
+
+ /**
+ * Read a predefined var.
+ *
+ * It returns a value referenced by <var>$key</var> using this search criteria:
+ * - if <var>$key</var> is a constant then return it. Else
+ * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
+ * - return <var>$def</var>.
+ *
+ * @param string $key The key to search for.
+ * @param string $def The default value to return.
+ * @return string the string value of the system property, or the default
+ * value if there is no property with that key.
+ */
+ public static function getSystemProperty($key, $def) {
+ if(defined($key)) {
+ return (string)constant($key);
+ } else if(isset($_SERVER[$key])) {
+ return (string)$_SERVER[$key];
+ } else if(isset($_ENV[$key])) {
+ return (string)$_ENV[$key];
+ } else {
+ return $def;
+ }
+ }
+
+ /** Converts $value to boolean, or throws an exception if not possible. */
+ public static function toBooleanEx($value) {
+ if (isset($value)) {
+ if (is_bool($value)) {
+ return $value;
+ }
+ $value = strtolower(trim($value));
+ if (in_array($value, self::$trueValues)) {
+ return true;
+ }
+ if (in_array($value, self::$falseValues)) {
+ return false;
+ }
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
+ }
+
+ /**
+ * Converts $value to integer, or throws an exception if not possible.
+ * Floats cannot be converted to integer.
+ */
+ public static function toIntegerEx($value) {
+ if (is_integer($value)) {
+ return $value;
+ }
+ if (is_numeric($value) && ($value == (integer) $value)) {
+ return (integer) $value;
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
+ }
+
+ /**
+ * Converts $value to integer, or throws an exception if not possible.
+ * Floats cannot be converted to integer.
+ */
+ public static function toPositiveIntegerEx($value) {
+ if (is_integer($value) && $value > 0) {
+ return $value;
+ }
+ if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
+ return (integer) $value;
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
+ }
+
+ /** Converts the value to a level. Throws an exception if not possible. */
+ public static function toLevelEx($value) {
+ if ($value instanceof Level) {
+ return $value;
+ }
+ $level = Level::toLevel($value);
+ if ($level === null) {
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
+ }
+ return $level;
+ }
+
+ /**
+ * Converts a value to a valid file size (integer).
+ *
+ * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
+ *
+ * The final value will be rounded to the nearest integer.
+ *
+ * Examples:
+ * - '100' => 100
+ * - '100.12' => 100
+ * - '100KB' => 102400
+ * - '1.5MB' => 1572864
+ *
+ * @param mixed $value File size (optionally with suffix).
+ * @return integer Parsed file size.
+ */
+ public static function toFileSizeEx($value) {
+
+ if (empty($value)) {
+ throw new LoggerException("Empty value cannot be converted to a file size.");
+ }
+
+ if (is_numeric($value)) {
+ return (integer) $value;
+ }
+
+ if (!is_string($value)) {
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
+ }
+
+ $str = strtoupper(trim($value));
+ $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
+
+ if ($count > 0) {
+ $size = $matches[1];
+ $unit = $matches[2];
+
+ switch($unit) {
+ case 'KB': $size *= pow(1024, 1); break;
+ case 'MB': $size *= pow(1024, 2); break;
+ case 'GB': $size *= pow(1024, 3); break;
+ }
+
+ return (integer) $size;
+ }
+
+ throw new LoggerException("Given value [$value] cannot be converted to a file size.");
+ }
+
+ /**
+ * Converts a value to string, or throws an exception if not possible.
+ *
+ * Objects can be converted to string if they implement the magic
+ * __toString() method.
+ *
+ */
+ public static function toStringEx($value) {
+ if (is_string($value)) {
+ return $value;
+ }
+ if (is_numeric($value)) {
+ return (string) $value;
+ }
+ if (is_object($value) && method_exists($value, '__toString')) {
+ return (string) $value;
+ }
+
+ throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
+ }
+
+ /**
+ * Performs value substitution for string options.
+ *
+ * An option can contain PHP constants delimited by '${' and '}'.
+ *
+ * E.g. for input string "some ${FOO} value", the method will attempt
+ * to substitute ${FOO} with the value of constant FOO if it exists.
+ *
+ * Therefore, if FOO is a constant, and it has value "bar", the resulting
+ * string will be "some bar value".
+ *
+ * If the constant is not defined, it will be replaced by an empty string,
+ * and the resulting string will be "some value".
+ *
+ * @param string $string String on which to perform substitution.
+ * @return string
+ */
+ public static function substConstants($string) {
+ preg_match_all('/\${([^}]+)}/', $string, $matches);
+
+ foreach($matches[1] as $key => $match) {
+ $match = trim($match);
+ $search = $matches[0][$key];
+ $replacement = defined($match) ? constant($match) : '';
+ $string = str_replace($search, $replacement, $string);
+ }
+ return $string;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Helpers/PatternParser.php
----------------------------------------------------------------------
diff --git a/src/Helpers/PatternParser.php b/src/Helpers/PatternParser.php
new file mode 100644
index 0000000..7e98a55
--- /dev/null
+++ b/src/Helpers/PatternParser.php
@@ -0,0 +1,245 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Helpers;
+
+use Apache\Log4php\LoggerException;
+use Apache\Log4php\Pattern\AbstractConverter;
+use Apache\Log4php\Pattern\LiteralConverter;
+
+/**
+ * Most of the work of the {@link LoggerPatternLayout} class
+ * is delegated to the {@link PatternParser} class.
+ *
+ * <p>It is this class that parses conversion patterns and creates
+ * a chained list of {@link AbstractConverter} converters.</p>
+ *
+ * @since 0.3
+ */
+class PatternParser {
+
+ /** Escape character for conversion words in the conversion pattern. */
+ const ESCAPE_CHAR = '%';
+
+ /** Maps conversion words to relevant converters. */
+ private $converterMap;
+
+ /** Conversion pattern used in layout. */
+ private $pattern;
+
+ /** Regex pattern used for parsing the conversion pattern. */
+ private $regex;
+
+ /**
+ * First converter in the chain.
+ * @var AbstractConverter
+ */
+ private $head;
+
+ /** Last converter in the chain. */
+ private $tail;
+
+ public function __construct($pattern, $converterMap) {
+ $this->pattern = $pattern;
+ $this->converterMap = $converterMap;
+
+ // Construct the regex pattern
+ $this->regex =
+ '/' . // Starting regex pattern delimiter
+ self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern
+ '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
+ '(?P<word>[a-zA-Z]+)' . // The conversion word
+ '(?P<option>{[^}]*})?' . // Conversion option in braces (optional)
+ '/'; // Ending regex pattern delimiter
+ }
+
+ /**
+ * Parses the conversion pattern string, converts it to a chain of pattern
+ * converters and returns the first converter in the chain.
+ *
+ * @return AbstractConverter
+ */
+ public function parse() {
+
+ // Skip parsing if the pattern is empty
+ if (empty($this->pattern)) {
+ $this->addLiteral('');
+ return $this->head;
+ }
+
+ // Find all conversion words in the conversion pattern
+ $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
+ if ($count === false) {
+ $error = error_get_last();
+ throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
+ }
+
+ $prevEnd = 0;
+
+ foreach($matches[0] as $key => $item) {
+
+ // Locate where the conversion command starts and ends
+ $length = strlen($item[0]);
+ $start = $item[1];
+ $end = $item[1] + $length;
+
+ // Find any literal expressions between matched commands
+ if ($start > $prevEnd) {
+ $literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
+ $this->addLiteral($literal);
+ }
+
+ // Extract the data from the matched command
+ $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
+ $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
+ $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
+
+ // Create a converter and add it to the chain
+ $this->addConverter($word, $modifiers, $option);
+
+ $prevEnd = $end;
+ }
+
+ // Add any trailing literals
+ if ($end < strlen($this->pattern)) {
+ $literal = substr($this->pattern, $end);
+ $this->addLiteral($literal);
+ }
+
+ return $this->head;
+ }
+
+ /**
+ * Adds a literal converter to the converter chain.
+ * @param string $string The string for the literal converter.
+ */
+ private function addLiteral($string) {
+ $converter = new LiteralConverter($string);
+ $this->addToChain($converter);
+ }
+
+ /**
+ * Adds a non-literal converter to the converter chain.
+ *
+ * @param string $word The conversion word, used to determine which
+ * converter will be used.
+ * @param string $modifiers Formatting modifiers.
+ * @param string $option Option to pass to the converter.
+ */
+ private function addConverter($word, $modifiers, $option) {
+ $formattingInfo = $this->parseModifiers($modifiers);
+ $option = trim($option, "{} ");
+
+ if (isset($this->converterMap[$word])) {
+ $converter = $this->getConverter($word, $formattingInfo, $option);
+ $this->addToChain($converter);
+ } else {
+ trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
+ }
+ }
+
+ /**
+ * Determines which converter to use based on the conversion word. Creates
+ * an instance of the converter using the provided formatting info and
+ * option and returns it.
+ *
+ * @param string $word The conversion word.
+ * @param FormattingInfo $info Formatting info.
+ * @param string $option Converter option.
+ *
+ * @throws LoggerException
+ *
+ * @return AbstractConverter
+ */
+ private function getConverter($word, $info, $option) {
+ if (!isset($this->converterMap[$word])) {
+ throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
+ }
+
+ $class = $this->converterMap[$word];
+ if (class_exists($class)) {
+ $converter = new $class($info, $option);
+ } else {
+ $nsClass = "Apache\\Log4php\\Pattern\\$class";
+ if (class_exists($nsClass)) {
+ $converter = new $nsClass($info, $option);
+ }
+ }
+
+ if (!isset($converter)) {
+ throw new LoggerException("Class '$class' does not exist.");
+ }
+
+ if(!($converter instanceof AbstractConverter)) {
+ throw new LoggerException("Class '$class' is not an instance of AbstractConverter.");
+ }
+
+ return $converter;
+ }
+
+ /** Adds a converter to the chain and updates $head and $tail pointers. */
+ private function addToChain(AbstractConverter $converter) {
+ if (!isset($this->head)) {
+ $this->head = $converter;
+ $this->tail = $this->head;
+ } else {
+ $this->tail->next = $converter;
+ $this->tail = $this->tail->next;
+ }
+ }
+
+ /**
+ * Parses the formatting modifiers and produces the corresponding
+ * FormattingInfo object.
+ *
+ * @param string $modifier
+ * @return FormattingInfo
+ * @throws LoggerException
+ */
+ private function parseModifiers($modifiers) {
+ $info = new FormattingInfo();
+
+ // If no modifiers are given, return default values
+ if (empty($modifiers)) {
+ return $info;
+ }
+
+ // Validate
+ $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
+ if (!preg_match($pattern, $modifiers)) {
+ trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
+ return $info;
+ }
+
+ $parts = explode('.', $modifiers);
+
+ if (!empty($parts[0])) {
+ $minPart = (integer) $parts[0];
+ $info->min = abs($minPart);
+ $info->padLeft = ($minPart > 0);
+ }
+
+ if (!empty($parts[1])) {
+ $maxPart = (integer) $parts[1];
+ $info->max = abs($maxPart);
+ $info->trimLeft = ($maxPart < 0);
+ }
+
+ return $info;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Helpers/Utils.php
----------------------------------------------------------------------
diff --git a/src/Helpers/Utils.php b/src/Helpers/Utils.php
new file mode 100644
index 0000000..52be24d
--- /dev/null
+++ b/src/Helpers/Utils.php
@@ -0,0 +1,120 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Helpers;
+
+/**
+ * Contains various helper methods.
+ * @since 2.3
+ */
+class Utils {
+
+ /**
+ * Splits a fully qualified class name into fragments delimited by the
+ * namespace separator (\).
+ *
+ * For backward compatibility, a dot (.) can be used as a delimiter as
+ * well.
+ *
+ * @param string $name
+ *
+ * @return array Class name split into fragments.
+ */
+ public static function tokenizeClassName($name) {
+ $name = str_replace('.', '\\', $name);
+ $name = trim($name, ' \\');
+ $fragments = explode('\\', $name);
+
+ foreach($fragments as $key => $fragment) {
+ if (trim($fragment) === '') {
+ unset($fragments[$key]);
+ }
+ }
+
+ return $fragments;
+ }
+
+ /**
+ * Attempts to shorten the given class name to the desired length.
+ *
+ * This is done by separating the class name into fragments (delimited
+ * by \ or .) and trimming individual fragments, starting with the left,
+ * until desired length has been reached.
+ *
+ * The final fragment (i.e. class name) will never be shortened so the
+ * result may still be longer than given length.
+ *
+ * @param string $name The (qualified) class name.
+ * @param integer $length The length to shorten to. If null or 0 is given,
+ * the name will be returned without shortening.
+ */
+ public static function shortenClassName($name, $length) {
+ if ($length === null || $length < 0) {
+ return $name;
+ }
+
+ $name = str_replace('.', '\\', $name);
+ $name = trim($name, ' \\');
+
+ // Check if any shortening is required
+ $currentLength = strlen($name);
+ if ($currentLength <= $length) {
+ return $name;
+ }
+
+ // Split name into fragments
+ $fragments = explode('\\', $name);
+
+ // If zero length is specified, return only last fragment
+ if ($length == 0) {
+ return array_pop($fragments);
+ }
+
+ // If the name splits to only one fragment, then it cannot be shortened
+ $count = count($fragments);
+ if ($count == 1) {
+ return $name;
+ }
+
+ foreach($fragments as $key => &$fragment) {
+
+ // Never shorten last fragment
+ if ($key == $count - 1) {
+ break;
+ }
+
+ // Check for empty fragments (shouldn't happen but it's possible)
+ $fragLen = strlen($fragment);
+ if ($fragLen <= 1) {
+ continue;
+ }
+
+ // Shorten fragment to one character and check if total length satisfactory
+ $fragment = substr($fragment, 0, 1);
+ $currentLength = $currentLength - $fragLen + 1;
+
+ if ($currentLength <= $length) {
+ break;
+ }
+ }
+ unset($fragment);
+
+ return implode('\\', $fragments);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Hierarchy.php
----------------------------------------------------------------------
diff --git a/src/Hierarchy.php b/src/Hierarchy.php
new file mode 100644
index 0000000..7b28a6b
--- /dev/null
+++ b/src/Hierarchy.php
@@ -0,0 +1,256 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+use Apache\Log4php\Renderers\RendererMap;
+
+/**
+ * This class is specialized in retrieving loggers by name and also maintaining
+ * the logger hierarchy. The logger hierarchy is dealing with the several Log-Levels
+ * Logger can have. From log4j website:
+ *
+ * "A logger is said to be an ancestor of another logger if its name followed
+ * by a dot is a prefix of the descendant logger name. A logger is said to be
+ * a parent of a child logger if there are no ancestors between itself and the
+ * descendant logger."
+ *
+ * Child Loggers do inherit their Log-Levels from their Ancestors. They can
+ * increase their Log-Level compared to their Ancestors, but they cannot decrease it.
+ *
+ * <p>The casual user does not have to deal with this class directly.</p>
+ *
+ * <p>The structure of the logger hierarchy is maintained by the
+ * getLogger method. The hierarchy is such that children link
+ * to their parent but parents do not have any pointers to their
+ * children. Moreover, loggers can be instantiated in any order, in
+ * particular descendant before ancestor.</p>
+ *
+ * <p>In case a descendant is created before a particular ancestor,
+ * then it creates a provision node for the ancestor and adds itself
+ * to the provision node. Other descendants of the same ancestor add
+ * themselves to the previously created provision node.</p>
+ */
+class Hierarchy {
+
+ /** Array holding all Logger instances. */
+ protected $loggers = array();
+
+ /**
+ * The root logger.
+ * @var RootLogger
+ */
+ protected $root;
+
+ /**
+ * The logger renderer map.
+ * @var RendererMap
+ */
+ protected $rendererMap;
+
+ /**
+ * Main level threshold. Events with lower level will not be logged by any
+ * logger, regardless of it's configuration.
+ * @var Level
+ */
+ protected $threshold;
+
+ /**
+ * Creates a new logger hierarchy.
+ * @param RootLogger $root The root logger.
+ */
+ public function __construct(RootLogger $root) {
+ $this->root = $root;
+ $this->setThreshold(Level::getLevelAll());
+ $this->rendererMap = new RendererMap();
+ }
+
+ /**
+ * Clears all loggers.
+ */
+ public function clear() {
+ $this->loggers = array();
+ }
+
+ /**
+ * Check if the named logger exists in the hierarchy.
+ * @param string $name
+ * @return boolean
+ */
+ public function exists($name) {
+ return isset($this->loggers[$name]);
+ }
+
+ /**
+ * Returns all the currently defined loggers in this hierarchy as an array.
+ * @return array
+ */
+ public function getCurrentLoggers() {
+ return array_values($this->loggers);
+ }
+
+ /**
+ * Returns a named logger instance logger. If it doesn't exist, one is created.
+ *
+ * @param string $name Logger name
+ * @return Logger Logger instance.
+ */
+ public function getLogger($name) {
+ if(!isset($this->loggers[$name])) {
+ $logger = new Logger($name);
+
+ $nodes = explode('.', $name);
+ $firstNode = array_shift($nodes);
+
+ // if name is not a first node but another first node is their
+ if($firstNode != $name and isset($this->loggers[$firstNode])) {
+ $logger->setParent($this->loggers[$firstNode]);
+ } else {
+ // if there is no father, set root logger as father
+ $logger->setParent($this->root);
+ }
+
+ // if there are more nodes than one
+ if(count($nodes) > 0) {
+ // find parent node
+ foreach($nodes as $node) {
+ $parentNode = "$firstNode.$node";
+ if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
+ $logger->setParent($this->loggers[$parentNode]);
+ }
+ $firstNode .= ".$node";
+ }
+ }
+
+ $this->loggers[$name] = $logger;
+ }
+
+ return $this->loggers[$name];
+ }
+
+ /**
+ * Returns the logger renderer map.
+ * @return RendererMap
+ */
+ public function getRendererMap() {
+ return $this->rendererMap;
+ }
+
+ /**
+ * Returns the root logger.
+ * @return RootLogger
+ */
+ public function getRootLogger() {
+ return $this->root;
+ }
+
+ /**
+ * Returns the main threshold level.
+ * @return Level
+ */
+ public function getThreshold() {
+ return $this->threshold;
+ }
+
+ /**
+ * Returns true if the hierarchy is disabled for given log level and false
+ * otherwise.
+ * @return boolean
+ */
+ public function isDisabled(Level $level) {
+ return ($this->threshold->toInt() > $level->toInt());
+ }
+
+ /**
+ * Reset all values contained in this hierarchy instance to their
+ * default.
+ *
+ * This removes all appenders from all loggers, sets
+ * the level of all non-root loggers to <i>null</i>,
+ * sets their additivity flag to <i>true</i> and sets the level
+ * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
+ *
+ * <p>Existing loggers are not removed. They are just reset.
+ *
+ * <p>This method should be used sparingly and with care as it will
+ * block all logging until it is completed.</p>
+ */
+ public function resetConfiguration() {
+ $root = $this->getRootLogger();
+
+ $root->setLevel(Level::getLevelDebug());
+ $this->setThreshold(Level::getLevelAll());
+ $this->shutDown();
+
+ foreach($this->loggers as $logger) {
+ $logger->setLevel(null);
+ $logger->setAdditivity(true);
+ $logger->removeAllAppenders();
+ }
+
+ $this->rendererMap->reset();
+ AppenderPool::clear();
+ }
+
+ /**
+ * Sets the main threshold level.
+ * @param Level $l
+ */
+ public function setThreshold(Level $threshold) {
+ $this->threshold = $threshold;
+ }
+
+ /**
+ * Shutting down a hierarchy will <i>safely</i> close and remove
+ * all appenders in all loggers including the root logger.
+ *
+ * The shutdown method is careful to close nested
+ * appenders before closing regular appenders. This is allows
+ * configurations where a regular appender is attached to a logger
+ * and again to a nested appender.
+ *
+ * @todo Check if the last paragraph is correct.
+ */
+ public function shutdown() {
+ $this->root->removeAllAppenders();
+
+ foreach($this->loggers as $logger) {
+ $logger->removeAllAppenders();
+ }
+ }
+
+ /**
+ * Prints the current Logger hierarchy tree. Useful for debugging.
+ */
+ public function printHierarchy() {
+ $this->printHierarchyInner($this->getRootLogger(), 0);
+ }
+
+ private function printHierarchyInner(Logger $current, $level) {
+ for ($i = 0; $i < $level; $i++) {
+ echo ($i == $level - 1) ? "|--" : "| ";
+ }
+ echo $current->getName() . "\n";
+
+ foreach($this->loggers as $logger) {
+ if ($logger->getParent() == $current) {
+ $this->printHierarchyInner($logger, $level + 1);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Layouts/AbstractLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/AbstractLayout.php b/src/Layouts/AbstractLayout.php
new file mode 100644
index 0000000..b6a2d14
--- /dev/null
+++ b/src/Layouts/AbstractLayout.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Layouts;
+
+use Apache\Log4php\Configurable;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Extend this abstract class to create your own log layout format.
+ */
+abstract class AbstractLayout extends Configurable {
+ /**
+ * Activates options for this layout.
+ * Override this method if you have options to be activated.
+ */
+ public function activateOptions() {
+ return true;
+ }
+
+ /**
+ * Override this method to create your own layout format.
+ *
+ * @param LoggingEvent
+ * @return string
+ */
+ public function format(LoggingEvent $event) {
+ return $event->getRenderedMessage();
+ }
+
+ /**
+ * Returns the content type output by this layout.
+ * @return string
+ */
+ public function getContentType() {
+ return "text/plain";
+ }
+
+ /**
+ * Returns the footer for the layout format.
+ * @return string
+ */
+ public function getFooter() {
+ return null;
+ }
+
+ /**
+ * Returns the header for the layout format.
+ * @return string
+ */
+ public function getHeader() {
+ return null;
+ }
+
+ /** Triggers a warning for this layout with the given message. */
+ protected function warn($message) {
+ trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Layouts/HtmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/HtmlLayout.php b/src/Layouts/HtmlLayout.php
new file mode 100644
index 0000000..af74e61
--- /dev/null
+++ b/src/Layouts/HtmlLayout.php
@@ -0,0 +1,197 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Layouts;
+
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Level;
+
+/**
+ * This layout outputs events in a HTML table.
+ *
+ * Configurable parameters for this layout are:
+ *
+ * - title
+ * - locationInfo
+ */
+class HtmlLayout extends AbstractLayout {
+ /**
+ * The <b>LocationInfo</b> option takes a boolean value. By
+ * default, it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement
+ * at the origin of the log statement will be output.
+ *
+ * <p>If you are embedding this layout within a {@link MailAppender}
+ * or a {@link MailEventAppender} then make sure to set the
+ * <b>LocationInfo</b> option of that appender as well.
+ * @var boolean
+ */
+ protected $locationInfo = false;
+
+ /**
+ * The <b>Title</b> option takes a String value. This option sets the
+ * document title of the generated HTML document.
+ * Defaults to 'Log4php Log Messages'.
+ * @var string
+ */
+ protected $title = "Log4php Log Messages";
+
+ /**
+ * The <b>LocationInfo</b> option takes a boolean value. By
+ * default, it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement
+ * at the origin of the log statement will be output.
+ *
+ * <p>If you are embedding this layout within a {@link MailAppender}
+ * or a {@link MailEventAppender} then make sure to set the
+ * <b>LocationInfo</b> option of that appender as well.
+ */
+ public function setLocationInfo($flag) {
+ $this->setBoolean('locationInfo', $flag);
+ }
+
+ /**
+ * Returns the current value of the <b>LocationInfo</b> option.
+ */
+ public function getLocationInfo() {
+ return $this->locationInfo;
+ }
+
+ /**
+ * The <b>Title</b> option takes a String value. This option sets the
+ * document title of the generated HTML document.
+ * Defaults to 'Log4php Log Messages'.
+ */
+ public function setTitle($title) {
+ $this->setString('title', $title);
+ }
+
+ /**
+ * @return string Returns the current value of the <b>Title</b> option.
+ */
+ public function getTitle() {
+ return $this->title;
+ }
+
+ /**
+ * @return string Returns the content type output by this layout, i.e "text/html".
+ */
+ public function getContentType() {
+ return "text/html";
+ }
+
+ /**
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event) {
+ $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
+
+ $sbuf .= "<td>";
+ $sbuf .= round(1000 * $event->getRelativeTime());
+ $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(Level::getLevelDebug())) {
+ $sbuf .= "<font color=\"#339933\">$level</font>";
+ } else if ($level->equals(Level::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;
+ }
+
+ /**
+ * @return string Returns appropriate HTML headers.
+ */
+ public function getHeader() {
+ $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
+ $sbuf .= "<html>" . PHP_EOL;
+ $sbuf .= "<head>" . PHP_EOL;
+ $sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
+ $sbuf .= "<style type=\"text/css\">" . PHP_EOL;
+ $sbuf .= "<!--" . PHP_EOL;
+ $sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
+ $sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
+ $sbuf .= "-->" . PHP_EOL;
+ $sbuf .= "</style>" . PHP_EOL;
+ $sbuf .= "</head>" . PHP_EOL;
+ $sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
+ $sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
+ $sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
+ $sbuf .= "<br>" . PHP_EOL;
+ $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
+ $sbuf .= "<tr>" . PHP_EOL;
+ $sbuf .= "<th>Time</th>" . PHP_EOL;
+ $sbuf .= "<th>Thread</th>" . PHP_EOL;
+ $sbuf .= "<th>Level</th>" . PHP_EOL;
+ $sbuf .= "<th>Category</th>" . PHP_EOL;
+ if ($this->locationInfo) {
+ $sbuf .= "<th>File:Line</th>" . PHP_EOL;
+ }
+ $sbuf .= "<th>Message</th>" . PHP_EOL;
+ $sbuf .= "</tr>" . PHP_EOL;
+
+ return $sbuf;
+ }
+
+ /**
+ * @return string Returns the appropriate HTML footers.
+ */
+ public function getFooter() {
+ $sbuf = "</table>" . PHP_EOL;
+ $sbuf .= "<br>" . PHP_EOL;
+ $sbuf .= "</body></html>";
+
+ return $sbuf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Layouts/PatternLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/PatternLayout.php b/src/Layouts/PatternLayout.php
new file mode 100644
index 0000000..c34cbe2
--- /dev/null
+++ b/src/Layouts/PatternLayout.php
@@ -0,0 +1,171 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Layouts;
+
+use Apache\Log4php\Helpers\PatternParser;
+use Apache\Log4php\LoggerException;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * A flexible layout configurable with a pattern string.
+ *
+ * Configurable parameters:
+ *
+ * * converionPattern - A string which controls the formatting of logging
+ * events. See docs for full specification.
+ */
+class PatternLayout extends AbstractLayout {
+
+ /** Default conversion pattern */
+ const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
+
+ /** Default conversion TTCC Pattern */
+ const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
+
+ /** The conversion pattern. */
+ protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
+
+ /** Maps conversion keywords to the relevant converter (default implementation). */
+ protected static $defaultConverterMap = array(
+ 'c' => 'LoggerConverter',
+ 'lo' => 'LoggerConverter',
+ 'logger' => 'LoggerConverter',
+
+ 'C' => 'ClassConverter',
+ 'class' => 'ClassConverter',
+
+ 'cookie' => 'CookieConverter',
+
+ 'd' => 'DateConverter',
+ 'date' => 'DateConverter',
+
+ 'e' => 'EnvironmentConverter',
+ 'env' => 'EnvironmentConverter',
+
+ 'ex' => 'ThrowableConverter',
+ 'exception' => 'ThrowableConverter',
+ 'throwable' => 'ThrowableConverter',
+
+ 'F' => 'FileConverter',
+ 'file' => 'FileConverter',
+
+ 'l' => 'LocationConverter',
+ 'location' => 'LocationConverter',
+
+ 'L' => 'LineConverter',
+ 'line' => 'LineConverter',
+
+ 'm' => 'MessageConverter',
+ 'msg' => 'MessageConverter',
+ 'message' => 'MessageConverter',
+
+ 'M' => 'MethodConverter',
+ 'method' => 'MethodConverter',
+
+ 'n' => 'NewLineConverter',
+ 'newline' => 'NewLineConverter',
+
+ 'p' => 'LevelConverter',
+ 'le' => 'LevelConverter',
+ 'level' => 'LevelConverter',
+
+ 'r' => 'RelativeConverter',
+ 'relative' => 'RelativeConverter',
+
+ 'req' => 'RequestConverter',
+ 'request' => 'RequestConverter',
+
+ 's' => 'ServerConverter',
+ 'server' => 'ServerConverter',
+
+ 'ses' => 'SessionConverter',
+ 'session' => 'SessionConverter',
+
+ 'sid' => 'SessionIdConverter',
+ 'sessionid' => 'SessionIdConverter',
+
+ 't' => 'ProcessConverter',
+ 'pid' => 'ProcessConverter',
+ 'process' => 'ProcessConverter',
+
+ 'x' => 'NdcConverter',
+ 'ndc' => 'NdcConverter',
+
+ 'X' => 'MdcConverter',
+ 'mdc' => 'MdcConverter',
+ );
+
+ /** Maps conversion keywords to the relevant converter. */
+ protected $converterMap = array();
+
+ /**
+ * Head of a chain of Converters.
+ * @var AbstractConverter
+ */
+ private $head;
+
+ /** Returns the default converter map. */
+ public static function getDefaultConverterMap() {
+ return self::$defaultConverterMap;
+ }
+
+ /** Constructor. Initializes the converter map. */
+ public function __construct() {
+ $this->converterMap = self::$defaultConverterMap;
+ }
+
+ /**
+ * Sets the conversionPattern option. This is the string which
+ * controls formatting and consists of a mix of literal content and
+ * conversion specifiers.
+ * @param array $conversionPattern
+ */
+ public function setConversionPattern($conversionPattern) {
+ $this->pattern = $conversionPattern;
+ }
+
+ /**
+ * 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 PatternParser($this->pattern, $this->converterMap);
+ $this->head = $parser->parse();
+ }
+
+ /**
+ * Produces a formatted string as specified by the conversion pattern.
+ *
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event) {
+ $sbuf = '';
+ $converter = $this->head;
+ while ($converter !== null) {
+ $converter->format($sbuf, $event);
+ $converter = $converter->next;
+ }
+ return $sbuf;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Layouts/SerializedLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SerializedLayout.php b/src/Layouts/SerializedLayout.php
new file mode 100644
index 0000000..5273c3b
--- /dev/null
+++ b/src/Layouts/SerializedLayout.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Layouts;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Layout which formats the events using PHP's serialize() function.
+ *
+ * Available options:
+ * - locationInfo - If set to true, the event's location information will also
+ * be serialized (slow, defaults to false).
+ * @since 2.2
+ */
+class SerializedLayout extends AbstractLayout {
+
+ /** Whether to include the event's location information (slow). */
+ protected $locationInfo = false;
+
+ /** Sets the location information flag. */
+ public function setLocationInfo($value) {
+ $this->setBoolean('locationInfo', $value);
+ }
+
+ /** Returns the location information flag. */
+ public function getLocationInfo() {
+ return $this->locationInfo;
+ }
+
+ public function format(LoggingEvent $event) {
+ // If required, initialize the location data
+ if($this->locationInfo) {
+ $event->getLocationInformation();
+ }
+ return serialize($event) . PHP_EOL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Layouts/SimpleLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/SimpleLayout.php b/src/Layouts/SimpleLayout.php
new file mode 100644
index 0000000..16645f3
--- /dev/null
+++ b/src/Layouts/SimpleLayout.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Layouts;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * A simple layout.
+ *
+ * Returns the log statement in a format consisting of the
+ * <b>level</b>, followed by " - " and then the <b>message</b>.
+ */
+class SimpleLayout extends AbstractLayout {
+ /**
+ * Returns the log statement in a format consisting of the
+ * <b>level</b>, followed by " - " and then the
+ * <b>message</b>. For example,
+ * <samp> INFO - "A message" </samp>
+ *
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event) {
+ $level = $event->getLevel();
+ $message = $event->getRenderedMessage();
+ return "$level - $message" . PHP_EOL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Layouts/XmlLayout.php
----------------------------------------------------------------------
diff --git a/src/Layouts/XmlLayout.php b/src/Layouts/XmlLayout.php
new file mode 100644
index 0000000..0ada386
--- /dev/null
+++ b/src/Layouts/XmlLayout.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php\Layouts;
+
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * The output of the LoggerXmlLayout consists of a series of log4php:event elements.
+ *
+ * Configurable parameters:
+ * - {@link $locationInfo} - If set to true then the file name and line number
+ * of the origin of the log statement will be included in output.
+ * - {@link $log4jNamespace} - If set to true then log4j namespace will be used
+ * instead of log4php namespace. This can be usefull when using log viewers
+ * which can only parse the log4j namespace such as Apache Chainsaw.
+ *
+ * <p>It does not output a complete well-formed XML file.
+ * The output is designed to be included as an external entity in a separate file to form
+ * a correct XML file.</p>
+ *
+ */
+class XmlLayout extends AbstractLayout {
+ const LOG4J_NS_PREFIX ='log4j';
+ const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
+
+ const LOG4PHP_NS_PREFIX = 'log4php';
+ const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
+
+ const CDATA_START = '<![CDATA[';
+ const CDATA_END = ']]>';
+ const CDATA_PSEUDO_END = ']]>';
+ const CDATA_EMBEDDED_END = ']]>]]><![CDATA[';
+
+ /**
+ * If set to true then the file name and line number of the origin of the
+ * log statement will be output.
+ * @var boolean
+ */
+ protected $locationInfo = true;
+
+ /**
+ * If set to true, log4j namespace will be used instead of the log4php
+ * namespace.
+ * @var boolean
+ */
+ protected $log4jNamespace = false;
+
+ /** The namespace in use. */
+ protected $namespace = self::LOG4PHP_NS;
+
+ /** The namespace prefix in use */
+ protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
+
+ public function activateOptions() {
+ if ($this->getLog4jNamespace()) {
+ $this->namespace = self::LOG4J_NS;
+ $this->namespacePrefix = self::LOG4J_NS_PREFIX;
+ } else {
+ $this->namespace = self::LOG4PHP_NS;
+ $this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function getHeader() {
+ return "<{$this->namespacePrefix}:eventSet ".
+ "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
+ "version=\"0.3\" ".
+ "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
+ ">" . PHP_EOL;
+ }
+
+ /**
+ * Formats a {@link LoggingEvent} in conformance with the log4php.dtd.
+ *
+ * @param LoggingEvent $event
+ * @return string
+ */
+ public function format(LoggingEvent $event) {
+ $ns = $this->namespacePrefix;
+
+ $loggerName = $event->getLoggerName();
+ $timeStamp = number_format((float)($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;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFooter() {
+ return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
+ }
+
+
+ /**
+ * Whether or not file name and line number will be included in the output.
+ * @return boolean
+ */
+ public function getLocationInfo() {
+ return $this->locationInfo;
+ }
+
+ /**
+ * The {@link $locationInfo} option takes a boolean value. By default,
+ * it is set to false which means there will be no location
+ * information output by this layout. If the the option is set to
+ * true, then the file name and line number of the statement at the
+ * origin of the log statement will be output.
+ */
+ public function setLocationInfo($flag) {
+ $this->setBoolean('locationInfo', $flag);
+ }
+
+ /**
+ * @return boolean
+ */
+ public function getLog4jNamespace() {
+ return $this->log4jNamespace;
+ }
+
+ /**
+ * @param boolean
+ */
+ public function setLog4jNamespace($flag) {
+ $this->setBoolean('log4jNamespace', $flag);
+ }
+
+ /**
+ * Encases a string in CDATA tags, and escapes any existing CDATA end
+ * tags already present in the string.
+ * @param string $string
+ */
+ private function encodeCDATA($string) {
+ $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
+ return self::CDATA_START . $string . self::CDATA_END;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Level.php
----------------------------------------------------------------------
diff --git a/src/Level.php b/src/Level.php
new file mode 100644
index 0000000..f17f0fc
--- /dev/null
+++ b/src/Level.php
@@ -0,0 +1,253 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * Defines the minimum set of levels recognized by the system, that is
+ * <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
+ * <i>WARN</i>, <i>INFO</i>, <i>DEBUG</i> and
+ * <i>ALL</i>.
+ *
+ * <p>The <i>Level</i> class may be subclassed to define a larger
+ * level set.</p>
+ * @since 0.5
+ */
+class Level {
+
+ const OFF = 2147483647;
+ const FATAL = 50000;
+ const ERROR = 40000;
+ const WARN = 30000;
+ const INFO = 20000;
+ const DEBUG = 10000;
+ const TRACE = 5000;
+ const ALL = -2147483647;
+
+ /** Integer level value. */
+ private $level;
+
+ /** Contains a list of instantiated levels. */
+ private static $levelMap;
+
+ /** String representation of the level. */
+ private $levelStr;
+
+ /**
+ * Equivalent syslog level.
+ * @var integer
+ */
+ private $syslogEquivalent;
+
+ /**
+ * Constructor
+ *
+ * @param integer $level
+ * @param string $levelStr
+ * @param integer $syslogEquivalent
+ */
+ private function __construct($level, $levelStr, $syslogEquivalent) {
+ $this->level = $level;
+ $this->levelStr = $levelStr;
+ $this->syslogEquivalent = $syslogEquivalent;
+ }
+
+ /**
+ * Compares two logger levels.
+ *
+ * @param Level $other
+ * @return boolean
+ */
+ public function equals($other) {
+ if($other instanceof Level) {
+ if($this->level == $other->level) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns an Off Level
+ * @return Level
+ */
+ public static function getLevelOff() {
+ if(!isset(self::$levelMap[Level::OFF])) {
+ self::$levelMap[Level::OFF] = new Level(Level::OFF, 'OFF', LOG_ALERT);
+ }
+ return self::$levelMap[Level::OFF];
+ }
+
+ /**
+ * Returns a Fatal Level
+ * @return Level
+ */
+ public static function getLevelFatal() {
+ if(!isset(self::$levelMap[Level::FATAL])) {
+ self::$levelMap[Level::FATAL] = new Level(Level::FATAL, 'FATAL', LOG_ALERT);
+ }
+ return self::$levelMap[Level::FATAL];
+ }
+
+ /**
+ * Returns an Error Level
+ * @return Level
+ */
+ public static function getLevelError() {
+ if(!isset(self::$levelMap[Level::ERROR])) {
+ self::$levelMap[Level::ERROR] = new Level(Level::ERROR, 'ERROR', LOG_ERR);
+ }
+ return self::$levelMap[Level::ERROR];
+ }
+
+ /**
+ * Returns a Warn Level
+ * @return Level
+ */
+ public static function getLevelWarn() {
+ if(!isset(self::$levelMap[Level::WARN])) {
+ self::$levelMap[Level::WARN] = new Level(Level::WARN, 'WARN', LOG_WARNING);
+ }
+ return self::$levelMap[Level::WARN];
+ }
+
+ /**
+ * Returns an Info Level
+ * @return Level
+ */
+ public static function getLevelInfo() {
+ if(!isset(self::$levelMap[Level::INFO])) {
+ self::$levelMap[Level::INFO] = new Level(Level::INFO, 'INFO', LOG_INFO);
+ }
+ return self::$levelMap[Level::INFO];
+ }
+
+ /**
+ * Returns a Debug Level
+ * @return Level
+ */
+ public static function getLevelDebug() {
+ if(!isset(self::$levelMap[Level::DEBUG])) {
+ self::$levelMap[Level::DEBUG] = new Level(Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ }
+ return self::$levelMap[Level::DEBUG];
+ }
+
+ /**
+ * Returns a Trace Level
+ * @return Level
+ */
+ public static function getLevelTrace() {
+ if(!isset(self::$levelMap[Level::TRACE])) {
+ self::$levelMap[Level::TRACE] = new Level(Level::TRACE, 'TRACE', LOG_DEBUG);
+ }
+ return self::$levelMap[Level::TRACE];
+ }
+
+ /**
+ * Returns an All Level
+ * @return Level
+ */
+ public static function getLevelAll() {
+ if(!isset(self::$levelMap[Level::ALL])) {
+ self::$levelMap[Level::ALL] = new Level(Level::ALL, 'ALL', LOG_DEBUG);
+ }
+ return self::$levelMap[Level::ALL];
+ }
+
+ /**
+ * Return the syslog equivalent of this level as an integer.
+ * @return integer
+ */
+ public function getSyslogEquivalent() {
+ return $this->syslogEquivalent;
+ }
+
+ /**
+ * Returns <i>true</i> if this level has a higher or equal
+ * level than the level passed as argument, <i>false</i>
+ * otherwise.
+ *
+ * @param Level $other
+ * @return boolean
+ */
+ public function isGreaterOrEqual($other) {
+ return $this->level >= $other->level;
+ }
+
+ /**
+ * Returns the string representation of this level.
+ * @return string
+ */
+ public function toString() {
+ return $this->levelStr;
+ }
+
+ /**
+ * Returns the string representation of this level.
+ * @return string
+ */
+ public function __toString() {
+ return $this->toString();
+ }
+
+ /**
+ * Returns the integer representation of this level.
+ * @return integer
+ */
+ public function toInt() {
+ return $this->level;
+ }
+
+ /**
+ * Convert the input argument to a level. If the conversion fails, then
+ * this method returns the provided default level.
+ *
+ * @param mixed $arg The value to convert to level.
+ * @param Level $default Value to return if conversion is not possible.
+ * @return Level
+ */
+ public static function toLevel($arg, $defaultLevel = null) {
+ if(is_int($arg)) {
+ switch($arg) {
+ case self::ALL: return self::getLevelAll();
+ case self::TRACE: return self::getLevelTrace();
+ case self::DEBUG: return self::getLevelDebug();
+ case self::INFO: return self::getLevelInfo();
+ case self::WARN: return self::getLevelWarn();
+ case self::ERROR: return self::getLevelError();
+ case self::FATAL: return self::getLevelFatal();
+ case self::OFF: return self::getLevelOff();
+ default: return $defaultLevel;
+ }
+ } else {
+ switch(strtoupper($arg)) {
+ case 'ALL': return self::getLevelAll();
+ case 'TRACE': return self::getLevelTrace();
+ case 'DEBUG': return self::getLevelDebug();
+ case 'INFO': return self::getLevelInfo();
+ case 'WARN': return self::getLevelWarn();
+ case 'ERROR': return self::getLevelError();
+ case 'FATAL': return self::getLevelFatal();
+ case 'OFF': return self::getLevelOff();
+ default: return $defaultLevel;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/LocationInfo.php
----------------------------------------------------------------------
diff --git a/src/LocationInfo.php b/src/LocationInfo.php
new file mode 100644
index 0000000..4615962
--- /dev/null
+++ b/src/LocationInfo.php
@@ -0,0 +1,100 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * The internal representation of caller location information.
+ * @since 0.3
+ */
+class LocationInfo {
+
+ /** The value to return when the location information is not available. */
+ const LOCATION_INFO_NA = 'NA';
+
+ /**
+ * Caller line number.
+ * @var integer
+ */
+ protected $lineNumber;
+
+ /**
+ * Caller file name.
+ * @var string
+ */
+ protected $fileName;
+
+ /**
+ * Caller class name.
+ * @var string
+ */
+ protected $className;
+
+ /**
+ * Caller method name.
+ * @var string
+ */
+ protected $methodName;
+
+ /**
+ * All the information combined.
+ * @var string
+ */
+ protected $fullInfo;
+
+ /**
+ * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
+ *
+ * @param array $trace
+ * @param mixed $caller
+ */
+ public function __construct($trace, $fqcn = null) {
+ $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
+ $this->fileName = isset($trace['file']) ? $trace['file'] : null;
+ $this->className = isset($trace['class']) ? $trace['class'] : null;
+ $this->methodName = isset($trace['function']) ? $trace['function'] : null;
+ $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
+ '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
+ }
+
+ /** Returns the caller class name. */
+ public function getClassName() {
+ return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
+ }
+
+ /** Returns the caller file name. */
+ public function getFileName() {
+ return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
+ }
+
+ /** Returns the caller line number. */
+ public function getLineNumber() {
+ return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
+ }
+
+ /** Returns the caller method name. */
+ public function getMethodName() {
+ return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
+ }
+
+ /** Returns the full information of the caller. */
+ public function getFullInfo() {
+ return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/Logger.php
----------------------------------------------------------------------
diff --git a/src/Logger.php b/src/Logger.php
new file mode 100644
index 0000000..27eca1c
--- /dev/null
+++ b/src/Logger.php
@@ -0,0 +1,592 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * This is the central class in the log4php package. All logging operations
+ * are done through this class.
+ *
+ * The main logging methods are:
+ * <ul>
+ * <li>{@link trace()}</li>
+ * <li>{@link debug()}</li>
+ * <li>{@link info()}</li>
+ * <li>{@link warn()}</li>
+ * <li>{@link error()}</li>
+ * <li>{@link fatal()}</li>
+ * </ul>
+ *
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+class Logger {
+
+ /**
+ * Logger additivity. If set to true then child loggers will inherit
+ * the appenders of their ancestors by default.
+ * @var boolean
+ */
+ private $additive = true;
+
+ /**
+ * The Logger's fully qualified class name.
+ * TODO: Determine if this is useful.
+ */
+ private $fqcn = 'Logger';
+
+ /** The assigned Logger level. */
+ private $level;
+
+ /** The name of this Logger instance. */
+ private $name;
+
+ /** The parent logger. Set to null if this is the root logger. */
+ private $parent;
+
+ /** A collection of appenders linked to this logger. */
+ private $appenders = array();
+
+ /**
+ * Constructor.
+ * @param string $name Name of the logger.
+ */
+ public function __construct($name) {
+ $this->name = $name;
+ }
+
+ /**
+ * Returns the logger name.
+ * @return string
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * Returns the parent Logger. Can be null if this is the root logger.
+ * @return Logger
+ */
+ public function getParent() {
+ return $this->parent;
+ }
+
+ // ******************************************
+ // *** Logging methods ***
+ // ******************************************
+
+ /**
+ * Log a message object with the TRACE level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function trace($message, $throwable = null) {
+ $this->log(Level::getLevelTrace(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the DEBUG level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function debug($message, $throwable = null) {
+ $this->log(Level::getLevelDebug(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the INFO Level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function info($message, $throwable = null) {
+ $this->log(Level::getLevelInfo(), $message, $throwable);
+ }
+
+ /**
+ * Log a message with the WARN level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function warn($message, $throwable = null) {
+ $this->log(Level::getLevelWarn(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the ERROR level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function error($message, $throwable = null) {
+ $this->log(Level::getLevelError(), $message, $throwable);
+ }
+
+ /**
+ * Log a message object with the FATAL level.
+ *
+ * @param mixed $message message
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function fatal($message, $throwable = null) {
+ $this->log(Level::getLevelFatal(), $message, $throwable);
+ }
+
+ /**
+ * Log a message using the provided logging level.
+ *
+ * @param Level $level The logging level.
+ * @param mixed $message Message to log.
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ */
+ public function log(Level $level, $message, $throwable = null) {
+ if($this->isEnabledFor($level)) {
+ $event = new LoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
+ $this->callAppenders($event);
+ }
+
+ // Forward the event upstream if additivity is turned on
+ if(isset($this->parent) && $this->getAdditivity()) {
+
+ // Use the event if already created
+ if (isset($event)) {
+ $this->parent->logEvent($event);
+ } else {
+ $this->parent->log($level, $message, $throwable);
+ }
+ }
+ }
+
+ /**
+ * Logs an already prepared logging event object.
+ * @param LoggingEvent $event
+ */
+ public function logEvent(LoggingEvent $event) {
+ if($this->isEnabledFor($event->getLevel())) {
+ $this->callAppenders($event);
+ }
+
+ // Forward the event upstream if additivity is turned on
+ if(isset($this->parent) && $this->getAdditivity()) {
+ $this->parent->logEvent($event);
+ }
+ }
+
+ /**
+ * If assertion parameter evaluates as false, then logs the message
+ * using the ERROR level.
+ *
+ * @param bool $assertion
+ * @param string $msg message to log
+ */
+ public function assertLog($assertion = true, $msg = '') {
+ if($assertion == false) {
+ $this->error($msg);
+ }
+ }
+
+ /**
+ * This method creates a new logging event and logs the event without
+ * further checks.
+ *
+ * It should not be called directly. Use {@link trace()}, {@link debug()},
+ * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
+ * wrappers.
+ *
+ * @param string $fqcn Fully qualified class name of the Logger
+ * @param Exception $throwable Optional throwable information to include
+ * in the logging event.
+ * @param Level $level log level
+ * @param mixed $message message to log
+ */
+ public function forcedLog($fqcn, $throwable, Level $level, $message) {
+ $event = new LoggingEvent($fqcn, $this, $level, $message, null, $throwable);
+ $this->callAppenders($event);
+
+ // Forward the event upstream if additivity is turned on
+ if(isset($this->parent) && $this->getAdditivity()) {
+ $this->parent->logEvent($event);
+ }
+ }
+
+ /**
+ * Forwards the given logging event to all linked appenders.
+ * @param LoggingEvent $event
+ */
+ public function callAppenders($event) {
+ foreach($this->appenders as $appender) {
+ $appender->doAppend($event);
+ }
+ }
+
+ // ******************************************
+ // *** Checker methods ***
+ // ******************************************
+
+ /**
+ * Check whether this Logger is enabled for a given Level passed as parameter.
+ *
+ * @param Level level
+ * @return boolean
+ */
+ public function isEnabledFor(Level $level) {
+ return $level->isGreaterOrEqual($this->getEffectiveLevel());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the TRACE Level.
+ * @return boolean
+ */
+ public function isTraceEnabled() {
+ return $this->isEnabledFor(Level::getLevelTrace());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the DEBUG Level.
+ * @return boolean
+ */
+ public function isDebugEnabled() {
+ return $this->isEnabledFor(Level::getLevelDebug());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the INFO Level.
+ * @return boolean
+ */
+ public function isInfoEnabled() {
+ return $this->isEnabledFor(Level::getLevelInfo());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the WARN Level.
+ * @return boolean
+ */
+ public function isWarnEnabled() {
+ return $this->isEnabledFor(Level::getLevelWarn());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the ERROR Level.
+ * @return boolean
+ */
+ public function isErrorEnabled() {
+ return $this->isEnabledFor(Level::getLevelError());
+ }
+
+ /**
+ * Check whether this Logger is enabled for the FATAL Level.
+ * @return boolean
+ */
+ public function isFatalEnabled() {
+ return $this->isEnabledFor(Level::getLevelFatal());
+ }
+
+ // ******************************************
+ // *** Configuration methods ***
+ // ******************************************
+
+ /**
+ * Adds a new appender to the Logger.
+ * @param Appender $appender The appender to add.
+ */
+ public function addAppender($appender) {
+ $appenderName = $appender->getName();
+ $this->appenders[$appenderName] = $appender;
+ }
+
+ /** Removes all appenders from the Logger. */
+ public function removeAllAppenders() {
+ foreach($this->appenders as $name => $appender) {
+ $this->removeAppender($name);
+ }
+ }
+
+ /**
+ * Remove the appender passed as parameter form the Logger.
+ * @param mixed $appender an appender name or a {@link Appender} instance.
+ */
+ public function removeAppender($appender) {
+ if($appender instanceof Appender) {
+ $appender->close();
+ unset($this->appenders[$appender->getName()]);
+ } else if (is_string($appender) and isset($this->appenders[$appender])) {
+ $this->appenders[$appender]->close();
+ unset($this->appenders[$appender]);
+ }
+ }
+
+ /**
+ * Returns the appenders linked to this logger as an array.
+ * @return array collection of appender names
+ */
+ public function getAllAppenders() {
+ return $this->appenders;
+ }
+
+ /**
+ * Returns a linked appender by name.
+ * @return Appender
+ */
+ public function getAppender($name) {
+ return $this->appenders[$name];
+ }
+
+ /**
+ * Sets the additivity flag.
+ * @param boolean $additive
+ */
+ public function setAdditivity($additive) {
+ $this->additive = (bool)$additive;
+ }
+
+ /**
+ * Returns the additivity flag.
+ * @return boolean
+ */
+ public function getAdditivity() {
+ return $this->additive;
+ }
+
+ /**
+ * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
+ * @see Level
+ * @return Level or null
+ */
+ public function getEffectiveLevel() {
+ for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
+ if($logger->getLevel() !== null) {
+ return $logger->getLevel();
+ }
+ }
+ }
+
+ /**
+ * Get the assigned Logger level.
+ * @return Level The assigned level or null if none is assigned.
+ */
+ public function getLevel() {
+ return $this->level;
+ }
+
+ /**
+ * Set the Logger level.
+ *
+ * Use Level::getLevelXXX() methods to get a Level object, e.g.
+ * <code>$logger->setLevel(Level::getLevelInfo());</code>
+ *
+ * @param Level $level The level to set, or NULL to clear the logger level.
+ */
+ public function setLevel(Level $level = null) {
+ $this->level = $level;
+ }
+
+ /**
+ * Checks whether an appender is attached to this logger instance.
+ *
+ * @param Appender $appender
+ * @return boolean
+ */
+ public function isAttached(Appender $appender) {
+ return isset($this->appenders[$appender->getName()]);
+ }
+
+ /**
+ * Sets the parent logger.
+ * @param Logger $logger
+ */
+ public function setParent(Logger $logger) {
+ $this->parent = $logger;
+ }
+
+ // ******************************************
+ // *** Static methods and properties ***
+ // ******************************************
+
+ /** The logger hierarchy used by log4php. */
+ private static $hierarchy;
+
+ /** Inidicates if log4php has been initialized */
+ private static $initialized = false;
+
+ /**
+ * Returns the hierarchy used by this Logger.
+ *
+ * Caution: do not use this hierarchy unless you have called initialize().
+ * To get Loggers, use the Logger::getLogger and Logger::getRootLogger
+ * methods instead of operating on on the hierarchy directly.
+ *
+ * @return Hierarchy
+ */
+ public static function getHierarchy() {
+ if(!isset(self::$hierarchy)) {
+ self::$hierarchy = new Hierarchy(new RootLogger());
+ }
+ return self::$hierarchy;
+ }
+
+ /**
+ * Returns a Logger by name. If it does not exist, it will be created.
+ *
+ * @param string $name The logger name
+ * @return Logger
+ */
+ public static function getLogger($name) {
+ if(!self::isInitialized()) {
+ self::configure();
+ }
+ return self::getHierarchy()->getLogger($name);
+ }
+
+ /**
+ * Returns the Root Logger.
+ * @return RootLogger
+ */
+ public static function getRootLogger() {
+ if(!self::isInitialized()) {
+ self::configure();
+ }
+ return self::getHierarchy()->getRootLogger();
+ }
+
+ /**
+ * Clears all Logger definitions from the logger hierarchy.
+ * @return boolean
+ */
+ public static function clear() {
+ return self::getHierarchy()->clear();
+ }
+
+ /**
+ * Destroy configurations for logger definitions
+ */
+ public static function resetConfiguration() {
+ self::getHierarchy()->resetConfiguration();
+ self::getHierarchy()->clear(); // TODO: clear or not?
+ self::$initialized = false;
+ }
+
+ /**
+ * Safely close all appenders.
+ * @deprecated This is no longer necessary due the appenders shutdown via
+ * destructors.
+ */
+ public static function shutdown() {
+ return self::getHierarchy()->shutdown();
+ }
+
+ /**
+ * check if a given logger exists.
+ *
+ * @param string $name logger name
+ * @return boolean
+ */
+ public static function exists($name) {
+ return self::getHierarchy()->exists($name);
+ }
+
+ /**
+ * Returns an array this whole Logger instances.
+ * @see Logger
+ * @return array
+ */
+ public static function getCurrentLoggers() {
+ return self::getHierarchy()->getCurrentLoggers();
+ }
+
+ /**
+ * Configures log4php.
+ *
+ * This method needs to be called before the first logging event has
+ * occured. If this method is not called before then the default
+ * configuration will be used.
+ *
+ * @param string|array $configuration Either a path to the configuration
+ * file, or a configuration array.
+ *
+ * @param string|Configurator $configurator A custom
+ * configurator class: either a class name (string), or an object which
+ * implements the Configurator interface. If left empty, the default
+ * configurator implementation will be used.
+ */
+ public static function configure($configuration = null, $configurator = null) {
+ self::resetConfiguration();
+ $configurator = self::getConfigurator($configurator);
+ $configurator->configure(self::getHierarchy(), $configuration);
+ self::$initialized = true;
+ }
+
+ /**
+ * Creates a logger configurator instance based on the provided
+ * configurator class. If no class is given, returns an instance of
+ * the default configurator.
+ *
+ * @param string|Configurator $configurator The configurator class
+ * or Configurator instance.
+ */
+ private static function getConfigurator($configurator = null) {
+ if ($configurator === null) {
+ return new Configuration\DefaultConfigurator();
+ }
+
+ if (is_object($configurator)) {
+ if ($configurator instanceof Configurator) {
+ return $configurator;
+ } else {
+ trigger_error("log4php: Given configurator object [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
+ return new Configuration\DefaultConfigurator();
+ }
+ }
+
+ if (is_string($configurator)) {
+ if (!class_exists($configurator)) {
+ trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
+ return new Configuration\DefaultConfigurator();
+ }
+
+ $instance = new $configurator();
+
+ if (!($instance instanceof Configurator)) {
+ trigger_error("log4php: Specified configurator class [$configurator] does not implement the Configurator interface. Reverting to default configurator.", E_USER_WARNING);
+ return new Configuration\DefaultConfigurator();
+ }
+
+ return $instance;
+ }
+
+ trigger_error("log4php: Invalid configurator specified. Expected either a string or a Configurator instance. Reverting to default configurator.", E_USER_WARNING);
+ return new Configuration\DefaultConfigurator();
+ }
+
+ /**
+ * Returns true if the log4php framework has been initialized.
+ * @return boolean
+ */
+ private static function isInitialized() {
+ return self::$initialized;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/LoggerException.php
----------------------------------------------------------------------
diff --git a/src/LoggerException.php b/src/LoggerException.php
new file mode 100644
index 0000000..103c532
--- /dev/null
+++ b/src/LoggerException.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache\Log4php;
+
+/**
+ * LoggerException class
+ */
+class LoggerException extends \Exception {
+}
[28/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Pattern/PatternConverterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Pattern/PatternConverterTest.php b/tests/src/Pattern/PatternConverterTest.php
index e491dba..a458369 100644
--- a/tests/src/Pattern/PatternConverterTest.php
+++ b/tests/src/Pattern/PatternConverterTest.php
@@ -27,19 +27,14 @@ use Apache\Log4php\Logger;
use Apache\Log4php\MDC;
use Apache\Log4php\NDC;
-use Apache\Log4php\Pattern\ClassConverter;
use Apache\Log4php\Pattern\CookieConverter;
use Apache\Log4php\Pattern\DateConverter;
use Apache\Log4php\Pattern\EnvironmentConverter;
-use Apache\Log4php\Pattern\FileConverter;
use Apache\Log4php\Pattern\LevelConverter;
-use Apache\Log4php\Pattern\LineConverter;
use Apache\Log4php\Pattern\LiteralConverter;
-use Apache\Log4php\Pattern\LocationConverter;
use Apache\Log4php\Pattern\LoggerConverter;
use Apache\Log4php\Pattern\MdcConverter;
use Apache\Log4php\Pattern\MessageConverter;
-use Apache\Log4php\Pattern\MethodConverter;
use Apache\Log4php\Pattern\NdcConverter;
use Apache\Log4php\Pattern\NewLineConverter;
use Apache\Log4php\Pattern\ProcessConverter;
@@ -49,367 +44,392 @@ use Apache\Log4php\Pattern\ServerConverter;
use Apache\Log4php\Pattern\SessionConverter;
use Apache\Log4php\Pattern\SessionIdConverter;
use Apache\Log4php\Pattern\SuperglobalConverter;
-use Apache\Log4php\Pattern\ThrowableConverter;
-
use Apache\Log4php\Tests\TestHelper;
/** Converter referencing non-existant superglobal variable. */
-class InvalidSuperglobalConverter extends SuperglobalConverter {
- protected $name = '_FOO';
+class InvalidSuperglobalConverter extends SuperglobalConverter
+{
+ protected $name = '_FOO';
}
/**
* @group pattern
*/
-class PatternConverterTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * A logging event for testing.
- * @var LoggingEvent
- */
- private $event;
-
- /**
- * Fromatting info used with the logging event.
- * @var LoggerFormattingInfos
- */
- private $info;
-
- public function __construct() {
- $this->event = TestHelper::getInfoEvent('foobar');
- $this->info = new FormattingInfo();
- }
-
- public function testCookie() {
- // Fake a couple of cookies
- $_COOKIE['test1'] = 'value1';
- $_COOKIE['test2'] = 'value2';
-
- $converter = new CookieConverter($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
-
- $converter = new CookieConverter($this->info, 'test2');
- $actual = $converter->convert($this->event);
- $expected = 'value2';
- self::assertSame($expected, $actual);
-
- $converter = new CookieConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = "test1=value1, test2=value2";
- self::assertSame($expected, $actual);
- }
-
- public function testDate() {
- $converter = new DateConverter($this->info, 'c');
- $actual = $converter->convert($this->event);
- $expected = date('c', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- // Format defaults to 'c'
- $converter = new DateConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = date('c', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- $converter = new DateConverter($this->info, '');
- $actual = $converter->convert($this->event);
- $expected = date('c', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- // Test ABSOLUTE
- $converter = new DateConverter($this->info, 'ABSOLUTE');
- $actual = $converter->convert($this->event);
- $expected = date('H:i:s', $this->event->getTimeStamp());
- self::assertSame($expected, $actual);
-
- // Test DATE
- $converter = new DateConverter($this->info, 'DATE');
- $actual = $converter->convert($this->event);
- $expected = date('d M Y H:i:s.', $this->event->getTimeStamp());
-
- $timestamp = $this->event->getTimeStamp();
- $ms = floor(($timestamp - floor($timestamp)) * 1000);
- $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
-
- $expected .= $ms;
-
- self::assertSame($expected, $actual);
- }
-
- public function testEnvironment() {
- // Fake a couple of environment values
- $_ENV['test1'] = 'value1';
- $_ENV['test2'] = 'value2';
-
- $converter = new EnvironmentConverter($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
-
- $converter = new EnvironmentConverter($this->info, 'test2');
- $actual = $converter->convert($this->event);
- $expected = 'value2';
- self::assertSame($expected, $actual);
- }
-
- public function testLevel() {
- $converter = new LevelConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = $this->event->getLevel()->toString();
- self::assertEquals($expected, $actual);
- }
-
- public function testLiteral() {
- $converter = new LiteralConverter('foo bar baz');
- $actual = $converter->convert($this->event);
- $expected = 'foo bar baz';
- self::assertEquals($expected, $actual);
- }
-
- public function testLoggerWithoutOption() {
- $event = TestHelper::getInfoEvent('foo', 'TestLoggerName');
- $converter = new LoggerConverter($this->info);
-
- $actual = $converter->convert($event);
- $expected = 'TestLoggerName';
- self::assertEquals($expected, $actual);
- }
-
- public function testLoggerWithOption0() {
- $event = TestHelper::getInfoEvent('foo', 'TestLoggerName');
- $converter = new LoggerConverter($this->info, '0');
-
- $actual = $converter->convert($event);
- $expected = 'TestLoggerName';
- self::assertEquals($expected, $actual);
- }
-
- public function testLocation() {
- $config = TestHelper::getEchoPatternConfig("%file:%line:%class:%method");
- Logger::configure($config);
-
- // Test by capturing output. Logging methods of a Logger object must
- // be used for the location info to be formed correctly.
- ob_start();
- $log = Logger::getLogger('foo');
- $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
- $actual = ob_get_contents();
- ob_end_clean();
-
- $expected = implode(':', array(__FILE__, $line, __CLASS__, __FUNCTION__));
- self::assertSame($expected, $actual);
-
- Logger::resetConfiguration();
- }
-
- public function testLocation2() {
- $config = TestHelper::getEchoPatternConfig("%location");
- Logger::configure($config);
-
- // Test by capturing output. Logging methods of a Logger object must
- // be used for the location info to be formed correctly.
- ob_start();
- $log = Logger::getLogger('foo');
- $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
- $actual = ob_get_contents();
- ob_end_clean();
-
- $class = __CLASS__;
- $func = __FUNCTION__;
- $file = __FILE__;
-
- $expected = "$class.$func($file:$line)";
- self::assertSame($expected, $actual);
-
- Logger::resetConfiguration();
- }
-
- public function testMessage() {
- $expected = "This is a message.";
- $event = TestHelper::getInfoEvent($expected);
- $converter = new MessageConverter($this->info);
- $actual = $converter->convert($event);
- self::assertSame($expected, $actual);
- }
-
- public function testMDC() {
- MDC::put('foo', 'bar');
- MDC::put('bla', 'tra');
-
- // Entire context
- $converter = new MdcConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = 'foo=bar, bla=tra';
- self::assertSame($expected, $actual);
-
- // Just foo
- $converter = new MdcConverter($this->info, 'foo');
- $actual = $converter->convert($this->event);
- $expected = 'bar';
- self::assertSame($expected, $actual);
-
- // Non existant key
- $converter = new MdcConverter($this->info, 'doesnotexist');
- $actual = $converter->convert($this->event);
- $expected = '';
- self::assertSame($expected, $actual);
-
- MDC::clear();
- }
-
- public function testNDC() {
- NDC::push('foo');
- NDC::push('bar');
- NDC::push('baz');
-
- $converter = new NdcConverter($this->info);
- $expected = 'foo bar baz';
- $actual = $converter->convert($this->event);
- self::assertEquals($expected, $actual);
- }
-
- public function testNewline() {
- $converter = new NewLineConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = PHP_EOL;
- self::assertSame($expected, $actual);
- }
-
- public function testProcess() {
- $converter = new ProcessConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = getmypid();
- self::assertSame($expected, $actual);
- }
-
- public function testRelative() {
- $converter = new RelativeConverter($this->info);
- $expected = number_format($this->event->getTimeStamp() - $this->event->getStartTime(), 4);
- $actual = $converter->convert($this->event);
- self::assertSame($expected, $actual);
- }
-
- public function testRequest() {
- // Fake a couple of request values
- $_REQUEST['test1'] = 'value1';
- $_REQUEST['test2'] = 'value2';
-
- // Entire request
- $converter = new RequestConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = 'test1=value1, test2=value2';
- self::assertSame($expected, $actual);
-
- // Just test2
- $converter = new RequestConverter($this->info, 'test2');
- $actual = $converter->convert($this->event);
- $expected = 'value2';
- self::assertSame($expected, $actual);
- }
-
- public function testServer() {
- // Fake a server value
- $_SERVER['test1'] = 'value1';
-
- $converter = new ServerConverter($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
- }
-
- public function testSession() {
- // Fake a session value
- $_SESSION['test1'] = 'value1';
-
- $converter = new SessionConverter($this->info, 'test1');
- $actual = $converter->convert($this->event);
- $expected = 'value1';
- self::assertSame($expected, $actual);
- }
-
- public function testSessionID() {
- $converter = new SessionIdConverter($this->info);
- $actual = $converter->convert($this->event);
- $expected = session_id();
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: InvalidSuperglobalConverter: Cannot find superglobal variable $_FOO
- */
- public function testNonexistantSuperglobal() {
- $converter = new InvalidSuperglobalConverter($this->info);
- $actual = $converter->convert($this->event);
- }
-
- public function testFormattingTrimRight() {
- $event = TestHelper::getInfoEvent('0123456789');
-
- $info = new FormattingInfo();
- $info->max = 5;
-
- $converter = new MessageConverter($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = "01234";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingTrimLeft() {
- $event = TestHelper::getInfoEvent('0123456789');
-
- $info = new FormattingInfo();
- $info->max = 5;
- $info->trimLeft = true;
-
- $converter = new MessageConverter($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = "56789";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingPadEmpty() {
- $event = TestHelper::getInfoEvent('');
-
- $info = new FormattingInfo();
- $info->min = 5;
-
- $converter = new MessageConverter($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = " ";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingPadLeft() {
- $event = TestHelper::getInfoEvent('0');
-
- $info = new FormattingInfo();
- $info->min = 5;
-
- $converter = new MessageConverter($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = " 0";
- self::assertSame($expected, $actual);
- }
-
- public function testFormattingPadRight() {
- $event = TestHelper::getInfoEvent('0');
-
- $info = new FormattingInfo();
- $info->min = 5;
- $info->padLeft = false;
-
- $converter = new MessageConverter($info);
- $actual = "";
- $converter->format($actual, $event);
- $expected = "0 ";
- self::assertSame($expected, $actual);
- }
+class PatternConverterTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * A logging event for testing.
+ * @var LoggingEvent
+ */
+ private $event;
+
+ /**
+ * Fromatting info used with the logging event.
+ * @var LoggerFormattingInfos
+ */
+ private $info;
+
+ public function __construct()
+ {
+ $this->event = TestHelper::getInfoEvent('foobar');
+ $this->info = new FormattingInfo();
+ }
+
+ public function testCookie()
+ {
+ // Fake a couple of cookies
+ $_COOKIE['test1'] = 'value1';
+ $_COOKIE['test2'] = 'value2';
+
+ $converter = new CookieConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+
+ $converter = new CookieConverter($this->info, 'test2');
+ $actual = $converter->convert($this->event);
+ $expected = 'value2';
+ self::assertSame($expected, $actual);
+
+ $converter = new CookieConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = "test1=value1, test2=value2";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testDate()
+ {
+ $converter = new DateConverter($this->info, 'c');
+ $actual = $converter->convert($this->event);
+ $expected = date('c', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ // Format defaults to 'c'
+ $converter = new DateConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = date('c', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ $converter = new DateConverter($this->info, '');
+ $actual = $converter->convert($this->event);
+ $expected = date('c', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ // Test ABSOLUTE
+ $converter = new DateConverter($this->info, 'ABSOLUTE');
+ $actual = $converter->convert($this->event);
+ $expected = date('H:i:s', $this->event->getTimeStamp());
+ self::assertSame($expected, $actual);
+
+ // Test DATE
+ $converter = new DateConverter($this->info, 'DATE');
+ $actual = $converter->convert($this->event);
+ $expected = date('d M Y H:i:s.', $this->event->getTimeStamp());
+
+ $timestamp = $this->event->getTimeStamp();
+ $ms = floor(($timestamp - floor($timestamp)) * 1000);
+ $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
+
+ $expected .= $ms;
+
+ self::assertSame($expected, $actual);
+ }
+
+ public function testEnvironment()
+ {
+ // Fake a couple of environment values
+ $_ENV['test1'] = 'value1';
+ $_ENV['test2'] = 'value2';
+
+ $converter = new EnvironmentConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+
+ $converter = new EnvironmentConverter($this->info, 'test2');
+ $actual = $converter->convert($this->event);
+ $expected = 'value2';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testLevel()
+ {
+ $converter = new LevelConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = $this->event->getLevel()->toString();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLiteral()
+ {
+ $converter = new LiteralConverter('foo bar baz');
+ $actual = $converter->convert($this->event);
+ $expected = 'foo bar baz';
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLoggerWithoutOption()
+ {
+ $event = TestHelper::getInfoEvent('foo', 'TestLoggerName');
+ $converter = new LoggerConverter($this->info);
+
+ $actual = $converter->convert($event);
+ $expected = 'TestLoggerName';
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLoggerWithOption0()
+ {
+ $event = TestHelper::getInfoEvent('foo', 'TestLoggerName');
+ $converter = new LoggerConverter($this->info, '0');
+
+ $actual = $converter->convert($event);
+ $expected = 'TestLoggerName';
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLocation()
+ {
+ $config = TestHelper::getEchoPatternConfig("%file:%line:%class:%method");
+ Logger::configure($config);
+
+ // Test by capturing output. Logging methods of a Logger object must
+ // be used for the location info to be formed correctly.
+ ob_start();
+ $log = Logger::getLogger('foo');
+ $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $expected = implode(':', array(__FILE__, $line, __CLASS__, __FUNCTION__));
+ self::assertSame($expected, $actual);
+
+ Logger::resetConfiguration();
+ }
+
+ public function testLocation2()
+ {
+ $config = TestHelper::getEchoPatternConfig("%location");
+ Logger::configure($config);
+
+ // Test by capturing output. Logging methods of a Logger object must
+ // be used for the location info to be formed correctly.
+ ob_start();
+ $log = Logger::getLogger('foo');
+ $log->info('foo'); $line = __LINE__; // Do NOT move this to next line.
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $class = __CLASS__;
+ $func = __FUNCTION__;
+ $file = __FILE__;
+
+ $expected = "$class.$func($file:$line)";
+ self::assertSame($expected, $actual);
+
+ Logger::resetConfiguration();
+ }
+
+ public function testMessage()
+ {
+ $expected = "This is a message.";
+ $event = TestHelper::getInfoEvent($expected);
+ $converter = new MessageConverter($this->info);
+ $actual = $converter->convert($event);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testMDC()
+ {
+ MDC::put('foo', 'bar');
+ MDC::put('bla', 'tra');
+
+ // Entire context
+ $converter = new MdcConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = 'foo=bar, bla=tra';
+ self::assertSame($expected, $actual);
+
+ // Just foo
+ $converter = new MdcConverter($this->info, 'foo');
+ $actual = $converter->convert($this->event);
+ $expected = 'bar';
+ self::assertSame($expected, $actual);
+
+ // Non existant key
+ $converter = new MdcConverter($this->info, 'doesnotexist');
+ $actual = $converter->convert($this->event);
+ $expected = '';
+ self::assertSame($expected, $actual);
+
+ MDC::clear();
+ }
+
+ public function testNDC()
+ {
+ NDC::push('foo');
+ NDC::push('bar');
+ NDC::push('baz');
+
+ $converter = new NdcConverter($this->info);
+ $expected = 'foo bar baz';
+ $actual = $converter->convert($this->event);
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testNewline()
+ {
+ $converter = new NewLineConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = PHP_EOL;
+ self::assertSame($expected, $actual);
+ }
+
+ public function testProcess()
+ {
+ $converter = new ProcessConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = getmypid();
+ self::assertSame($expected, $actual);
+ }
+
+ public function testRelative()
+ {
+ $converter = new RelativeConverter($this->info);
+ $expected = number_format($this->event->getTimeStamp() - $this->event->getStartTime(), 4);
+ $actual = $converter->convert($this->event);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testRequest()
+ {
+ // Fake a couple of request values
+ $_REQUEST['test1'] = 'value1';
+ $_REQUEST['test2'] = 'value2';
+
+ // Entire request
+ $converter = new RequestConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = 'test1=value1, test2=value2';
+ self::assertSame($expected, $actual);
+
+ // Just test2
+ $converter = new RequestConverter($this->info, 'test2');
+ $actual = $converter->convert($this->event);
+ $expected = 'value2';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testServer()
+ {
+ // Fake a server value
+ $_SERVER['test1'] = 'value1';
+
+ $converter = new ServerConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testSession()
+ {
+ // Fake a session value
+ $_SESSION['test1'] = 'value1';
+
+ $converter = new SessionConverter($this->info, 'test1');
+ $actual = $converter->convert($this->event);
+ $expected = 'value1';
+ self::assertSame($expected, $actual);
+ }
+
+ public function testSessionID()
+ {
+ $converter = new SessionIdConverter($this->info);
+ $actual = $converter->convert($this->event);
+ $expected = session_id();
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: InvalidSuperglobalConverter: Cannot find superglobal variable $_FOO
+ */
+ public function testNonexistantSuperglobal()
+ {
+ $converter = new InvalidSuperglobalConverter($this->info);
+ $actual = $converter->convert($this->event);
+ }
+
+ public function testFormattingTrimRight()
+ {
+ $event = TestHelper::getInfoEvent('0123456789');
+
+ $info = new FormattingInfo();
+ $info->max = 5;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = "01234";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingTrimLeft()
+ {
+ $event = TestHelper::getInfoEvent('0123456789');
+
+ $info = new FormattingInfo();
+ $info->max = 5;
+ $info->trimLeft = true;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = "56789";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingPadEmpty()
+ {
+ $event = TestHelper::getInfoEvent('');
+
+ $info = new FormattingInfo();
+ $info->min = 5;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = " ";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingPadLeft()
+ {
+ $event = TestHelper::getInfoEvent('0');
+
+ $info = new FormattingInfo();
+ $info->min = 5;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = " 0";
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFormattingPadRight()
+ {
+ $event = TestHelper::getInfoEvent('0');
+
+ $info = new FormattingInfo();
+ $info->min = 5;
+ $info->padLeft = false;
+
+ $converter = new MessageConverter($info);
+ $actual = "";
+ $converter->format($actual, $event);
+ $expected = "0 ";
+ self::assertSame($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/ReflectionUtilsTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ReflectionUtilsTest.php b/tests/src/ReflectionUtilsTest.php
index 2357657..1e5229b 100644
--- a/tests/src/ReflectionUtilsTest.php
+++ b/tests/src/ReflectionUtilsTest.php
@@ -24,23 +24,28 @@ namespace Apache\Log4php\Tests;
use Apache\Log4php\ReflectionUtils;
-class Simple {
+class Simple
+{
private $name;
private $male;
- public function getName() {
+ public function getName()
+ {
return $this->name;
}
- public function isMale() {
+ public function isMale()
+ {
return $this->male;
}
- public function setName($name) {
+ public function setName($name)
+ {
$this->name = $name;
}
- public function setMale($male) {
+ public function setMale($male)
+ {
$this->male = $male;
}
}
@@ -48,44 +53,48 @@ class Simple {
/**
* @group main
*/
-class ReflectionUtilsTest extends \PHPUnit_Framework_TestCase {
-
- public function testSimpleSet() {
- $s = new Simple();
- $ps = new ReflectionUtils($s);
- $ps->setProperty("name", "Joe");
- $ps->setProperty("male", true);
-
- $this->assertEquals($s->isMale(), true);
- $this->assertEquals($s->getName(), 'Joe');
- }
+class ReflectionUtilsTest extends \PHPUnit_Framework_TestCase
+{
+ public function testSimpleSet()
+ {
+ $s = new Simple();
+ $ps = new ReflectionUtils($s);
+ $ps->setProperty("name", "Joe");
+ $ps->setProperty("male", true);
+
+ $this->assertEquals($s->isMale(), true);
+ $this->assertEquals($s->getName(), 'Joe');
+ }
- public function testSimpleArraySet() {
- $arr['xxxname'] = 'Joe';
- $arr['xxxmale'] = true;
+ public function testSimpleArraySet()
+ {
+ $arr['xxxname'] = 'Joe';
+ $arr['xxxmale'] = true;
- $s = new Simple();
- $ps = new ReflectionUtils($s);
- $ps->setProperties($arr, "xxx");
+ $s = new Simple();
+ $ps = new ReflectionUtils($s);
+ $ps->setProperties($arr, "xxx");
- $this->assertEquals($s->getName(), 'Joe');
- $this->assertEquals($s->isMale(), true);
- }
+ $this->assertEquals($s->getName(), 'Joe');
+ $this->assertEquals($s->isMale(), true);
+ }
- public function testStaticArraySet() {
- $arr['xxxname'] = 'Joe';
- $arr['xxxmale'] = true;
+ public function testStaticArraySet()
+ {
+ $arr['xxxname'] = 'Joe';
+ $arr['xxxmale'] = true;
- $s = new Simple();
- ReflectionUtils::setPropertiesByObject($s,$arr,"xxx");
+ $s = new Simple();
+ ReflectionUtils::setPropertiesByObject($s,$arr,"xxx");
- $this->assertEquals($s->getName(), 'Joe');
- $this->assertEquals($s->isMale(), true);
- }
- public function testCreateObject() {
+ $this->assertEquals($s->getName(), 'Joe');
+ $this->assertEquals($s->isMale(), true);
+ }
+ public function testCreateObject()
+ {
$class = 'Apache\\Log4php\\Layouts\\SimpleLayout';
- $object = ReflectionUtils::createObject($class);
- $name = get_class($object);
- self::assertEquals($name, $class);
- }
+ $object = ReflectionUtils::createObject($class);
+ $name = get_class($object);
+ self::assertEquals($name, $class);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/Renderers/RendererMapTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Renderers/RendererMapTest.php b/tests/src/Renderers/RendererMapTest.php
index 3960660..664bb71 100644
--- a/tests/src/Renderers/RendererMapTest.php
+++ b/tests/src/Renderers/RendererMapTest.php
@@ -27,223 +27,229 @@ use Apache\Log4php\Logger;
use Apache\Log4php\LoggerException;
/** Renders everything as 'foo'. */
-class FooRenderer implements RendererInterface {
- public function render($input) {
- return 'foo';
- }
+class FooRenderer implements RendererInterface
+{
+ public function render($input)
+ {
+ return 'foo';
+ }
}
class InvalidCostumObjectRenderer { }
-class Fruit3 {
+class Fruit3
+{
public $test1 = 'test1';
public $test2 = 'test2';
public $test3 = 'test3';
}
-class Fruit3Descendant extends Fruit3 {
+class Fruit3Descendant extends Fruit3
+{
}
-class FruitRenderer3 implements RendererInterface {
- public function render($fruit) {
- return $fruit->test1 . ',' . $fruit->test2 . ',' . $fruit->test3;
- }
+class FruitRenderer3 implements RendererInterface
+{
+ public function render($fruit)
+ {
+ return $fruit->test1 . ',' . $fruit->test2 . ',' . $fruit->test3;
+ }
}
-class SampleObject {
+class SampleObject
+{
}
/**
* @group renderers
*/
-class RendererMapTest extends \PHPUnit_Framework_TestCase {
-
- public function testDefaults() {
-
- $map = new RendererMap();
- $actual = $map->getByClassName('Exception');
- $expected = 'Apache\\Log4php\\Renderers\\ExceptionRenderer';
- self::assertInstanceOf($expected, $actual);
-
- // Check non-configured objects return null
- self::assertNull($map->getByObject(new stdClass()));
- self::assertNull($map->getByClassName('stdClass'));
- }
-
- public function testClear()
- {
- $map = new RendererMap();
- $map->clear(); // This should clear the map and remove default renderers
- self::assertNull($map->getByClassName('Exception'));
- }
-
- public function testFindAndRender()
- {
- $map = new RendererMap();
- $map->addRenderer('Fruit3', 'FruitRenderer3');
-
- $fruit = new Fruit3();
- $descendant = new Fruit3Descendant();
-
- // Check rendering of fruit
- $actual = $map->findAndRender($fruit);
- $expected = 'test1,test2,test3';
- self::assertSame($expected, $actual);
-
- $actual = $map->getByObject($fruit);
- self::assertInstanceOf('FruitRenderer3', $actual);
-
- // Check rendering of fruit's descendant
- $actual = $map->findAndRender($descendant);
- $expected = 'test1,test2,test3';
- self::assertSame($expected, $actual);
-
- $actual = $map->getByObject($descendant);
- self::assertInstanceOf('FruitRenderer3', $actual);
-
- // Test rendering null returns null
- self::assertNull($map->findAndRender(null));
- }
-
- /**
- * Try adding a non-existant class as renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExist] not found.
- */
- public function testAddRendererError1()
- {
- $map = new RendererMap();
- $map->addRenderer('Fruit3', 'DoesNotExist');
- }
-
- /**
- * Try adding a class which does not implement RendererInterface as renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
- */
- public function testAddRendererError2()
- {
- $map = new RendererMap();
- $map->addRenderer('Fruit3', 'stdClass');
- }
-
- public function testAddRendererError3()
- {
- $map = new RendererMap();
- @$map->addRenderer('Fruit3', 'stdClass');
- self::assertNull($map->getByClassName('Fruit3'));
-
- @$map->addRenderer('Fruit3', 'DoesNotExist');
- self::assertNull($map->getByClassName('Fruit3'));
- }
-
- /**
- * Try setting a non-existant class as default renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed setting default renderer. Rendering class [DoesNotExist] not found.
- */
- public function testSetDefaultRendererError1()
- {
- $map = new RendererMap();
- $map->setDefaultRenderer('DoesNotExist');
- }
-
- /**
- * Try setting a class which does not implement RendererInterface as default renderer.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed setting default renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
- */
- public function testSetDefaultRendererError2()
- {
- $map = new RendererMap();
- $map->setDefaultRenderer('stdClass');
- }
-
- public function testSetDefaultRendererError3()
- {
- $map = new RendererMap();
- $expected = $map->getDefaultRenderer();
-
- @$map->setDefaultRenderer('stdClass');
- $actual = $map->getDefaultRenderer();
- self::assertSame($expected, $actual);
-
- @$map->setDefaultRenderer('DoesNotExist');
- $actual = $map->getDefaultRenderer();
- self::assertSame($expected, $actual);
- }
-
- public function testFetchingRenderer()
- {
- $map = new RendererMap();
- $map->addRenderer('Fruit3', 'FruitRenderer3');
- }
-
- public function testDefaultRenderer()
- {
- $fruit = new Fruit3();
-
- $map = new RendererMap();
- $actual = $map->findAndRender($fruit);
-
- $defaultRenderer = new DefaultRenderer();
- $expected = $defaultRenderer->render($fruit);
- self::assertSame($expected, $actual);
- }
-
- public function testOverrideDefaultRenderer()
- {
- $map = new RendererMap();
- $default = $map->getDefaultRenderer();
-
- $array = array(1, 2, 3);
-
- $actual = $map->findAndRender($array);
- $expected = print_r($array, true);
- self::assertSame($actual, $expected);
-
- // Now switch the default renderer
- $map->setDefaultRenderer('FooRenderer');
- $actual = $map->findAndRender($array);
- $expected = 'foo';
- self::assertSame($actual, $expected);
- }
-
- public function testGetByObjectCrap()
- {
- $map = new RendererMap();
-
- // Non object input should always return null
- self::assertNull($map->getByObject(null));
- self::assertNull($map->getByObject(array()));
- self::assertNull($map->getByObject('sdasda'));
- }
-
- public function testXMLConfig()
- {
- $map = Logger::getHierarchy()->getRendererMap();
- Logger::resetConfiguration();
-
- $expected = 'Apache\\Log4php\\Renderers\\DefaultRenderer';
- self::assertInstanceOf($expected, $map->getDefaultRenderer());
-
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_default_renderer.xml');
- self::assertInstanceOf('FruitRenderer3', $map->getDefaultRenderer());
-
- Logger::resetConfiguration();
- self::assertInstanceOf($expected, $map->getDefaultRenderer());
- }
-
- public function testExceptionRenderer()
- {
- $ex = new LoggerException("This is a test");
-
- $map = new RendererMap();
- $actual = $map->findAndRender($ex);
- $expected = (string) $ex;
-
- self::assertSame($expected, $actual);
- }
-
+class RendererMapTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDefaults()
+ {
+ $map = new RendererMap();
+ $actual = $map->getByClassName('Exception');
+ $expected = 'Apache\\Log4php\\Renderers\\ExceptionRenderer';
+ self::assertInstanceOf($expected, $actual);
+
+ // Check non-configured objects return null
+ self::assertNull($map->getByObject(new stdClass()));
+ self::assertNull($map->getByClassName('stdClass'));
+ }
+
+ public function testClear()
+ {
+ $map = new RendererMap();
+ $map->clear(); // This should clear the map and remove default renderers
+ self::assertNull($map->getByClassName('Exception'));
+ }
+
+ public function testFindAndRender()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'FruitRenderer3');
+
+ $fruit = new Fruit3();
+ $descendant = new Fruit3Descendant();
+
+ // Check rendering of fruit
+ $actual = $map->findAndRender($fruit);
+ $expected = 'test1,test2,test3';
+ self::assertSame($expected, $actual);
+
+ $actual = $map->getByObject($fruit);
+ self::assertInstanceOf('FruitRenderer3', $actual);
+
+ // Check rendering of fruit's descendant
+ $actual = $map->findAndRender($descendant);
+ $expected = 'test1,test2,test3';
+ self::assertSame($expected, $actual);
+
+ $actual = $map->getByObject($descendant);
+ self::assertInstanceOf('FruitRenderer3', $actual);
+
+ // Test rendering null returns null
+ self::assertNull($map->findAndRender(null));
+ }
+
+ /**
+ * Try adding a non-existant class as renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExist] not found.
+ */
+ public function testAddRendererError1()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'DoesNotExist');
+ }
+
+ /**
+ * Try adding a class which does not implement RendererInterface as renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ */
+ public function testAddRendererError2()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'stdClass');
+ }
+
+ public function testAddRendererError3()
+ {
+ $map = new RendererMap();
+ @$map->addRenderer('Fruit3', 'stdClass');
+ self::assertNull($map->getByClassName('Fruit3'));
+
+ @$map->addRenderer('Fruit3', 'DoesNotExist');
+ self::assertNull($map->getByClassName('Fruit3'));
+ }
+
+ /**
+ * Try setting a non-existant class as default renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed setting default renderer. Rendering class [DoesNotExist] not found.
+ */
+ public function testSetDefaultRendererError1()
+ {
+ $map = new RendererMap();
+ $map->setDefaultRenderer('DoesNotExist');
+ }
+
+ /**
+ * Try setting a class which does not implement RendererInterface as default renderer.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed setting default renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ */
+ public function testSetDefaultRendererError2()
+ {
+ $map = new RendererMap();
+ $map->setDefaultRenderer('stdClass');
+ }
+
+ public function testSetDefaultRendererError3()
+ {
+ $map = new RendererMap();
+ $expected = $map->getDefaultRenderer();
+
+ @$map->setDefaultRenderer('stdClass');
+ $actual = $map->getDefaultRenderer();
+ self::assertSame($expected, $actual);
+
+ @$map->setDefaultRenderer('DoesNotExist');
+ $actual = $map->getDefaultRenderer();
+ self::assertSame($expected, $actual);
+ }
+
+ public function testFetchingRenderer()
+ {
+ $map = new RendererMap();
+ $map->addRenderer('Fruit3', 'FruitRenderer3');
+ }
+
+ public function testDefaultRenderer()
+ {
+ $fruit = new Fruit3();
+
+ $map = new RendererMap();
+ $actual = $map->findAndRender($fruit);
+
+ $defaultRenderer = new DefaultRenderer();
+ $expected = $defaultRenderer->render($fruit);
+ self::assertSame($expected, $actual);
+ }
+
+ public function testOverrideDefaultRenderer()
+ {
+ $map = new RendererMap();
+ $default = $map->getDefaultRenderer();
+
+ $array = array(1, 2, 3);
+
+ $actual = $map->findAndRender($array);
+ $expected = print_r($array, true);
+ self::assertSame($actual, $expected);
+
+ // Now switch the default renderer
+ $map->setDefaultRenderer('FooRenderer');
+ $actual = $map->findAndRender($array);
+ $expected = 'foo';
+ self::assertSame($actual, $expected);
+ }
+
+ public function testGetByObjectCrap()
+ {
+ $map = new RendererMap();
+
+ // Non object input should always return null
+ self::assertNull($map->getByObject(null));
+ self::assertNull($map->getByObject(array()));
+ self::assertNull($map->getByObject('sdasda'));
+ }
+
+ public function testXMLConfig()
+ {
+ $map = Logger::getHierarchy()->getRendererMap();
+ Logger::resetConfiguration();
+
+ $expected = 'Apache\\Log4php\\Renderers\\DefaultRenderer';
+ self::assertInstanceOf($expected, $map->getDefaultRenderer());
+
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_default_renderer.xml');
+ self::assertInstanceOf('FruitRenderer3', $map->getDefaultRenderer());
+
+ Logger::resetConfiguration();
+ self::assertInstanceOf($expected, $map->getDefaultRenderer());
+ }
+
+ public function testExceptionRenderer()
+ {
+ $ex = new LoggerException("This is a test");
+
+ $map = new RendererMap();
+ $actual = $map->findAndRender($ex);
+ $expected = (string) $ex;
+
+ self::assertSame($expected, $actual);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/RootLoggerTest.php
----------------------------------------------------------------------
diff --git a/tests/src/RootLoggerTest.php b/tests/src/RootLoggerTest.php
index aa6429e..471ed7e 100644
--- a/tests/src/RootLoggerTest.php
+++ b/tests/src/RootLoggerTest.php
@@ -29,39 +29,43 @@ use Apache\Log4php\RootLogger;
/**
* @group main
*/
-class RootLoggerTest extends \PHPUnit_Framework_TestCase {
+class RootLoggerTest extends \PHPUnit_Framework_TestCase
+{
+ public function testInitialSetup()
+ {
+ $root = new RootLogger();
+ self::assertSame(Level::getLevelAll(), $root->getLevel());
+ self::assertSame(Level::getLevelAll(), $root->getEffectiveLevel());
+ self::assertSame('root', $root->getName());
+ self::assertNull($root->getParent());
+ }
- public function testInitialSetup() {
- $root = new RootLogger();
- self::assertSame(Level::getLevelAll(), $root->getLevel());
- self::assertSame(Level::getLevelAll(), $root->getEffectiveLevel());
- self::assertSame('root', $root->getName());
- self::assertNull($root->getParent());
- }
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: RootLogger cannot have a parent.
+ */
+ public function testSetParentWarning()
+ {
+ $root = new RootLogger();
+ $logger = new Logger('test');
+ $root->setParent($logger);
+ }
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: RootLogger cannot have a parent.
- */
- public function testSetParentWarning() {
- $root = new RootLogger();
- $logger = new Logger('test');
- $root->setParent($logger);
- }
+ public function testSetParentResult()
+ {
+ $root = new RootLogger();
+ $logger = new Logger('test');
+ @$root->setParent($logger);
+ self::assertNull($root->getParent());
+ }
- public function testSetParentResult() {
- $root = new RootLogger();
- $logger = new Logger('test');
- @$root->setParent($logger);
- self::assertNull($root->getParent());
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Cannot set RootLogger level to null.
- */
- public function testNullLevelWarning() {
- $root = new RootLogger();
- $root->setLevel(null);
- }
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Cannot set RootLogger level to null.
+ */
+ public function testNullLevelWarning()
+ {
+ $root = new RootLogger();
+ $root->setLevel(null);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/TestHelper.php
----------------------------------------------------------------------
diff --git a/tests/src/TestHelper.php b/tests/src/TestHelper.php
index c653eca..5366e6d 100644
--- a/tests/src/TestHelper.php
+++ b/tests/src/TestHelper.php
@@ -29,132 +29,141 @@ use Apache\Log4php\Logger;
use Apache\Log4php\LoggingEvent;
/** A set of helper functions for running tests. */
-class TestHelper {
-
- /**
- * Returns a test logging event with level set to TRACE.
- * @return LoggingEvent
- */
- public static function getTraceEvent($message = 'test', $logger = "test") {
- return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelTrace(), $message);
- }
-
- /**
- * Returns a test logging event with level set to DEBUG.
- * @return LoggingEvent
- */
- public static function getDebugEvent($message = 'test', $logger = "test") {
- return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelDebug(), $message);
- }
-
- /**
- * Returns a test logging event with level set to INFO.
- * @return LoggingEvent
- */
- public static function getInfoEvent($message = 'test', $logger = "test") {
- return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelInfo(), $message);
- }
-
- /**
- * Returns a test logging event with level set to WARN.
- * @return LoggingEvent
- */
- public static function getWarnEvent($message = 'test', $logger = "test") {
- return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelWarn(), $message);
- }
-
- /**
- * Returns a test logging event with level set to ERROR.
- * @return LoggingEvent
- */
- public static function getErrorEvent($message = 'test', $logger = "test") {
- return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelError(), $message);
- }
-
- /**
- * Returns a test logging event with level set to FATAL.
- * @return LoggingEvent
- */
- public static function getFatalEvent($message = 'test', $logger = "test") {
- return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelFatal(), $message);
- }
-
- /**
- * Returns an array of logging events, one for each level, sorted ascending
- * by severitiy.
- */
- public static function getAllEvents($message = 'test') {
- return array(
- self::getTraceEvent($message),
- self::getDebugEvent($message),
- self::getInfoEvent($message),
- self::getWarnEvent($message),
- self::getErrorEvent($message),
- self::getFatalEvent($message),
- );
- }
-
- /** Returns an array of all existing levels, sorted ascending by severity. */
- public static function getAllLevels() {
- return array(
- Level::getLevelTrace(),
- Level::getLevelDebug(),
- Level::getLevelInfo(),
- Level::getLevelWarn(),
- Level::getLevelError(),
- Level::getLevelFatal(),
- );
- }
-
- /** Returns a string representation of a filter decision. */
- public static function decisionToString($decision) {
- switch($decision) {
- case AbstractFilter::ACCEPT: return 'ACCEPT';
- case AbstractFilter::NEUTRAL: return 'NEUTRAL';
- case AbstractFilter::DENY: return 'DENY';
- }
- }
-
- /** Returns a simple configuration with one echo appender tied to root logger. */
- public static function getEchoConfig() {
- return array(
- 'threshold' => 'ALL',
- 'rootLogger' => array(
- 'level' => 'trace',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'SimpleLayout',
- ),
- ),
- ),
- );
- }
-
- /** Returns a simple configuration with one echo appender using the pattern layout. */
- public static function getEchoPatternConfig($pattern) {
- return array(
- 'threshold' => 'ALL',
- 'rootLogger' => array(
- 'level' => 'trace',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'EchoAppender',
- 'layout' => array(
- 'class' => 'PatternLayout',
- 'params' => array(
- 'conversionPattern' => $pattern
- )
- ),
- ),
- ),
- );
- }
+class TestHelper
+{
+ /**
+ * Returns a test logging event with level set to TRACE.
+ * @return LoggingEvent
+ */
+ public static function getTraceEvent($message = 'test', $logger = "test")
+ {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelTrace(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to DEBUG.
+ * @return LoggingEvent
+ */
+ public static function getDebugEvent($message = 'test', $logger = "test")
+ {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelDebug(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to INFO.
+ * @return LoggingEvent
+ */
+ public static function getInfoEvent($message = 'test', $logger = "test")
+ {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelInfo(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to WARN.
+ * @return LoggingEvent
+ */
+ public static function getWarnEvent($message = 'test', $logger = "test")
+ {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelWarn(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to ERROR.
+ * @return LoggingEvent
+ */
+ public static function getErrorEvent($message = 'test', $logger = "test")
+ {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelError(), $message);
+ }
+
+ /**
+ * Returns a test logging event with level set to FATAL.
+ * @return LoggingEvent
+ */
+ public static function getFatalEvent($message = 'test', $logger = "test")
+ {
+ return new LoggingEvent(__CLASS__, new Logger($logger), Level::getLevelFatal(), $message);
+ }
+
+ /**
+ * Returns an array of logging events, one for each level, sorted ascending
+ * by severitiy.
+ */
+ public static function getAllEvents($message = 'test')
+ {
+ return array(
+ self::getTraceEvent($message),
+ self::getDebugEvent($message),
+ self::getInfoEvent($message),
+ self::getWarnEvent($message),
+ self::getErrorEvent($message),
+ self::getFatalEvent($message),
+ );
+ }
+
+ /** Returns an array of all existing levels, sorted ascending by severity. */
+ public static function getAllLevels()
+ {
+ return array(
+ Level::getLevelTrace(),
+ Level::getLevelDebug(),
+ Level::getLevelInfo(),
+ Level::getLevelWarn(),
+ Level::getLevelError(),
+ Level::getLevelFatal(),
+ );
+ }
+
+ /** Returns a string representation of a filter decision. */
+ public static function decisionToString($decision)
+ {
+ switch ($decision) {
+ case AbstractFilter::ACCEPT: return 'ACCEPT';
+ case AbstractFilter::NEUTRAL: return 'NEUTRAL';
+ case AbstractFilter::DENY: return 'DENY';
+ }
+ }
+
+ /** Returns a simple configuration with one echo appender tied to root logger. */
+ public static function getEchoConfig()
+ {
+ return array(
+ 'threshold' => 'ALL',
+ 'rootLogger' => array(
+ 'level' => 'trace',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout',
+ ),
+ ),
+ ),
+ );
+ }
+
+ /** Returns a simple configuration with one echo appender using the pattern layout. */
+ public static function getEchoPatternConfig($pattern)
+ {
+ return array(
+ 'threshold' => 'ALL',
+ 'rootLogger' => array(
+ 'level' => 'trace',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => $pattern
+ )
+ ),
+ ),
+ ),
+ );
+ }
}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/tests/src/ThrowableInformationTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ThrowableInformationTest.php b/tests/src/ThrowableInformationTest.php
index 9d230da..d07c945 100644
--- a/tests/src/ThrowableInformationTest.php
+++ b/tests/src/ThrowableInformationTest.php
@@ -29,30 +29,33 @@ class ThrowableInformationTestException extends \Exception { }
/**
* @group main
*/
-class ThrowableInformationTest extends \PHPUnit_Framework_TestCase {
-
- public function testConstructor() {
- $ex = new \Exception();
- $tInfo = new ThrowableInformation($ex);
-
- $result = $tInfo->getStringRepresentation();
- $this->assertInternalType('array', $result);
- }
-
- public function testExceptionChain() {
- $ex1 = new ThrowableInformationTestException('Message1');
- $ex2 = new ThrowableInformationTestException('Message2', 0, $ex1);
- $ex3 = new ThrowableInformationTestException('Message3', 0, $ex2);
-
- $tInfo = new ThrowableInformation($ex3);
- $result = $tInfo->getStringRepresentation();
- $this->assertInternalType('array', $result);
- }
-
- public function testGetThrowable() {
- $ex = new ThrowableInformationTestException('Message1');
- $tInfo = new ThrowableInformation($ex);
- $result = $tInfo->getThrowable();
- $this->assertEquals($ex, $result);
- }
+class ThrowableInformationTest extends \PHPUnit_Framework_TestCase
+{
+ public function testConstructor()
+ {
+ $ex = new \Exception();
+ $tInfo = new ThrowableInformation($ex);
+
+ $result = $tInfo->getStringRepresentation();
+ $this->assertInternalType('array', $result);
+ }
+
+ public function testExceptionChain()
+ {
+ $ex1 = new ThrowableInformationTestException('Message1');
+ $ex2 = new ThrowableInformationTestException('Message2', 0, $ex1);
+ $ex3 = new ThrowableInformationTestException('Message3', 0, $ex2);
+
+ $tInfo = new ThrowableInformation($ex3);
+ $result = $tInfo->getStringRepresentation();
+ $this->assertInternalType('array', $result);
+ }
+
+ public function testGetThrowable()
+ {
+ $ex = new ThrowableInformationTestException('Message1');
+ $tInfo = new ThrowableInformation($ex);
+ $result = $tInfo->getThrowable();
+ $this->assertEquals($ex, $result);
+ }
}
[02/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/ConfiguratorTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ConfiguratorTest.php b/tests/src/ConfiguratorTest.php
new file mode 100644
index 0000000..b6fb802
--- /dev/null
+++ b/tests/src/ConfiguratorTest.php
@@ -0,0 +1,453 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\Renderers\RendererInterface;
+use Apache\Log4php\Configuration\DefaultConfigurator;
+
+use Mockery as m;
+
+class CostumDefaultRenderer implements RendererInterface {
+ public function render($o) { }
+}
+
+/**
+ * @group configuration
+ */
+ class ConfiguratorTest extends \PHPUnit_Framework_TestCase
+ {
+ /** Reset configuration after each test. */
+ public function setUp() {
+ Logger::resetConfiguration();
+ }
+ /** Reset configuration after each test. */
+ public function tearDown() {
+ Logger::resetConfiguration();
+ }
+
+ /** Check default setup. */
+ public function testDefaultConfig() {
+ Logger::configure();
+
+ $actual = Logger::getCurrentLoggers();
+ $expected = array();
+ $this->assertSame($expected, $actual);
+
+ $appenders = Logger::getRootLogger()->getAllAppenders();
+ $this->assertInternalType('array', $appenders);
+ $this->assertEquals(count($appenders), 1);
+
+ $names = array_keys($appenders);
+ $this->assertSame('default', $names[0]);
+
+ $appender = array_shift($appenders);
+ $this->assertInstanceOf('Apache\\Log4php\\Appenders\\EchoAppender', $appender);
+ $this->assertSame('default', $appender->getName());
+
+ $layout = $appender->getLayout();
+ $this->assertInstanceOf('Apache\\Log4php\\Layouts\\SimpleLayout', $layout);
+
+ $root = Logger::getRootLogger();
+ $appenders = $root->getAllAppenders();
+ $this->assertInternalType('array', $appenders);
+ $this->assertEquals(count($appenders), 1);
+
+ $actual = $root->getLevel();
+ $expected = Level::getLevelDebug();
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid configuration param given. Reverting to default configuration.
+ */
+ public function testInputIsInteger() {
+ Logger::configure(12345);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Configuration failed. Unsupported configuration file extension: yml
+ */
+ public function testYAMLFile() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/config.yml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid configuration provided for appender
+ */
+ public function testAppenderConfigNotArray() {
+ $config = array(
+ 'appenders' => array(
+ 'default',
+ ),
+ );
+
+ $hierachyMock = m::mock("Apache\\Log4php\\Hierarchy");
+ $configurator = new DefaultConfigurator();
+ $configurator->configure($hierachyMock, $config);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage No class given for appender
+ */
+ public function testNoAppenderClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid class [unknownClass] given for appender [foo]. Class does not exist. Skipping appender definition.
+ */
+ public function testNotExistingAppenderClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid class [stdClass] given for appender [foo]. Not a valid Appender class. Skipping appender definition.
+ */
+ public function testInvalidAppenderClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_appender_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistant filter class [Foo] specified on appender [foo]. Skipping filter definition.
+ */
+ public function testNotExistingAppenderFilterClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_filter_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistant option [fooParameter] specified on [Apache\Log4php\Filters\StringMatchFilter]. Skipping.
+ */
+ public function testInvalidAppenderFilterParamter() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_parameters.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid filter class [stdClass] sepcified on appender [foo]. Skipping filter definition.
+ */
+ public function testInvalidAppenderFilterClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistant layout class [Foo] specified for appender [foo]. Reverting to default layout.
+ */
+ public function testNotExistingAppenderLayoutClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_layout_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid layout class [stdClass] sepcified for appender [foo]. Reverting to default layout.
+ */
+ public function testInvalidAppenderLayoutClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_layout_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Layout class not specified for appender [foo]. Reverting to default layout.
+ */
+ public function testNoAppenderLayoutClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_layout_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the RendererInterface interface.
+ */
+ public function testInvalidRenderingClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_invalid_rendering_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Rendering class not specified. Skipping renderer definition.
+ */
+ public function testNoRenderingClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendering_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Rendered class not specified. Skipping renderer definition.
+ */
+ public function testNoRenderedClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendered_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExistRenderer] not found.
+ */
+ public function testNotExistingRenderingClassSet() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_not_existing_rendering_class.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid additivity value [4711] specified for logger [myLogger].
+ */
+ public function testInvalidLoggerAddivity() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_invalid_additivity.xml');
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Nonexistnant appender [unknownAppender] linked to logger [myLogger].
+ */
+ public function testNotExistingLoggerAppendersClass() {
+ Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_not_existing_appenders.xml');
+ }
+
+ /**
+ * Test that an error is reported when config file is not found.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Configuration failed. File not found
+ */
+ public function testNonexistantFile() {
+ Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
+
+ }
+
+ /** Test correct fallback to the default configuration. */
+ public function testNonexistantFileFallback() {
+ @Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
+ $this->testDefaultConfig();
+ }
+
+ public function testAppendersWithLayout() {
+ $config = Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('app1', 'app2')
+ ),
+ 'loggers' => array(
+ 'myLogger' => array(
+ 'appenders' => array('app1'),
+ 'additivity'=> true
+ )
+ ),
+ 'renderers' => array(
+ array('renderedClass' => 'stdClass', 'renderingClass' => 'DefaultRenderer')
+ ),
+ 'appenders' => array(
+ 'app1' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array(
+ 'htmlLineBreaks' => false
+ )
+ ),
+ 'app2' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => 'message: %m%n'
+ )
+ ),
+ 'filters' => array(
+ array(
+ 'class' => 'StringMatchFilter',
+ 'params'=> array(
+ 'stringToMatch' => 'foo',
+ 'acceptOnMatch' => false
+ )
+ )
+ )
+ ),
+ )
+ ));
+
+ ob_start();
+ Logger::getRootLogger()->info('info');
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $expected = "INFO - info" . PHP_EOL . "message: info" . PHP_EOL;
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testThreshold()
+ {
+ Logger::configure(array(
+ 'threshold' => 'WARN',
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+
+ $actual = Logger::getHierarchy()->getThreshold();
+ $expected = Level::getLevelWarn();
+
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid threshold value [FOO] specified. Ignoring threshold definition.
+ */
+ public function testInvalidThreshold()
+ {
+ Logger::configure(array(
+ 'threshold' => 'FOO',
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+ }
+
+ public function testAppenderThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'threshold' => 'INFO'
+ ),
+ )
+ ));
+
+ $actual = Logger::getRootLogger()->getAppender('default')->getThreshold();
+ $expected = Level::getLevelInfo();
+
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid threshold value [FOO] specified for appender [default]. Ignoring threshold definition.
+ */
+ public function testAppenderInvalidThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'threshold' => 'FOO'
+ ),
+ )
+ ));
+ }
+
+ public function testLoggerThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ 'level' => 'ERROR'
+ ),
+ 'loggers' => array(
+ 'default' => array(
+ 'appenders' => array('default'),
+ 'level' => 'WARN'
+ )
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+
+ // Check root logger
+ $actual = Logger::getRootLogger()->getLevel();
+ $expected = Level::getLevelError();
+ self::assertSame($expected, $actual);
+
+ // Check default logger
+ $actual = Logger::getLogger('default')->getLevel();
+ $expected = Level::getLevelWarn();
+ self::assertSame($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid level value [FOO] specified for logger [default]. Ignoring level definition.
+ */
+ public function testInvalidLoggerThreshold()
+ {
+ Logger::configure(array(
+ 'loggers' => array(
+ 'default' => array(
+ 'appenders' => array('default'),
+ 'level' => 'FOO'
+ )
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid level value [FOO] specified for logger [root]. Ignoring level definition.
+ */
+ public function testInvalidRootLoggerThreshold()
+ {
+ Logger::configure(array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ 'level' => 'FOO'
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ ),
+ )
+ ));
+ }
+ }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Configurators/INIAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/INIAdapterTest.php b/tests/src/Configurators/INIAdapterTest.php
new file mode 100644
index 0000000..92d2380
--- /dev/null
+++ b/tests/src/Configurators/INIAdapterTest.php
@@ -0,0 +1,177 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @package log4php
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Configuration;
+
+use Apache\Log4php\Configuration\Adapters\IniAdapter;
+use Apache\Log4php\Helpers\OptionConverter;
+use Apache\Log4php\LoggerException;
+
+/**
+ * @group configuration
+ */
+class INIAdapterTest extends \PHPUnit_Framework_TestCase {
+
+ /** Expected output of parsing config1.ini. */
+ private $expected1 = array(
+ 'threshold' => 'debug',
+ 'rootLogger' => array(
+ 'level' => 'DEBUG',
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'LoggerLayoutTTCC',
+ ),
+ ),
+ 'file' => array(
+ 'class' => 'DailyFileAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
+ ),
+ ),
+ 'params' => array(
+ 'datePattern' => 'Ymd',
+ 'file' => 'target/examples/daily_%s.log',
+ ),
+ 'threshold' => 'warn'
+ ),
+ ),
+ 'loggers' => array(
+ 'foo' => array(
+ 'level' => 'warn',
+ 'appenders' => array('default'),
+ ),
+ 'foo.bar' => array(
+ 'level' => 'debug',
+ 'appenders' => array('file'),
+ 'additivity' => 'true',
+ ),
+ 'foo.bar.baz' => array(
+ 'level' => 'trace',
+ 'appenders' => array('default', 'file'),
+ 'additivity' => 'false',
+ ),
+ ),
+ 'renderers' => array(
+ array(
+ 'renderedClass' => 'Fruit',
+ 'renderingClass' => 'FruitRenderer',
+ ),
+ array(
+ 'renderedClass' => 'Beer',
+ 'renderingClass' => 'BeerRenderer',
+ ),
+ ),
+ );
+
+ public function testConfig() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_valid.ini';
+ $adapter = new IniAdapter();
+ $actual = $adapter->convert($url);
+
+ $this->assertSame($this->expected1, $actual);
+ }
+
+ /**
+ * Test exception is thrown when file cannot be found.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage File [you/will/never/find/me.ini] does not exist.
+ */
+ public function testNonExistantFileException() {
+ $adapter = new IniAdapter();
+ $adapter->convert('you/will/never/find/me.ini');
+ }
+
+ /**
+ * Test exception is thrown when file is not a valid ini file.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Error parsing configuration file
+ */
+ public function testInvalidFileException() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_syntax.ini';
+ $adapter = new IniAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test a warning is triggered when configurator doesn't understand a line.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.layout.param.bla = LoggerLayoutTTCC". Skipping.
+ */
+ public function testInvalidLineWarning1() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_1.ini';
+ $adapter = new IniAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test a warning is triggered when configurator doesn't understand a line.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.not-layout.param = LoggerLayoutTTCC". Skipping.
+ */
+ public function testInvalidLineWarning2() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_2.ini';
+ $adapter = new IniAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Check that various boolean equivalents from ini file convert properly
+ * to boolean.
+ */
+ public function testBooleanValues() {
+ $values = parse_ini_file(PHPUNIT_CONFIG_DIR . '/adapters/ini/values.ini');
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_true']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_yes']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_false']);
+ self::assertFalse($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_no']);
+ self::assertFalse($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['quoted_true']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['quoted_false']);
+ self::assertFalse($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_one']);
+ self::assertTrue($actual);
+
+ $actual = OptionConverter::toBooleanEx($values['unquoted_zero']);
+ self::assertFalse($actual);
+ }
+
+}
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Configurators/PHPAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/PHPAdapterTest.php b/tests/src/Configurators/PHPAdapterTest.php
new file mode 100644
index 0000000..2b79826
--- /dev/null
+++ b/tests/src/Configurators/PHPAdapterTest.php
@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @package log4php
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Configuration;
+
+use Apache\Log4php\Configuration\Adapters\PhpAdapter;
+
+/**
+ * @group configuration
+ */
+class PHPAdapterTest extends \PHPUnit_Framework_TestCase {
+
+ private $expected1 = array(
+ 'rootLogger' => array(
+ 'level' => 'info',
+ 'appenders' => array('default')
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ )
+ )
+ );
+
+ public function testConfig() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_valid.php';
+ $adapter = new PhpAdapter();
+ $actual = $adapter->convert($url);
+
+ $this->assertSame($this->expected1, $actual);
+ }
+
+ /**
+ * Test exception is thrown when file cannot be found.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
+ */
+ public function testNonExistantFileWarning() {
+ $adapter = new PhpAdapter();
+ $adapter->convert('you/will/never/find/me.conf');
+ }
+
+ /**
+ * Test exception is thrown when file is not valid.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Error parsing configuration: syntax error
+ */
+ public function testInvalidFileWarning() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_invalid_syntax.php';
+ $adapter = new PhpAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test exception is thrown when the configuration is empty.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Invalid configuration: empty configuration array.
+ */
+ public function testEmptyConfigWarning() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_empty.php';
+ $adapter = new PhpAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test exception is thrown when the configuration does not contain an array.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Invalid configuration: not an array.
+ */
+ public function testInvalidConfigWarning() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_not_an_array.php';
+ $adapter = new PhpAdapter();
+ $adapter->convert($url);
+ }
+}
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Configurators/XMLAdapterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Configurators/XMLAdapterTest.php b/tests/src/Configurators/XMLAdapterTest.php
new file mode 100644
index 0000000..3c4dbe2
--- /dev/null
+++ b/tests/src/Configurators/XMLAdapterTest.php
@@ -0,0 +1,178 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @package log4php
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Configuration;
+
+use Apache\Log4php\Logger;
+use Apache\Log4php\Configuration\Adapters\XmlAdapter;
+
+/**
+ * @group configuration
+ */
+class XMLAdapterTest extends \PHPUnit_Framework_TestCase {
+
+ /** Expected output of parsing config1.xml.*/
+ private $expected1 = array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'LoggerLayoutTTCC',
+ ),
+ 'filters' => array(
+ array(
+ 'class' => 'LevelRangeFilter',
+ 'params' => array(
+ 'levelMin' => 'ERROR',
+ 'levelMax' => 'FATAL',
+ 'acceptOnMatch' => 'false',
+ ),
+ ),
+ array(
+ 'class' => 'DenyAllFilter',
+ ),
+ ),
+ ),
+ 'file' => array(
+ 'class' => 'DailyFileAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
+ ),
+ ),
+ 'params' => array(
+ 'datePattern' => 'Ymd',
+ 'file' => 'target/examples/daily_%s.log',
+ ),
+ 'threshold' => 'warn'
+ ),
+ ),
+ 'loggers' => array(
+ 'foo.bar.baz' => array(
+ 'level' => 'trace',
+ 'additivity' => 'false',
+ 'appenders' => array('default'),
+ ),
+ 'foo.bar' => array(
+ 'level' => 'debug',
+ 'additivity' => 'true',
+ 'appenders' => array('file'),
+ ),
+ 'foo' => array(
+ 'level' => 'warn',
+ 'appenders' => array('default', 'file'),
+ ),
+ ),
+ 'renderers' => array(
+ array(
+ 'renderedClass' => 'Fruit',
+ 'renderingClass' => 'FruitRenderer',
+ ),
+ array(
+ 'renderedClass' => 'Beer',
+ 'renderingClass' => 'BeerRenderer',
+ ),
+ ),
+ 'threshold' => 'debug',
+ 'rootLogger' => array(
+ 'level' => 'DEBUG',
+ 'appenders' => array('default'),
+ ),
+ );
+
+ public function setUp() {
+ Logger::resetConfiguration();
+ }
+
+ public function tearDown() {
+ Logger::resetConfiguration();
+ }
+
+ public function testConversion() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid.xml';
+ $adapter = new XmlAdapter();
+ $actual = $adapter->convert($url);
+ $this->assertEquals($this->expected1, $actual);
+ }
+
+ public function testConversion2() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid_underscore.xml';
+ $adapter = new XmlAdapter();
+ $actual = $adapter->convert($url);
+
+ $this->assertEquals($this->expected1, $actual);
+ }
+
+ /**
+ * Test exception is thrown when file cannot be found.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
+ */
+ public function testNonExistantFile() {
+ $adapter = new XmlAdapter();
+ $adapter->convert('you/will/never/find/me.conf');
+ }
+
+ /**
+ * Test exception is thrown when file contains invalid XML.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Error loading configuration file: Premature end of data in tag configuration line
+ */
+ public function testInvalidXMLFile() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_invalid_syntax.xml';
+ $adapter = new XmlAdapter();
+ $adapter->convert($url);
+ }
+
+ /**
+ * Test that a warning is triggered when two loggers with the same name
+ * are defined.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Duplicate logger definition [foo]. Overwriting
+ */
+ public function testDuplicateLoggerWarning() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
+ $adapter = new XmlAdapter();
+ $adapter->convert($url);
+ }
+
+
+ /**
+ * Test that when two loggers with the same name are defined, the second
+ * one will overwrite the first.
+ */
+ public function testDuplicateLoggerConfig() {
+ $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
+ $adapter = new XmlAdapter();
+
+ // Supress the warning so that test can continue
+ $config = @$adapter->convert($url);
+
+ // Second definition of foo has level set to warn (the first to info)
+ $this->assertEquals('warn', $config['loggers']['foo']['level']);
+ }
+}
+
+?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/ExceptionTest.php
----------------------------------------------------------------------
diff --git a/tests/src/ExceptionTest.php b/tests/src/ExceptionTest.php
new file mode 100644
index 0000000..5b56f9e
--- /dev/null
+++ b/tests/src/ExceptionTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\LoggerException;
+
+/**
+ * @group main
+ */
+class ExceptionTest extends \PHPUnit_Framework_TestCase {
+ /**
+ * @expectedException Apache\Log4php\LoggerException
+ */
+ public function testMessage() {
+ try {
+ throw new LoggerException("TEST");
+ } catch (LoggerException $e) {
+ self::assertEquals("TEST", $e->getMessage());
+ throw $e;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/FilterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/FilterTest.php b/tests/src/FilterTest.php
new file mode 100644
index 0000000..e54d01b
--- /dev/null
+++ b/tests/src/FilterTest.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Level;
+
+class MyFilter extends AbstractFilter {}
+
+/**
+ * @group filters
+ */
+class FilterTest extends \PHPUnit_Framework_TestCase {
+
+ public function testDecide() {
+ $filter = new MyFilter();
+ // activateOptions is empty, but should at least throw no exeception
+ $filter->activateOptions();
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Filters/FilterDenyAllTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterDenyAllTest.php b/tests/src/Filters/FilterDenyAllTest.php
new file mode 100644
index 0000000..ac41f3b
--- /dev/null
+++ b/tests/src/Filters/FilterDenyAllTest.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Configuration\DefaultConfigurator;
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Filters\DenyAllFilter;
+use Apache\Log4php\Logger;
+
+/**
+ * @group filters
+ */
+class FilterDenyAllTest extends \PHPUnit_Framework_TestCase {
+
+ public function testDecide() {
+ $filter = new DenyAllFilter();
+
+ $events = array(
+ TestHelper::getTraceEvent(),
+ TestHelper::getDebugEvent(),
+ TestHelper::getInfoEvent(),
+ TestHelper::getWarnEvent(),
+ TestHelper::getErrorEvent(),
+ TestHelper::getFatalEvent(),
+ );
+
+ foreach($events as $event) {
+ $actual = $filter->decide($event);
+ self::assertEquals(AbstractFilter::DENY, $actual);
+ }
+ }
+
+ public function testConfiguration() {
+ $config = DefaultConfigurator::getDefaultConfiguration();
+ $config['appenders']['default']['filters'] = array(
+ array(
+ 'class' => 'DenyAllFilter'
+ )
+ );
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+
+ ob_start();
+ $logger->trace('Test');
+ $logger->debug('Test');
+ $logger->info('Test');
+ $logger->warn('Test');
+ $logger->error('Test');
+ $logger->fatal('Test');
+ $actual = ob_get_clean();
+
+ $this->assertEmpty($actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Filters/FilterLevelMatchTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterLevelMatchTest.php b/tests/src/Filters/FilterLevelMatchTest.php
new file mode 100644
index 0000000..28f5601
--- /dev/null
+++ b/tests/src/Filters/FilterLevelMatchTest.php
@@ -0,0 +1,184 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Filters\LevelMatchFilter;
+use Apache\Log4php\Logger;
+
+/**
+ * @group filters
+ */
+class FilterLevelMatchTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * Tests all possible combinations of event level and filter levelToMatch
+ * option, with acceptOnMatch set to TRUE.
+ */
+ public function testDecideAccept() {
+ $filter = new LevelMatchFilter();
+ $filter->setAcceptOnMatch("true");
+
+ $levels = TestHelper::getAllLevels();
+ $events = TestHelper::getAllEvents();
+
+ foreach($levels as $level) {
+ $filter->setLevelToMatch($level);
+
+ foreach($events as $event) {
+ // Expecting given level to be accepted, neutral for others
+ $expected = ($event->getLevel() == $level) ? AbstractFilter::ACCEPT : AbstractFilter::NEUTRAL;
+ $actual = $filter->decide($event);
+
+ // Get string represenations for logging
+ $sExpected = TestHelper::decisionToString($expected);
+ $sActual = TestHelper::decisionToString($actual);
+
+ $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
+ }
+ }
+ }
+
+ /**
+ * Tests all possible combinations of event level and filter levelToMatch
+ * option, with acceptOnMatch set to TRUE.
+ */
+ public function testDecideDeny() {
+ $filter = new LevelMatchFilter();
+ $filter->setAcceptOnMatch("false");
+
+ $levels = TestHelper::getAllLevels();
+ $events = TestHelper::getAllEvents();
+
+ foreach($levels as $level) {
+ $filter->setLevelToMatch($level);
+
+ foreach($events as $event) {
+ // Expecting given level to be denied, neutral for others
+ $expected = ($event->getLevel() == $level) ? AbstractFilter::DENY : AbstractFilter::NEUTRAL;
+ $actual = $filter->decide($event);
+
+ // Get string represenations for logging
+ $sExpected = TestHelper::decisionToString($expected);
+ $sActual = TestHelper::decisionToString($actual);
+
+ $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
+ }
+ }
+ }
+
+ /** Test that filter always decides NEUTRAL when levelToMatch is not set. */
+ public function testDecideNull() {
+ $filter = new LevelMatchFilter();
+ $events = TestHelper::getAllEvents();
+
+ foreach($events as $event) {
+ $expected = AbstractFilter::NEUTRAL;
+ $actual = $filter->decide($event);
+
+ // Get string represenations for logging
+ $sExpected = TestHelper::decisionToString($expected);
+ $sActual = TestHelper::decisionToString($actual);
+ $level = $event->getLevel();
+
+ $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
+ }
+ }
+
+ /** Test logger configuration. */
+ public function testAcceptConfig() {
+ $config = TestHelper::getEchoConfig();
+
+ // Add filters to default appender
+ $config['appenders']['default']['filters'] = array(
+
+ // Accepts only INFO events
+ array(
+ 'class' => 'LevelMatchFilter',
+ 'params' => array(
+ 'levelToMatch' => 'info',
+ 'acceptOnMatch' => true
+ )
+ ),
+
+ // Denies all events not accepted by first filter
+ array(
+ 'class' => 'DenyAllFilter',
+ )
+ );
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+
+ ob_start();
+ $logger->trace('Test');
+ $logger->debug('Test');
+ $logger->info('Test');
+ $logger->warn('Test');
+ $logger->error('Test');
+ $logger->fatal('Test');
+
+ $actual = ob_get_clean();
+
+
+ $expected = "INFO - Test" . PHP_EOL;
+ }
+
+ public function testDenyConfig() {
+ $config = TestHelper::getEchoConfig();
+
+ // Add filter which denies INFO events
+ $config['appenders']['default']['filters'] = array(
+ array(
+ 'class' => 'LevelMatchFilter',
+ 'params' => array(
+ 'levelToMatch' => 'info',
+ 'acceptOnMatch' => false
+ )
+ )
+ );
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+
+ ob_start();
+ $logger->trace('Test');
+ $logger->debug('Test');
+ $logger->info('Test');
+ $logger->warn('Test');
+ $logger->error('Test');
+ $logger->fatal('Test');
+
+ $actual = ob_get_clean();
+
+ // Should log all except info
+ $expected =
+ "TRACE - Test" . PHP_EOL .
+ "DEBUG - Test" . PHP_EOL .
+ "WARN - Test" . PHP_EOL .
+ "ERROR - Test" . PHP_EOL .
+ "FATAL - Test" . PHP_EOL;
+
+ $this->assertSame($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Filters/FilterLevelRangeTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterLevelRangeTest.php b/tests/src/Filters/FilterLevelRangeTest.php
new file mode 100644
index 0000000..31999eb
--- /dev/null
+++ b/tests/src/Filters/FilterLevelRangeTest.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Filters\LevelRangeFilter;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group filters
+ */
+class FilterLevelRangeTest extends \PHPUnit_Framework_TestCase {
+
+ public function testDecide() {
+ $filter = new LevelRangeFilter();
+ $filter->setAcceptOnMatch("true");
+ $filter->setLevelMin(Level::getLevelWarn());
+ $filter->setLevelMax(Level::getLevelError());
+
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+ }
+
+ public function testDecideAcceptFalse() {
+ $filter = new LevelRangeFilter();
+ $filter->setAcceptOnMatch("false");
+ $filter->setLevelMin(Level::getLevelWarn());
+ $filter->setLevelMax(Level::getLevelError());
+
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+ }
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Filters/FilterStringMatchTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Filters/FilterStringMatchTest.php b/tests/src/Filters/FilterStringMatchTest.php
new file mode 100644
index 0000000..5618412
--- /dev/null
+++ b/tests/src/Filters/FilterStringMatchTest.php
@@ -0,0 +1,118 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Filters\AbstractFilter;
+use Apache\Log4php\Filters\StringMatchFilter;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group filters
+ */
+class FilterStringMatchTest extends \PHPUnit_Framework_TestCase {
+
+ public function testDecideAccept() {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("true");
+ $filter->setStringToMatch("testmessage");
+
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventError2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "xyz");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "xyz");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ $eventWarn2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "xyz");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventError2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventDebug2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::ACCEPT);
+
+ $result = $filter->decide($eventWarn2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+
+ public function testDecideDeny() {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("false");
+ $filter->setStringToMatch("testmessage");
+
+ $eventError = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventError2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "xyz");
+ $eventDebug = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $eventDebug2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "xyz");
+ $eventWarn = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ $eventWarn2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "xyz");
+
+ $result = $filter->decide($eventError);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventError2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventDebug);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventDebug2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+
+ $result = $filter->decide($eventWarn);
+ self::assertEquals($result, AbstractFilter::DENY);
+
+ $result = $filter->decide($eventWarn2);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+
+ public function testDecideNullMessage() {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("false");
+ $filter->setStringToMatch("testmessage");
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), null);
+
+ $result = $filter->decide($event);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+
+ public function testDecideNullMatch() {
+ $filter = new StringMatchFilter();
+ $filter->setAcceptOnMatch("false");
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $result = $filter->decide($event);
+ self::assertEquals($result, AbstractFilter::NEUTRAL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Helpers/OptionConverterTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Helpers/OptionConverterTest.php b/tests/src/Helpers/OptionConverterTest.php
new file mode 100644
index 0000000..6c00e43
--- /dev/null
+++ b/tests/src/Helpers/OptionConverterTest.php
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Helpers;
+
+use Apache\Log4php\Helpers\OptionConverter;
+use Apache\Log4php\Appenders\FileAppender;
+
+define('MY_CONSTANT_CONSTANT', 'DEFINE');
+define('MY_CONSTANT_CONSTANT_OTHER', 'DEFINE_OTHER');
+
+/**
+ * @group helpers
+ */
+class OptionConverterTest extends \PHPUnit_Framework_TestCase {
+
+ public function testToBoolean() {
+ self::assertTrue(OptionConverter::toBooleanEx(1));
+ self::assertTrue(OptionConverter::toBooleanEx("1"));
+ self::assertTrue(OptionConverter::toBooleanEx(true));
+ self::assertTrue(OptionConverter::toBooleanEx("true"));
+ self::assertTrue(OptionConverter::toBooleanEx("on"));
+ self::assertTrue(OptionConverter::toBooleanEx("yes"));
+
+ self::assertFalse(OptionConverter::toBooleanEx(0));
+ self::assertFalse(OptionConverter::toBooleanEx("0"));
+ self::assertFalse(OptionConverter::toBooleanEx(false));
+ self::assertFalse(OptionConverter::toBooleanEx("false"));
+ self::assertFalse(OptionConverter::toBooleanEx("off"));
+ self::assertFalse(OptionConverter::toBooleanEx("no"));
+ }
+
+ /**
+ * Test fail on NULL.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value [NULL] cannot be converted to boolean.
+ */
+ public function testToBooleanFailure1() {
+ OptionConverter::toBooleanEx(null);
+ }
+
+ /**
+ * Test fail on invalid string.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value ['foo'] cannot be converted to boolean.
+ */
+ public function testToBooleanFailure2() {
+ OptionConverter::toBooleanEx('foo');
+ }
+
+ public function testToInteger() {
+ self::assertSame(1, OptionConverter::toIntegerEx('1'));
+ self::assertSame(1, OptionConverter::toIntegerEx(1));
+ self::assertSame(0, OptionConverter::toIntegerEx('0'));
+ self::assertSame(0, OptionConverter::toIntegerEx(0));
+ self::assertSame(-1, OptionConverter::toIntegerEx('-1'));
+ self::assertSame(-1, OptionConverter::toIntegerEx(-1));
+ }
+
+ /**
+ * Test fail on NULL.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value [NULL] cannot be converted to integer.
+ */
+ public function testToIntegerFailure1() {
+ OptionConverter::toIntegerEx(null);
+ }
+
+ /**
+ * Test fail on empty string.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value [''] cannot be converted to integer.
+ */
+ public function testToIntegerFailure2() {
+ OptionConverter::toIntegerEx('');
+ }
+
+ /**
+ * Test fail on invalid string.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value ['foo'] cannot be converted to integer.
+ */
+ public function testToIntegerFailure3() {
+ OptionConverter::toIntegerEx('foo');
+ }
+
+ /**
+ * Test fail on boolean.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value [true] cannot be converted to integer.
+ */
+ public function testToIntegerFailure4() {
+ OptionConverter::toIntegerEx(true);
+ }
+
+ /**
+ * Test fail on boolean.
+ * @expectedException Apache\Log4php\LoggerException
+ * @expectedExceptionMessage Given value [false] cannot be converted to integer.
+ */
+ public function testToIntegerFailure5() {
+ OptionConverter::toIntegerEx(false);
+ }
+
+ public function testSubstituteConstants() {
+ define('OTHER_CONSTANT', 'OTHER');
+ define('MY_CONSTANT', 'TEST');
+ define('NEXT_CONSTANT', 'NEXT');
+
+ $result = OptionConverter::substConstants('Value of key is ${MY_CONSTANT}.');
+ self::assertEquals('Value of key is TEST.', $result);
+
+ $result = OptionConverter::substConstants('Value of key is ${MY_CONSTANT} or ${OTHER_CONSTANT}.');
+ self::assertEquals('Value of key is TEST or OTHER.', $result);
+
+ $result = OptionConverter::substConstants('Value of key is ${MY_CONSTANT_CONSTANT}.');
+ self::assertEquals('Value of key is DEFINE.', $result);
+
+ $result = OptionConverter::substConstants('Value of key is ${MY_CONSTANT_CONSTANT} or ${MY_CONSTANT_CONSTANT_OTHER}.');
+ self::assertEquals('Value of key is DEFINE or DEFINE_OTHER.', $result);
+ }
+
+ public function testActualSubstituteConstants() {
+ $a = new FileAppender();
+ $a->setFile('${PHPUNIT_TEMP_DIR}/log.txt');
+ $actual = $a->getFile();
+ $expected = PHPUNIT_TEMP_DIR . '/log.txt';
+ self::assertSame($expected, $actual);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Helpers/PatternParserTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Helpers/PatternParserTest.php b/tests/src/Helpers/PatternParserTest.php
new file mode 100644
index 0000000..f849c2d
--- /dev/null
+++ b/tests/src/Helpers/PatternParserTest.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Helpers;
+
+/**
+ * @group helpers
+ *
+ * TODO: Should also test complex patterns like: "%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n"
+ */
+class LoggerPatternParserTest extends \PHPUnit_Framework_TestCase {
+
+ public function testErrorLayout() {
+// $event = new LoggingEvent("XmlLayout", new Logger("TEST"), Level::getLevelError(), "testmessage");
+// $expected = 'ERROR TEST : testmessage in NA at NA'.PHP_EOL;
+
+// $patternParser = new PatternParser("%-5p %c %X{username}: %m in %F at %L%n");
+// $c = $patternParser->parse();
+
+// $actual = '';
+// $c->format($actual, $event);
+// self::assertEquals($expected, $actual);
+
+ }
+
+ public function testClassname() {
+// $event = new LoggingEvent("MyClass", new Logger("TEST"), Level::getLevelError(), "testmessage");
+// $expected = 'MyClass';
+// $patternParser = new PatternParser("%C");
+// $c = $patternParser->parse();
+// $actual = '';
+// $c->format($actual, $event);
+// self::assertEquals($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Helpers/UtilsTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Helpers/UtilsTest.php b/tests/src/Helpers/UtilsTest.php
new file mode 100644
index 0000000..38ac597
--- /dev/null
+++ b/tests/src/Helpers/UtilsTest.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Helpers;
+
+use Apache\Log4php\Helpers\Utils;
+
+/**
+ * @group helpers
+ */
+class LoggerUtilsTest extends \PHPUnit_Framework_TestCase {
+
+ public function testShorten() {
+ $name = 'org\\apache\\logging\\log4php\\Foo';
+
+ $actual = Utils::shortenClassName($name, null);
+ self::assertSame($name, $actual);
+
+ $actual = Utils::shortenClassName($name, 0);
+ self::assertSame('Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 5);
+ self::assertSame('o\\a\\l\\l\\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 16);
+ self::assertSame('o\\a\\l\\l\\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 17);
+ self::assertSame('o\\a\\l\\log4php\\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 25);
+ self::assertSame('o\\a\\logging\\log4php\\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 28);
+ self::assertSame('o\\apache\\logging\\log4php\\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 30);
+ self::assertSame('org\\apache\\logging\\log4php\\Foo', $actual);
+ }
+
+ /** Dot separated notation must be supported for legacy reasons. */
+ public function testShortenWithDots() {
+ $name = 'org.apache.logging.log4php.Foo';
+
+ $actual = Utils::shortenClassName($name, null);
+ self::assertSame($name, $actual);
+
+ $actual = Utils::shortenClassName($name, 0);
+ self::assertSame('Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 5);
+ self::assertSame('o\a\l\l\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 16);
+ self::assertSame('o\a\l\l\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 17);
+ self::assertSame('o\a\l\log4php\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 25);
+ self::assertSame('o\a\logging\log4php\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 28);
+ self::assertSame('o\apache\logging\log4php\Foo', $actual);
+
+ $actual = Utils::shortenClassName($name, 30);
+ self::assertSame('org\apache\logging\log4php\Foo', $actual);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/HierarchyTest.php
----------------------------------------------------------------------
diff --git a/tests/src/HierarchyTest.php b/tests/src/HierarchyTest.php
new file mode 100644
index 0000000..d9f5b49
--- /dev/null
+++ b/tests/src/HierarchyTest.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Appenders\ConsoleAppender;
+use Apache\Log4php\Hierarchy;
+use Apache\Log4php\Level;
+use Apache\Log4php\RootLogger;
+
+/**
+ * @group main
+ */
+class HierarchyTest extends \PHPUnit_Framework_TestCase {
+
+ private $hierarchy;
+
+ protected function setUp() {
+ $this->hierarchy = new Hierarchy(new RootLogger());
+ }
+
+ public function testResetConfiguration() {
+ $root = $this->hierarchy->getRootLogger();
+ $appender = new ConsoleAppender('A1');
+ $root->addAppender($appender);
+
+ $logger = $this->hierarchy->getLogger('test');
+ self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
+
+ $this->hierarchy->resetConfiguration();
+ self::assertEquals(Level::getLevelDebug(), $root->getLevel());
+ self::assertEquals(Level::getLevelAll(), $this->hierarchy->getThreshold());
+ self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
+
+ foreach($this->hierarchy->getCurrentLoggers() as $logger) {
+ self::assertNull($logger->getLevel());
+ self::assertTrue($logger->getAdditivity());
+ self::assertEquals(0, count($logger->getAllAppenders()), 0);
+ }
+ }
+
+ public function testSettingParents() {
+ $hierarchy = $this->hierarchy;
+ $loggerDE = $hierarchy->getLogger("de");
+ $root = $loggerDE->getParent();
+ self::assertEquals('root', $root->getName());
+
+ $loggerDEBLUB = $hierarchy->getLogger("de.blub");
+ self::assertEquals('de.blub', $loggerDEBLUB->getName());
+ $p = $loggerDEBLUB->getParent();
+ self::assertEquals('de', $p->getName());
+
+ $loggerDEBLA = $hierarchy->getLogger("de.bla");
+ $p = $loggerDEBLA->getParent();
+ self::assertEquals('de', $p->getName());
+
+ $logger3 = $hierarchy->getLogger("de.bla.third");
+ $p = $logger3->getParent();
+ self::assertEquals('de.bla', $p->getName());
+
+ $p = $p->getParent();
+ self::assertEquals('de', $p->getName());
+ }
+
+ public function testExists() {
+ $hierarchy = $this->hierarchy;
+ $logger = $hierarchy->getLogger("de");
+
+ self::assertTrue($hierarchy->exists("de"));
+
+ $logger = $hierarchy->getLogger("de.blub");
+ self::assertTrue($hierarchy->exists("de.blub"));
+ self::assertTrue($hierarchy->exists("de"));
+
+ $logger = $hierarchy->getLogger("de.de");
+ self::assertTrue($hierarchy->exists("de.de"));
+ }
+
+ public function testClear() {
+ $hierarchy = $this->hierarchy;
+ $logger = $hierarchy->getLogger("de");
+ self::assertTrue($hierarchy->exists("de"));
+ $hierarchy->clear();
+ self::assertFalse($hierarchy->exists("de"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Layouts/HtmlLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/HtmlLayoutTest.php b/tests/src/Layouts/HtmlLayoutTest.php
new file mode 100644
index 0000000..902d3fc
--- /dev/null
+++ b/tests/src/Layouts/HtmlLayoutTest.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Layouts;
+
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Logger;
+use Apache\Log4php\Level;
+use Apache\Log4php\Layouts\HtmlLayout;
+
+/**
+ * @group layouts
+ */
+class HtmlLayoutTest extends \PHPUnit_Framework_TestCase {
+
+ public function testErrorLayout() {
+ $event = new LoggingEvent("HtmlLayoutTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $layout = new HtmlLayout();
+ $v = $layout->format($event);
+
+ $e = PHP_EOL."<tr>".PHP_EOL.
+ "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
+ "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
+ "<td title=\"Level\">ERROR</td>".PHP_EOL.
+ "<td title=\"TEST category\">TEST</td>".PHP_EOL.
+ "<td title=\"Message\">testmessage</td>".PHP_EOL.
+ "</tr>".PHP_EOL;
+
+ self::assertEquals($v, $e);
+ }
+
+ public function testWarnLayout() {
+ $event = new LoggingEvent("HtmlLayoutTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+
+ $layout = new HtmlLayout();
+ $v = $layout->format($event);
+
+ $e = PHP_EOL."<tr>".PHP_EOL.
+ "<td>".round(1000*$event->getRelativeTime())."</td>".PHP_EOL.
+ "<td title=\"".$event->getThreadName()." thread\">".$event->getThreadName()."</td>".PHP_EOL.
+ "<td title=\"Level\"><font color=\"#993300\"><strong>WARN</strong></font></td>".PHP_EOL.
+ "<td title=\"TEST category\">TEST</td>".PHP_EOL.
+ "<td title=\"Message\">testmessage</td>".PHP_EOL.
+ "</tr>".PHP_EOL;
+
+ self::assertEquals($v, $e);
+ }
+
+ public function testContentType() {
+ $layout = new HtmlLayout();
+ $v = $layout->getContentType();
+ $e = "text/html";
+ self::assertEquals($v, $e);
+ }
+
+ public function testTitle() {
+ $layout = new HtmlLayout();
+ $v = $layout->getTitle();
+ $e = "Log4php Log Messages";
+ self::assertEquals($v, $e);
+
+ $layout->setTitle("test");
+ $v = $layout->getTitle();
+ $e = "test";
+ self::assertEquals($v, $e);
+ }
+
+ public function testHeader() {
+ $layout = new HtmlLayout();
+ $v = $layout->getHeader();
+ self::assertTrue(strpos($v, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">") === 0);
+ }
+
+ public function testFooter() {
+ $layout = new HtmlLayout();
+ $v = $layout->getFooter();
+ self::assertTrue(strpos($v, "</table>") === 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Layouts/PatternLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/PatternLayoutTest.php b/tests/src/Layouts/PatternLayoutTest.php
new file mode 100644
index 0000000..71d331d
--- /dev/null
+++ b/tests/src/Layouts/PatternLayoutTest.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Layouts;
+
+use Apache\Log4php\Tests\TestHelper;
+use Apache\Log4php\Logger;
+
+/**
+ * @group layouts
+ */
+class PatternLayoutTest extends \PHPUnit_Framework_TestCase {
+
+ /** Pattern used for testing. */
+ private $pattern = "%-6level %logger: %msg from %class::%method() in %file at %line%n";
+
+ public function testComplexLayout() {
+
+ $config = TestHelper::getEchoPatternConfig($this->pattern);
+ Logger::configure($config);
+
+ ob_start();
+ $log = Logger::getLogger('LoggerTest');
+ $log->error("my message"); $line = __LINE__;
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $file = __FILE__;
+ $class = __CLASS__;
+ $method = __FUNCTION__;
+
+ $expected = "ERROR LoggerTest: my message from $class::$method() in $file at $line" . PHP_EOL;
+ self::assertSame($expected, $actual);
+
+ Logger::resetConfiguration();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Layouts/SerializedLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/SerializedLayoutTest.php b/tests/src/Layouts/SerializedLayoutTest.php
new file mode 100644
index 0000000..257fde2
--- /dev/null
+++ b/tests/src/Layouts/SerializedLayoutTest.php
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Layouts;
+
+use Apache\Log4php\Layouts\SerializedLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+
+/**
+ * @group layouts
+ */
+class SerializedLayoutTest extends \PHPUnit_Framework_TestCase {
+
+ public function testLocationInfo() {
+ $layout = new SerializedLayout();
+ self::assertFalse($layout->getLocationInfo());
+ $layout->setLocationInfo(true);
+ self::assertTrue($layout->getLocationInfo());
+ $layout->setLocationInfo(false);
+ self::assertFalse($layout->getLocationInfo());
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Invalid value given for 'locationInfo' property: ['foo']. Expected a boolean value. Property not changed.
+ */
+ public function testLocationInfoFail() {
+ $layout = new SerializedLayout();
+ $layout->setLocationInfo('foo');
+ }
+
+ public function testLayout() {
+ Logger::configure(array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SerializedLayout'
+ )
+ )
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ )
+ ));
+
+ ob_start();
+ $foo = Logger::getLogger('foo');
+ $foo->info("Interesting message.");
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $event = unserialize($actual);
+
+ self::assertInstanceOf('Apache\\Log4php\\LoggingEvent', $event);
+ self::assertEquals('Interesting message.', $event->getMessage());
+ self::assertEquals(Level::getLevelInfo(), $event->getLevel());
+ }
+
+ public function testLayoutWithLocationInfo() {
+ Logger::configure(array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SerializedLayout',
+ 'params' => array(
+ 'locationInfo' => true
+ )
+ )
+ )
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default')
+ )
+ ));
+
+ ob_start();
+ $foo = Logger::getLogger('foo');
+ $foo->info("Interesting message.");
+ $actual = ob_get_contents();
+ ob_end_clean();
+
+ $event = unserialize($actual);
+
+ self::assertInstanceOf('Apache\\Log4php\\LoggingEvent', $event);
+ self::assertEquals('Interesting message.', $event->getMessage());
+ self::assertEquals(Level::getLevelInfo(), $event->getLevel());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Layouts/SimpleLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/SimpleLayoutTest.php b/tests/src/Layouts/SimpleLayoutTest.php
new file mode 100644
index 0000000..f33057d
--- /dev/null
+++ b/tests/src/Layouts/SimpleLayoutTest.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Layouts;
+
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Logger;
+use Apache\Log4php\Level;
+use Apache\Log4php\Layouts\SimpleLayout;
+
+/**
+ * @group layouts
+ */
+class SimpleLayoutTest extends \PHPUnit_Framework_TestCase {
+
+ public function testSimpleLayout() {
+ $event = new LoggingEvent("SimpleLayoutTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $layout = new SimpleLayout();
+ $actual = $layout->format($event);
+ $expected = "ERROR - testmessage" . PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Layouts/XmlLayoutTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Layouts/XmlLayoutTest.php b/tests/src/Layouts/XmlLayoutTest.php
new file mode 100644
index 0000000..bbcb7dd
--- /dev/null
+++ b/tests/src/Layouts/XmlLayoutTest.php
@@ -0,0 +1,153 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Layouts;
+
+use Apache\Log4php\Tests\TestHelper;
+
+use Apache\Log4php\Layouts\XmlLayout;
+use Apache\Log4php\NDC;
+use Apache\Log4php\MDC;
+
+/**
+ * @group layouts
+ */
+class XmlLayoutTest extends \PHPUnit_Framework_TestCase {
+
+ public function testErrorLayout() {
+ $event = TestHelper::getErrorEvent("testmessage");
+
+ $layout = new XmlLayout();
+ $layout->activateOptions();
+
+ $actual = $layout->format($event);
+
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+
+ $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
+
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testWarnLayout() {
+ $event = TestHelper::getWarnEvent("testmessage");
+
+ $layout = new XmlLayout();
+ $layout->activateOptions();
+
+ $actual = $layout->format($event);
+
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+
+ $expected = "<log4php:event logger=\"test\" level=\"WARN\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
+
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testLog4JNamespaceErrorLayout() {
+ $event = TestHelper::getErrorEvent("testmessage");
+
+ $layout = new XmlLayout();
+ $layout->setLog4jNamespace(true);
+ $layout->activateOptions();
+
+ $actual = $layout->format($event);
+
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+
+ $expected = "<log4j:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4j:message><![CDATA[testmessage]]></log4j:message>" . PHP_EOL .
+ "<log4j:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4j:event>" . PHP_EOL;
+
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testNDC()
+ {
+ NDC::push('foo');
+ NDC::push('bar');
+
+ $event = TestHelper::getErrorEvent("testmessage");
+
+ $layout = new XmlLayout();
+ $layout->activateOptions();
+
+ $actual = $layout->format($event);
+
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+
+ $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:NDC><![CDATA[<![CDATA[foo bar]]>]]></log4php:NDC>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
+
+ self::assertEquals($expected, $actual);
+
+ NDC::clear();
+ }
+
+ public function testMDC()
+ {
+ MDC::put('foo', 'bar');
+ MDC::put('bla', 'tra');
+
+ $event = TestHelper::getErrorEvent("testmessage");
+
+ $layout = new XmlLayout();
+ $layout->activateOptions();
+
+ $actual = $layout->format($event);
+
+ $thread = $event->getThreadName();
+ $timestamp = number_format(($event->getTimeStamp() * 1000), 0, '', '');
+
+ $expected = "<log4php:event logger=\"test\" level=\"ERROR\" thread=\"$thread\" timestamp=\"$timestamp\">" . PHP_EOL .
+ "<log4php:message><![CDATA[testmessage]]></log4php:message>" . PHP_EOL .
+ "<log4php:properties>" . PHP_EOL .
+ "<log4php:data name=\"foo\" value=\"bar\" />" . PHP_EOL .
+ "<log4php:data name=\"bla\" value=\"tra\" />" . PHP_EOL .
+ "</log4php:properties>" . PHP_EOL .
+ "<log4php:locationInfo class=\"Apache\\Log4php\\LoggingEvent\" file=\"NA\" line=\"NA\" " .
+ "method=\"getLocationInformation\" />" . PHP_EOL .
+ "</log4php:event>" . PHP_EOL;
+
+ self::assertEquals($expected, $actual);
+
+ MDC::clear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/LevelTest.php
----------------------------------------------------------------------
diff --git a/tests/src/LevelTest.php b/tests/src/LevelTest.php
new file mode 100644
index 0000000..29ece9b
--- /dev/null
+++ b/tests/src/LevelTest.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Level;
+
+/**
+ * @group main
+ */
+class LevelTest extends \PHPUnit_Framework_TestCase {
+
+ protected function doTestLevel($level, $code, $str, $syslog) {
+ self::assertTrue($level instanceof Level);
+ self::assertEquals($level->toInt(), $code);
+ self::assertEquals($level->toString(), $str);
+ self::assertEquals($level->getSyslogEquivalent(), $syslog);
+ }
+
+ public function testLevelOff() {
+ $this->doTestLevel(Level::getLevelOff(), Level::OFF, 'OFF', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel(Level::OFF), Level::OFF, 'OFF', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel('OFF'), Level::OFF, 'OFF', LOG_ALERT);
+ }
+
+ public function testLevelFatal() {
+ $this->doTestLevel(Level::getLevelFatal(), Level::FATAL, 'FATAL', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel(Level::FATAL), Level::FATAL, 'FATAL', LOG_ALERT);
+ $this->doTestLevel(Level::toLevel('FATAL'), Level::FATAL, 'FATAL', LOG_ALERT);
+ }
+
+ public function testLevelError() {
+ $this->doTestLevel(Level::getLevelError(), Level::ERROR, 'ERROR', LOG_ERR);
+ $this->doTestLevel(Level::toLevel(Level::ERROR), Level::ERROR, 'ERROR', LOG_ERR);
+ $this->doTestLevel(Level::toLevel('ERROR'), Level::ERROR, 'ERROR', LOG_ERR);
+ }
+
+ public function testLevelWarn() {
+ $this->doTestLevel(Level::getLevelWarn(), Level::WARN, 'WARN', LOG_WARNING);
+ $this->doTestLevel(Level::toLevel(Level::WARN), Level::WARN, 'WARN', LOG_WARNING);
+ $this->doTestLevel(Level::toLevel('WARN'), Level::WARN, 'WARN', LOG_WARNING);
+ }
+
+ public function testLevelInfo() {
+ $this->doTestLevel(Level::getLevelInfo(), Level::INFO, 'INFO', LOG_INFO);
+ $this->doTestLevel(Level::toLevel(Level::INFO), Level::INFO, 'INFO', LOG_INFO);
+ $this->doTestLevel(Level::toLevel('INFO'), Level::INFO, 'INFO', LOG_INFO);
+ }
+
+ public function testLevelDebug() {
+ $this->doTestLevel(Level::getLevelDebug(), Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel(Level::DEBUG), Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel('DEBUG'), Level::DEBUG, 'DEBUG', LOG_DEBUG);
+ }
+
+ public function testLevelTrace() {
+ $this->doTestLevel(Level::getLevelTrace(), Level::TRACE, 'TRACE', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel(Level::TRACE), Level::TRACE, 'TRACE', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel('TRACE'), Level::TRACE, 'TRACE', LOG_DEBUG);
+ }
+
+ public function testLevelAll() {
+ $this->doTestLevel(Level::getLevelAll(), Level::ALL, 'ALL', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel(Level::ALL), Level::ALL, 'ALL', LOG_DEBUG);
+ $this->doTestLevel(Level::toLevel('ALL'), Level::ALL, 'ALL', LOG_DEBUG);
+ }
+}
[06/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderFirephpTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderFirephpTest.php b/src/test/php/appenders/LoggerAppenderFirephpTest.php
deleted file mode 100644
index 6a2918a..0000000
--- a/src/test/php/appenders/LoggerAppenderFirephpTest.php
+++ /dev/null
@@ -1,201 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- * @internal Phpmd clean.
- */
-
-@include_once('FirePHPCore/FirePHP.class.php');
-
-/**
- * @group appenders
- */
-class LoggerAppenderFirePHPTest extends PHPUnit_Framework_TestCase {
-
- private $config = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderFirePHP',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- ),
- 'params' => array('target' => 'page')
- )
- )
- );
-
- public function setUp() {
- if(!method_exists('FirePHP', 'to')) {
- self::markTestSkipped("Please install 'FirePHP' in order to run this test");
- }
- }
-
- private function createEvent($message, $level) {
- $eventMock = new LoggerLoggingEvent("LoggerAppenderFirePHPTest", new Logger("TEST"), LoggerLevel::toLevel($level), $message);
-
- return $eventMock;
- }
-
- public function testSetTarget() {
- $appender = new LoggerAppenderFirePHP();
- $appender->setTarget('page');
- self::assertSame('page', $appender->getTarget());
- }
-
- public function testAppend_HandleDebug() {
- $console = new FirePHPSpy();
-
- $appender = new TestableLoggerAppenderFirePhp();
- $appender->setConsole($console);
-
- $expectedMessage = 'trace message';
- $expectedLevel = 'debug';
-
- $appender->append($this->createEvent($expectedMessage, $expectedLevel));
-
- $this->assertLog($console, $expectedMessage, $expectedLevel, 'log');
- }
-
- public function testAppend_HandleWarn() {
- $console = new FirePHPSpy();
-
- $appender = new TestableLoggerAppenderFirePhp();
- $appender->setConsole($console);
-
- $expectedMessage = 'debug message';
- $expectedLevel = 'warn';
-
- $appender->append($this->createEvent($expectedMessage, $expectedLevel));
-
- $this->assertLog($console, $expectedMessage, $expectedLevel, 'warn');
- }
-
- public function testAppend_HandleError() {
- $console = new FirePHPSpy();
-
- $appender = new TestableLoggerAppenderFirePhp();
- $appender->setConsole($console);
-
- $expectedMessage = 'error message';
- $expectedLevel = 'error';
-
- $appender->append($this->createEvent($expectedMessage, $expectedLevel));
-
- $this->assertLog($console, $expectedMessage, $expectedLevel, 'error');
- }
-
- public function testAppend_HandleFatal() {
- $console = new FirePHPSpy();
-
- $appender = new TestableLoggerAppenderFirePhp();
- $appender->setConsole($console);
-
- $expectedMessage = "fatal message";
- $expectedLevel = 'fatal';
-
- $appender->append($this->createEvent($expectedMessage, $expectedLevel));
-
- $this->assertLog($console, $expectedMessage, $expectedLevel, 'error');
- }
-
- public function testAppend_HandleDefault() {
- $console = new FirePHPSpy();
-
- $appender = new TestableLoggerAppenderFirePhp();
- $appender->setConsole($console);
-
- $expectedMessage = 'info message';
- $expectedLevel = 'info';
-
- $appender->append($this->createEvent($expectedMessage, $expectedLevel));
-
- $this->assertLog($console, $expectedMessage, $expectedLevel, 'info');
- }
-
- public function assertLog($console, $expectedMessage, $logLevel, $calledMethod) {
- $event = $this->createEvent($expectedMessage, $logLevel);
-
- $layout = new LoggerLayoutSimple();
- $message = $layout->format($event);
-
- $this->assertEquals($message, $console->getMessage(), 'log message is wrong');
- $this->assertEquals(1, $console->getCalls(), 'wasn\'t called once');
- $this->assertEquals($calledMethod, $console->getCalledMethod(), 'wrong log-method was called');
- }
-}
-
-class TestableLoggerAppenderFirePhp extends LoggerAppenderFirePHP {
- public function setConsole($console) {
- $this->console = $console;
- }
-}
-
-class FirePHPSpy {
- private $calls = 0;
- private $message = '';
- private $calledMethod = '';
-
- public function getCalls() {
- return $this->calls;
- }
-
- public function getMessage() {
- return $this->message;
- }
-
- public function log($message) {
- $this->calls++;
- $this->calledMethod = 'log';
- $this->message = $message;
- }
-
- public function debug($message) {
- $this->calls++;
- $this->calledMethod = 'debug';
- $this->message = $message;
- }
-
- public function warn($message) {
- $this->calls++;
- $this->calledMethod = 'warn';
- $this->message = $message;
- }
-
- public function error($message) {
- $this->calls++;
- $this->calledMethod = 'error';
- $this->message = $message;
- }
-
- public function info($message) {
- $this->calls++;
- $this->calledMethod = 'info';
- $this->message = $message;
- }
-
- public function getCalledMethod() {
- return $this->calledMethod;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderMailEventTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderMailEventTest.php b/src/test/php/appenders/LoggerAppenderMailEventTest.php
deleted file mode 100644
index 7a19244..0000000
--- a/src/test/php/appenders/LoggerAppenderMailEventTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderMailEventTest extends PHPUnit_Framework_TestCase {
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderMailEvent();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testMail() {
- $appender = new LoggerAppenderMailEvent("myname");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
- $appender->setDry(true);
- $appender->setTo('test@example.com');
- $appender->setFrom('Testsender');
-
- $appender->activateOptions();
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- ob_start();
- $appender->append($event);
- $v = ob_get_contents();
- ob_end_clean();
-
- $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with additional headers 'From: Testsender' and content: ERROR - testmessage".PHP_EOL;
- self::assertEquals($e, $v);
- $appender->close();
- }
-
- /**
- * Check an error is reported if 'to' is not set.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'to' not set.
- */
- public function testEmptyTo() {
- $appender = new LoggerAppenderMailEvent("myname");
- $appender->setLayout(new LoggerLayoutSimple());
- $appender->setFrom('info@example.com');
- $appender->activateOptions();
- }
-
- /**
- * Check an error is reported if 'from' is not set.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'from' not set.
- */
- public function testEmptyFrom() {
- $appender = new LoggerAppenderMailEvent("myname");
- $appender->setLayout(new LoggerLayoutSimple());
- $appender->setTo('info@example.com');
- $appender->activateOptions();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderMailTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderMailTest.php b/src/test/php/appenders/LoggerAppenderMailTest.php
deleted file mode 100644
index eeb0500..0000000
--- a/src/test/php/appenders/LoggerAppenderMailTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderMailTest extends PHPUnit_Framework_TestCase {
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderMail();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testMail() {
- $appender = new LoggerAppenderMail("myname ");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
- $appender->setDry(true);
- $appender->setTo('test@example.com');
- $appender->setFrom('Testsender');
-
- $appender->activateOptions();
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $event2 = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage2");
-
- ob_start();
- $appender->append($event);
- $appender->append($event2);
- $appender->close();
- $v = ob_get_contents();
- ob_end_clean();
-
- $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with content: ERROR - testmessage".PHP_EOL."ERROR - testmessage2".PHP_EOL;
- self::assertEquals($e, $v);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderMongoDBTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderMongoDBTest.php b/src/test/php/appenders/LoggerAppenderMongoDBTest.php
deleted file mode 100644
index 7d62fe5..0000000
--- a/src/test/php/appenders/LoggerAppenderMongoDBTest.php
+++ /dev/null
@@ -1,207 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * Testclass for the MongoDB appender.
- *
- * This class has been originally contributed from Vladimir Gorej
- * (http://github.com/log4mongo/log4mongo-php).
- *
- * @group appenders
- */
-class LoggerAppenderMongoDBTest extends PHPUnit_Framework_TestCase {
-
- protected $appender;
- protected $event;
-
- protected function setUp() {
- if (!extension_loaded('mongo')) {
- $this->markTestSkipped(
- 'The Mongo extension is not available.'
- );
- } else {
- $this->appender = new LoggerAppenderMongoDB('mongo_appender');
- $this->event = LoggerTestHelper::getErrorEvent('mongo logging event', 'test_mongo');
- }
- }
-
- protected function tearDown() {
- unset($this->appender);
- }
-
- public function testHost() {
- $expected = 'mongodb://localhost';
- $this->appender->setHost($expected);
- $result = $this->appender->getHost();
- $this->assertEquals($expected, $result);
- }
-
- public function testPort() {
- $expected = 27017;
- $this->appender->setPort($expected);
- $result = $this->appender->getPort();
- $this->assertEquals($expected, $result);
- }
-
- public function testDatabaseName() {
- $expected = 'log4php_mongodb';
- $this->appender->setDatabaseName($expected);
- $result = $this->appender->getDatabaseName();
- $this->assertEquals($expected, $result);
- }
-
- public function testCollectionName() {
- $expected = 'logs';
- $this->appender->setCollectionName($expected);
- $result = $this->appender->getCollectionName();
- $this->assertEquals($expected, $result);
- }
-
- public function testUserName() {
- $expected = 'char0n';
- $this->appender->setUserName($expected);
- $result = $this->appender->getUserName();
- $this->assertEquals($expected, $result);
- }
-
- public function testPassword() {
- $expected = 'secret pass';
- $this->appender->setPassword($expected);
- $result = $this->appender->getPassword();
- $this->assertEquals($expected, $result);
- }
-
- public function testTimeout() {
- $expected = 4000;
- $this->appender->setTimeout($expected);
- $result = $this->appender->getTimeout();
- $this->assertEquals($expected, $result);
- }
-
- public function testActivateOptions() {
- $this->appender->activateOptions();
- $this->assertInstanceOf('Mongo', $this->appender->getConnection());
- $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
- }
-
- public function testActivateOptionsNoCredentials() {
- $this->appender->setUserName(null);
- $this->appender->setPassword(null);
- $this->appender->activateOptions();
- $this->assertInstanceOf('Mongo', $this->appender->getConnection());
- $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
- }
-
- public function testFormat() {
- $this->appender->activateOptions();
- $record = $this->logOne($this->event);
-
- $this->assertEquals('ERROR', $record['level']);
- $this->assertEquals('mongo logging event', $record['message']);
- $this->assertEquals('test_mongo', $record['loggerName']);
-
- $this->assertEquals('NA', $record['fileName']);
- $this->assertEquals('getLocationInformation', $record['method']);
- $this->assertEquals('NA', $record['lineNumber']);
- $this->assertEquals('LoggerLoggingEvent', $record['className']);
-
- $this->assertTrue(is_int($record['thread']));
- $this->assertSame(getmypid(), $record['thread']);
- $this->assertTrue(is_int($record['lineNumber']) || $record['lineNumber'] == 'NA');
- }
-
- public function testFormatThrowableInfo() {
- $this->appender->activateOptions();
- $event = new LoggerLoggingEvent(
- 'testFqcn',
- new Logger('test.Logger'),
- LoggerLevel::getLevelWarn(),
- 'test message',
- microtime(true),
- new Exception('test exception', 1)
- );
-
- $record = $this->logOne($event);
-
- $this->assertArrayHasKey('exception', $record);
- $this->assertEquals(1, $record['exception']['code']);
- $this->assertEquals('test exception', $record['exception']['message']);
- $this->assertContains('[internal function]: LoggerAppenderMongoDBTest', $record['exception']['stackTrace']);
- }
-
- public function testFormatThrowableInfoWithInnerException() {
-
- // Skip test if PHP version is lower than 5.3.0 (no inner exception support)
- if (version_compare(PHP_VERSION, '5.3.0') < 0) {
- $this->markTestSkipped();
- }
-
- $this->appender->activateOptions();
- $event = new LoggerLoggingEvent(
- 'testFqcn',
- new Logger('test.Logger'),
- LoggerLevel::getLevelWarn(),
- 'test message',
- microtime(true),
- new Exception('test exception', 1, new Exception('test exception inner', 2))
- );
-
- $record = $this->logOne($event);
-
- $this->assertArrayHasKey('exception', $record);
- $this->assertEquals(1, $record['exception']['code']);
- $this->assertEquals('test exception', $record['exception']['message']);
- $this->assertContains('[internal function]: LoggerAppenderMongoDBTest', $record['exception']['stackTrace']);
-
- $this->assertArrayHasKey('innerException', $record['exception']);
- $this->assertEquals(2, $record['exception']['innerException']['code']);
- $this->assertEquals('test exception inner', $record['exception']['innerException']['message']);
- }
-
-
- public function testClose() {
- $this->appender->activateOptions();
- $this->assertInstanceOf('Mongo', $this->appender->getConnection());
- $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
- $this->appender->close();
- $this->assertNull($this->appender->getConnection());
- $this->assertNull($this->appender->getCollection());
- }
-
- /**
- * Logs the event and returns the record from the database.
- * @param LoggerLoggingEvent $event
- * @return array
- */
- private function logOne($event)
- {
- $collection = $this->appender->getCollection();
- $collection->drop();
- $this->appender->append($event);
- $record = $collection->findOne();
- $this->assertNotNull($record, 'Could not read the record from the database.');
- return $record;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderNullTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderNullTest.php b/src/test/php/appenders/LoggerAppenderNullTest.php
deleted file mode 100644
index 2a30797..0000000
--- a/src/test/php/appenders/LoggerAppenderNullTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderNullTest extends PHPUnit_Framework_TestCase {
- /**
- * The Null appender does nothing - nothing to assert.
- * Just here for the sake of completness and a good testing ratio :-)
- */
- public function testActivateOptions() {
- $event = new LoggerLoggingEvent("LoggerAppenderNullTest", new Logger("TEST"), LoggerLevel::getLevelInfo(), "testmessage");
-
- $appender = new LoggerAppenderNull("TEST");
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderNull();
- self::assertFalse($appender->requiresLayout());
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderPDOTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderPDOTest.php b/src/test/php/appenders/LoggerAppenderPDOTest.php
deleted file mode 100644
index 567134e..0000000
--- a/src/test/php/appenders/LoggerAppenderPDOTest.php
+++ /dev/null
@@ -1,164 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderPDOTest extends PHPUnit_Framework_TestCase {
-
- const FILENAME = 'pdotest.sqlite';
- private static $dsn;
- private static $file;
-
- public static function setUpBeforeClass() {
-
- self::$file = PHPUNIT_TEMP_DIR . '/' . self::FILENAME;
- self::$dsn = 'sqlite:' . self::$file;
-
- if(extension_loaded('pdo_sqlite')) {
- $drop = 'DROP TABLE IF EXISTS log4php_log;';
- $create = 'CREATE TABLE log4php_log (
- timestamp VARCHAR(256),
- logger VARCHAR(256),
- level VARCHAR(32),
- message VARCHAR(4000),
- thread INTEGER,
- file VARCHAR(255),
- line VARCHAR(10)
- );';
-
- $pdo = new PDO(self::$dsn);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $pdo->exec($drop);
- $pdo->exec($create);
- }
- }
-
- /** To start with an empty database for each single test. */
- public function setUp() {
- if(!extension_loaded('pdo_sqlite')) {
- self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
- }
- }
-
- /** Clean up after the last test was run. */
- public static function tearDownAfterClass() {
- @unlink(self::$file);
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderPDO();
- self::assertFalse($appender->requiresLayout());
- }
-
- /** Tests new-style logging using prepared statements and the default SQL definition. */
- public function testSimpleWithDefaults() {
- // Log event
- $event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $appender = new LoggerAppenderPDO("myname");
- $appender->setDSN(self::$dsn);
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- // Test the default pattern
- $db = new PDO(self::$dsn);
- $query = "SELECT * FROM log4php_log";
- $sth = $db->query($query);
- $row = $sth->fetch(PDO::FETCH_NUM);
-
- self::assertTrue(is_array($row), "No rows found.");
- self::assertEquals(7, count($row));
- self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row[0])); // datetime
- self::assertEquals('TEST', $row[1]); // logger name
- self::assertEquals('ERROR', $row[2]); // level
- self::assertEquals('testmessage', $row[3]); // message
- if (function_exists('posix_getpid')) {
- self::assertEquals(posix_getpid(), $row[4]); // process id
- }
- self::assertEquals('NA', $row[5]); // file, NA due to phpunit magic
- self::assertEquals('NA', $row[6]); // line, NA due to phpunit magic
- }
-
-
- /** Tests new style prepared statment logging with customized SQL. */
- public function testCustomizedSql() {
-
- $dateFormat = "Y-m-d H:i:s";
-
- // Prepare appender
- $appender = new LoggerAppenderPDO("myname");
- $appender->setDSN(self::$dsn);
- $appender->setInsertSql("INSERT INTO log4php_log (file, line, thread, timestamp, logger, level, message) VALUES (?,?,?,?,?,?,?)");
- $appender->setInsertPattern("%F,%L,%t,%d\{$dateFormat\},%c,%p,%m");
- $appender->activateOptions();
-
- // Action!
- $event = new LoggerLoggingEvent("LoggerAppenderPDOTest2", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $appender->append($event);
-
- // Check
- $db = new PDO(self::$dsn);
- $result = $db->query("SELECT * FROM log4php_log");
- $row = $result->fetch(PDO::FETCH_OBJ);
- self::assertTrue(is_object($row));
- self::assertEquals("NA", $row->file); // "NA" due to phpunit magic
- self::assertEquals("NA", $row->line); // "NA" due to phpunit magic
- if (function_exists('posix_getpid')) {
- self::assertEquals(posix_getpid(), $row->thread);
- }
- self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row->timestamp));
- self::assertEquals('TEST', $row->logger);
- self::assertEquals('ERROR', $row->level);
- self::assertEquals('testmessage', $row->message);
- }
-
- /**
- * Tests a warning is shown when connecting to invalid dns.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage invalid data source name
- */
- public function testException() {
- $dsn = 'doenotexist';
- $appender = new LoggerAppenderPDO("myname");
- $appender->setDSN($dsn);
- $appender->activateOptions();
- }
-
- /**
- * Check whether close() actually closes the database connection.
- */
- public function testClose() {
- $event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $appender = new LoggerAppenderPDO("myname");
- $appender->setDSN(self::$dsn);
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- self::assertNull($appender->getDatabaseHandle());
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderPhpTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderPhpTest.php b/src/test/php/appenders/LoggerAppenderPhpTest.php
deleted file mode 100644
index 953315f..0000000
--- a/src/test/php/appenders/LoggerAppenderPhpTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-function errorHandler($errno, $errstr, $errfile, $errline) {
- PHPUnit_Framework_TestCase::assertEquals(LoggerAppenderPhpTest::$expectedError, $errno);
- PHPUnit_Framework_TestCase::assertEquals(LoggerAppenderPhpTest::$expectedMessage, $errstr);
-}
-
-/**
- * @group appenders
- */
-class LoggerAppenderPhpTest extends PHPUnit_Framework_TestCase {
-
- public static $expectedMessage;
-
- public static $expectedError;
-
- private $config = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- 'level' => 'trace'
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderPHP',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- )
- )
- );
-
- protected function setUp() {
- set_error_handler("errorHandler");
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderPhp();
- $this->assertTrue($appender->requiresLayout());
- }
-
- public function testPhp() {
- Logger::configure($this->config);
- $logger = Logger::getRootLogger();
-
-
- self::$expectedError = E_USER_ERROR;
- self::$expectedMessage = "FATAL - This is a test" . PHP_EOL;
- $logger->fatal("This is a test");
-
- self::$expectedError = E_USER_ERROR;
- self::$expectedMessage = "ERROR - This is a test" . PHP_EOL;
- $logger->error("This is a test");
-
- self::$expectedError = E_USER_WARNING;
- self::$expectedMessage = "WARN - This is a test" . PHP_EOL;
- $logger->warn("This is a test");
-
- self::$expectedError = E_USER_NOTICE;
- self::$expectedMessage = "INFO - This is a test" . PHP_EOL;
- $logger->info("This is a test");
-
- self::$expectedError = E_USER_NOTICE;
- self::$expectedMessage = "DEBUG - This is a test" . PHP_EOL;
- $logger->debug("This is a test");
-
- self::$expectedError = E_USER_NOTICE;
- self::$expectedMessage = "TRACE - This is a test" . PHP_EOL;
- $logger->trace("This is a test");
- }
-
- protected function tearDown() {
- restore_error_handler();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderRollingFileTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderRollingFileTest.php b/src/test/php/appenders/LoggerAppenderRollingFileTest.php
deleted file mode 100644
index 2ae1289..0000000
--- a/src/test/php/appenders/LoggerAppenderRollingFileTest.php
+++ /dev/null
@@ -1,206 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderRollingFileTest extends PHPUnit_Framework_TestCase {
-
- const WARNING_MASSAGE = 'WARN - my messageXYZ';
-
- protected function setUp() {
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1');
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2');
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderRollingFile();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testMaxFileSize() {
- $appender = new LoggerAppenderRollingFile("mylogger");
-
- $appender->setMaxFileSize('1KB');
- self::assertEquals(1024, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('2KB');
- self::assertEquals(2048, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('1MB');
- self::assertEquals(1048576, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('3MB');
- self::assertEquals(3145728, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('1GB');
- self::assertEquals(1073741824, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('10000');
- self::assertEquals(10000, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('100.5');
- self::assertEquals(100, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('1000.6');
- self::assertEquals(1000, $appender->getMaxFileSize());
-
- $appender->setMaxFileSize('1.5MB');
- self::assertEquals(1572864, $appender->getMaxFileSize());
- }
-
- /**
- * @return LoggerAppenderRollingFile
- */
- private function createRolloverAppender() {
- $layout = new LoggerLayoutSimple();
-
- $appender = new LoggerAppenderRollingFile("mylogger");
- $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
- $appender->setLayout($layout);
- $appender->setMaxFileSize('1KB');
- $appender->setMaxBackupIndex(2);
- $appender->activateOptions();
-
- return $appender;
- }
-
- public function testSimpleLogging() {
- $appender = $this->createRolloverAppender();
-
- $event = LoggerTestHelper::getWarnEvent("my message123");
-
- for($i = 0; $i < 1000; $i++) {
- $appender->append($event);
- }
-
- $appender->append(LoggerTestHelper::getWarnEvent("my messageXYZ"));
-
- $appender->close();
-
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
- $data = file($file);
- $line = $data[count($data)-1];
- $e = "WARN - my messageXYZ".PHP_EOL;
- self::assertEquals($e, $line);
-
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
- $this->checkFileContent($file);
-
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
- $this->checkFileContent($file);
-
- // Should not roll over three times
- $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'));
- }
-
- public function testLoggingViaLogger() {
- $logger = Logger::getLogger('mycat');
- $logger->setAdditivity(false);
-
- $appender = $this->createRolloverAppender();
-
- $logger->addAppender($appender);
-
- for($i = 0; $i < 1000; $i++) {
- $logger->warn("my message123");
- }
-
- $logger->warn("my messageXYZ");
-
- $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt';
- $data = file($file);
-
- $line = $data[count($data)-1];
- $e = "WARN - my messageXYZ".PHP_EOL;
- self::assertEquals($e, $line);
-
- $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1';
- $this->checkFileContent($file);
-
- $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2';
- $this->checkFileContent($file);
-
- $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'), 'should not roll over three times');
- }
-
- public function testRolloverWithCompression() {
- $logger = Logger::getLogger('mycat');
- $logger->setAdditivity(false);
-
- $appender = $this->createRolloverAppender();
- $appender->setCompress(true);
-
- $logger->addAppender($appender);
-
- for($i = 0; $i < 1000; $i++) {
- $logger->warn(self::WARNING_MASSAGE. $i);
- }
-
- $logger->warn("my messageXYZ");
-
- $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
- $data = file($file);
-
- $line = $data[count($data)-1];
- $e = self::WARNING_MASSAGE.PHP_EOL;
- self::assertEquals($e, $line);
-
- $firstCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1.gz';
- $this->assertTrue(file_exists($firstCompressedRollingFile),'TEST-rolling.txt.1.gz not found');
-
- $firstUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
- $this->assertFalse(file_exists($firstUncompressedRollingField),'TEST-rolling.txt.1 should be replaced by compressed');
-
- $secondCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2.gz';
- $this->assertTrue(file_exists($secondCompressedRollingFile), 'TEST-rolling.txt.2.gz not found');
-
- $secondUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
- $this->assertFalse(file_exists($secondUncompressedRollingField),'TEST-rolling.txt.2 should be replaced by compressed');
-
- }
-
- private function checkFileContent($file) {
- $data = file($file);
- $this->checkText($data);
- }
-
- private function checkText($text) {
- $line = $text[count($text)-1];
- $e = "WARN - my message123".PHP_EOL;
- foreach($text as $r) {
- self::assertEquals($e, $r);
- }
- }
-
- protected function tearDown() {
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1.gz');
- @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2.gz');
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderSocketTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderSocketTest.php b/src/test/php/appenders/LoggerAppenderSocketTest.php
deleted file mode 100644
index 5b9430a..0000000
--- a/src/test/php/appenders/LoggerAppenderSocketTest.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderSocketTest extends PHPUnit_Framework_TestCase {
-
- /** Port on which the socket server will run. */
- const SOCKET_PORT = 12345;
-
- /** The socket server process resource. */
- private $server;
-
- /** The pipes array for the server process. */
- private $pipes;
-
- public function setUp() {
- Logger::clear();
- }
-
- public function tearDown() {
- Logger::clear();
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderSocket();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testLogging()
- {
- Logger::configure(array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderSocket',
- 'params' => array(
- 'remoteHost' => 'localhost',
- 'port' => self::SOCKET_PORT
- ),
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- )
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- ));
-
- $this->startServer();
-
- $logger = Logger::getLogger("myLogger");
- $logger->trace("This message is a test");
- $logger->debug("This message is a test");
- $logger->info("This message is a test");
- $logger->warn("This message is a test");
- $logger->error("This message is a test");
- $logger->fatal("This message is a test");
-
- $actual = $this->getPlayback();
- $this->stopServer();
-
- $expected = "DEBUG - This message is a test" .
- "INFO - This message is a test" .
- "WARN - This message is a test" .
- "ERROR - This message is a test" .
- "FATAL - This message is a test";
-
- $this->assertEquals($expected, $actual);
- }
-
- /** Starts a socket server in a separate process. */
- private function startServer() {
- $serverLog = PHPUNIT_TEMP_DIR . '/socketServer.log';
- $descriptorspec = array(
- 0 => array("pipe", "r"), // stdin
- 1 => array("file", $serverLog, "a"),// stdout
- 2 => array("file", $serverLog, "a") // stderr
- );
-
- $cmd = "php " . dirname(__FILE__) . '/socketServer.php';
- $this->server = proc_open($cmd, $descriptorspec, $this->pipes);
- if ($this->server === false) {
- throw new Exception("Failed starting the socket server process.");
- }
-
- // Sleep a bit to allow server to start
- usleep(200000);
-
- // Verify the server is running
- $status = proc_get_status($this->server);
- if (!$status['running']) {
- throw new Exception("Socket server process failed to start. Check the log at [$serverLog].");
- }
- }
-
- /** Sends a message to the socket server and returns the reply. */
- private function socketSend($msg) {
- $sock = fsockopen('localhost', self::SOCKET_PORT, $errno, $errstr);
- if ($sock === false) {
- throw new Exception("Unable to open socket. Error: [$errno] $errstr");
- }
-
- fputs($sock, "$msg\n");
- $reply = '';
- while(!feof($sock)) {
- $reply .= fgets($sock);
- }
- fclose($sock);
- return trim($reply);
- }
-
- /** Retrieves a playback of all sent messages from the socket server. */
- private function getPlayback() {
- return $this->socketSend('playback');
- }
-
- /** Stops the socket server and closes the process. */
- private function stopServer() {
- $this->socketSend('shutdown');
- foreach($this->pipes as $pipe) {
- fclose($pipe);
- }
- proc_close($this->server);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderSyslogTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderSyslogTest.php b/src/test/php/appenders/LoggerAppenderSyslogTest.php
deleted file mode 100644
index 36d16b0..0000000
--- a/src/test/php/appenders/LoggerAppenderSyslogTest.php
+++ /dev/null
@@ -1,264 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * Tests the syslog appender.
- *
- * Many of these tests rely on reflection features introduced in 5.3 and
- * will be skipped if run on a lower version.
- *
- * This test will only write a single entry to the syslog.
- *
- * @group appenders
- */
-class LoggerAppenderSyslogTest extends PHPUnit_Framework_TestCase {
-
- public function testSettersGetters() {
-
- // Setters should accept any value, without validation
- $expected = "Random string value";
-
- $appender = new LoggerAppenderSyslog();
- $appender->setIdent($expected);
- $appender->setFacility($expected);
- $appender->setOverridePriority($expected);
- $appender->setPriority($expected);
- $appender->setOption($expected);
-
- $actuals = array(
- $appender->getIdent(),
- $appender->getFacility(),
- $appender->getOverridePriority(),
- $appender->getPriority(),
- $appender->getOption()
- );
-
- foreach($actuals as $actual) {
- $this->assertSame($expected, $actual);
- }
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderSyslog();
- $this->assertTrue($appender->requiresLayout());
- }
-
- public function testLogging() {
- $appender = new LoggerAppenderSyslog("myname");
- $appender->setLayout(new LoggerLayoutSimple());
- $appender->activateOptions();
-
- $event = new LoggerLoggingEvent(__CLASS__, new Logger("TestLogger"), LoggerLevel::getLevelError(), "testmessage");
- $appender->append($event);
- }
-
- /** Tests parsing of "option" parameter. */
- public function testOption() {
- if(!method_exists('ReflectionProperty', 'setAccessible')) {
- $this->markTestSkipped("ReflectionProperty::setAccessible() required to perform this test (available in PHP 5.3.2+).");
- }
-
- $options = array(
- 'CONS' => LOG_CONS,
- 'NDELAY' => LOG_NDELAY,
- 'ODELAY' => LOG_ODELAY,
- 'PERROR' => LOG_PERROR,
- 'PID' => LOG_PID,
-
- // test some combinations
- 'CONS|NDELAY' => LOG_CONS | LOG_NDELAY,
- 'PID|PERROR' => LOG_PID | LOG_PERROR,
- 'CONS|PID|NDELAY' => LOG_CONS | LOG_PID | LOG_NDELAY
- );
-
- // Defaults
- $defaultStr = "PID|CONS";
- $default = LOG_PID | LOG_CONS;
-
- // This makes reading of a private property possible
- $property = new ReflectionProperty('LoggerAppenderSyslog', 'intOption');
- $property->setAccessible(true);
-
- // Check default value first
- $appender = new LoggerAppenderSyslog();
- $appender->activateOptions();
- $actual = $property->getValue($appender);
- $this->assertSame($default, $actual, "Failed setting default option [$defaultStr]");
-
- foreach($options as $option => $expected) {
- $appender = new LoggerAppenderSyslog();
- $appender->setOption($option);
- $appender->activateOptions();
-
- $actual = $property->getValue($appender);
- $this->assertSame($expected, $actual, "Failed setting option [$option].");
- }
- }
-
- /** Tests parsing of "priority" parameter. */
- public function testPriority() {
- if(!method_exists('ReflectionProperty', 'setAccessible')) {
- $this->markTestSkipped("ReflectionProperty::setAccessible() required to perform this test (available in PHP 5.3.2+).");
- }
-
- $default = null;
- $defaultStr = 'null';
-
- $priorities = array(
- 'EMERG' => LOG_EMERG,
- 'ALERT' => LOG_ALERT,
- 'CRIT' => LOG_CRIT,
- 'ERR' => LOG_ERR,
- 'WARNING' => LOG_WARNING,
- 'NOTICE' => LOG_NOTICE,
- 'INFO' => LOG_INFO,
- 'DEBUG' => LOG_DEBUG
- );
-
- // This makes reading of a private property possible
- $property = new ReflectionProperty('LoggerAppenderSyslog', 'intPriority');
- $property->setAccessible(true);
-
- // Check default value first
- $appender = new LoggerAppenderSyslog();
- $appender->activateOptions();
- $actual = $property->getValue($appender);
- $this->assertSame($default, $actual, "Failed setting default priority [$defaultStr].");
-
- foreach($priorities as $priority => $expected) {
- $appender = new LoggerAppenderSyslog();
- $appender->setPriority($priority);
- $appender->activateOptions();
-
- $actual = $property->getValue($appender);
- $this->assertSame($expected, $actual, "Failed setting priority [$priority].");
- }
- }
-
- /** Tests parsing of "facility" parameter. */
- public function testFacility() {
- if(!method_exists('ReflectionProperty', 'setAccessible')) {
- $this->markTestSkipped("ReflectionProperty::setAccessible() required to perform this test (available in PHP 5.3.2+).");
- }
-
- // Default value is the same on all OSs
- $default = LOG_USER;
- $defaultStr = 'USER';
-
- // All possible facility strings (some of which might not exist depending on the OS)
- $strings = array(
- 'KERN', 'USER', 'MAIL', 'DAEMON', 'AUTH',
- 'SYSLOG', 'LPR', 'NEWS', 'UUCP', 'CRON', 'AUTHPRIV',
- 'LOCAL0', 'LOCAL1', 'LOCAL2', 'LOCAL3', 'LOCAL4',
- 'LOCAL5', 'LOCAL6', 'LOCAL7',
- );
-
- // Only test facilities which exist on this OS
- $facilities = array();
- foreach($strings as $string) {
- $const = "LOG_$string";
- if (defined($const)) {
- $facilities[$string] = constant($const);
- }
- }
-
- // This makes reading of a private property possible
- $property = new ReflectionProperty('LoggerAppenderSyslog', 'intFacility');
- $property->setAccessible(true);
-
- // Check default value first
- $appender = new LoggerAppenderSyslog();
- $appender->activateOptions();
- $actual = $property->getValue($appender);
- $this->assertSame($default, $default, "Failed setting default facility [$defaultStr].");
-
- foreach($facilities as $facility => $expected) {
- $appender = new LoggerAppenderSyslog();
- $appender->setFacility($facility);
- $appender->activateOptions();
-
- $actual = $property->getValue($appender);
- $this->assertSame($expected, $actual, "Failed setting priority [$facility].");
- }
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- */
- public function testInvalidOption() {
- $appender = new LoggerAppenderSyslog();
- $appender->setOption('CONS|XYZ');
- $appender->activateOptions();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- */
- public function testInvalidPriority() {
- $appender = new LoggerAppenderSyslog();
- $appender->setPriority('XYZ');
- $appender->activateOptions();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- */
- public function testInvalidFacility() {
- $appender = new LoggerAppenderSyslog();
- $appender->setFacility('XYZ');
- $appender->activateOptions();
- }
-
-
- public function testPriorityOverride() {
- if(!method_exists('ReflectionProperty', 'setAccessible')) {
- $this->markTestSkipped("ReflectionProperty::setAccessible() required to perform this test (available in PHP 5.3.2+).");
- }
-
- $appender = new LoggerAppenderSyslog();
- $appender->setPriority('EMERG');
- $appender->setOverridePriority(true);
- $appender->activateOptions();
-
- $levels = array(
- LoggerLevel::getLevelTrace(),
- LoggerLevel::getLevelDebug(),
- LoggerLevel::getLevelInfo(),
- LoggerLevel::getLevelWarn(),
- LoggerLevel::getLevelError(),
- LoggerLevel::getLevelFatal(),
- );
-
- $expected = LOG_EMERG;
-
- $method = new ReflectionMethod('LoggerAppenderSyslog', 'getSyslogPriority');
- $method->setAccessible(true);
-
- foreach($levels as $level) {
- $actual = $method->invoke($appender, $level);
- $this->assertSame($expected, $actual);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/socketServer.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/socketServer.php b/src/test/php/appenders/socketServer.php
deleted file mode 100644
index 39ec47c..0000000
--- a/src/test/php/appenders/socketServer.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- *
- * A simple socket server used in LoggerAppenderSocketTest.
- */
-
-// Port on which to start the server
-define('SERVER_PORT', 12345);
-
-// Prevent hangs
-set_time_limit(0);
-
-// Create a socket
-$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
-if ($sock === false) {
- die("Failed creating socket: " . socket_strerror(socket_last_error()));
-}
-
-if (socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1) === false) {
- die("Failed setting socket options: " . socket_strerror(socket_last_error()));
-}
-
-if (socket_bind($sock, 'localhost', SERVER_PORT) === false) {
- die("Failed binding socket: " . socket_strerror(socket_last_error()));
-}
-
-if (socket_listen($sock, 100) === false) {
- die("Failed binding socket: " . socket_strerror(socket_last_error()));
-}
-
-socket_getsockname($sock, $addr, $port);
-myLog("Server Listening on $addr:$port");
-
-// Buffer which will store incoming messages
-$playback = "";
-
-while(true) {
- myLog("Waiting for incoming connections...");
-
- $msgsock = socket_accept($sock);
- if ($msgsock === false) {
- myLog("Failed accepting a connection: " . socket_strerror(socket_last_error()));
- break;
- }
-
- $buf = socket_read($msgsock, 2048, PHP_NORMAL_READ);
-
- myLog('Received: "' . trim($buf) . '"');
-
- // Shutdown command
- if (trim($buf) == 'shutdown') {
- myLog("Shutting down.");
- socket_close($msgsock);
- break;
- }
- // Playback command
- else if (trim($buf) == 'playback') {
- myLog("Returning playback: \"$playback\"");
- socket_write($msgsock, $playback);
- }
- // Default: add to playback buffer
- else {
- $playback .= trim($buf);
- }
-
- socket_close($msgsock);
-}
-
-myLog("Closing socket.");
-socket_close($sock);
-
-function myLog($msg) {
- echo date("Y-m-d H:i:s") . " $msg\n";
-}
-
-?>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/bootstrap.php
----------------------------------------------------------------------
diff --git a/src/test/php/bootstrap.php b/src/test/php/bootstrap.php
deleted file mode 100644
index 2dfb255..0000000
--- a/src/test/php/bootstrap.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-error_reporting(E_ALL | E_STRICT);
-
-// Required for testing logging of sessionID in pattern layout
-session_start();
-
-date_default_timezone_set('Europe/London');
-
-// Define a temp dir where tests may write to
-$tmpDir = dirname(__FILE__) . '/../../../target/temp/phpunit';
-if (!is_dir($tmpDir)) {
- mkdir($tmpDir, 0777, true);
-}
-define('PHPUNIT_TEMP_DIR', realpath($tmpDir));
-
-// Make the path to the configurations dir for easier access
-$confDir = dirname(__FILE__) . '/../resources/configs';
-define('PHPUNIT_CONFIG_DIR', realpath($confDir));
-
-require dirname(__FILE__) . '/../../main/php/Logger.php';
-require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'LoggerTestHelper.php';
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/configurators/LoggerConfigurationAdapterINITest.php
----------------------------------------------------------------------
diff --git a/src/test/php/configurators/LoggerConfigurationAdapterINITest.php b/src/test/php/configurators/LoggerConfigurationAdapterINITest.php
deleted file mode 100644
index 2159c73..0000000
--- a/src/test/php/configurators/LoggerConfigurationAdapterINITest.php
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group configurators
- */
-class LoggerConfigurationAdapterINITest extends PHPUnit_Framework_TestCase {
-
- /** Expected output of parsing config1.ini. */
- private $expected1 = array(
- 'threshold' => 'debug',
- 'rootLogger' => array(
- 'level' => 'DEBUG',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutTTCC',
- ),
- ),
- 'file' => array(
- 'class' => 'LoggerAppenderDailyFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'params' => array(
- 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
- ),
- ),
- 'params' => array(
- 'datePattern' => 'Ymd',
- 'file' => 'target/examples/daily_%s.log',
- ),
- 'threshold' => 'warn'
- ),
- ),
- 'loggers' => array(
- 'foo' => array(
- 'level' => 'warn',
- 'appenders' => array('default'),
- ),
- 'foo.bar' => array(
- 'level' => 'debug',
- 'appenders' => array('file'),
- 'additivity' => 'true',
- ),
- 'foo.bar.baz' => array(
- 'level' => 'trace',
- 'appenders' => array('default', 'file'),
- 'additivity' => 'false',
- ),
- ),
- 'renderers' => array(
- array(
- 'renderedClass' => 'Fruit',
- 'renderingClass' => 'FruitRenderer',
- ),
- array(
- 'renderedClass' => 'Beer',
- 'renderingClass' => 'BeerRenderer',
- ),
- ),
- );
-
- public function testConfig() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_valid.ini';
- $adapter = new LoggerConfigurationAdapterINI();
- $actual = $adapter->convert($url);
-
- $this->assertSame($this->expected1, $actual);
- }
-
- /**
- * Test exception is thrown when file cannot be found.
- * @expectedException LoggerException
- * @expectedExceptionMessage File [you/will/never/find/me.ini] does not exist.
- */
- public function testNonExistantFileException() {
- $adapter = new LoggerConfigurationAdapterINI();
- $adapter->convert('you/will/never/find/me.ini');
- }
-
- /**
- * Test exception is thrown when file is not a valid ini file.
- * @expectedException LoggerException
- * @expectedExceptionMessage Error parsing configuration file
- */
- public function testInvalidFileException() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_syntax.ini';
- $adapter = new LoggerConfigurationAdapterINI();
- $adapter->convert($url);
- }
-
- /**
- * Test a warning is triggered when configurator doesn't understand a line.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.layout.param.bla = LoggerLayoutTTCC". Skipping.
- */
- public function testInvalidLineWarning1() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_1.ini';
- $adapter = new LoggerConfigurationAdapterINI();
- $adapter->convert($url);
- }
-
- /**
- * Test a warning is triggered when configurator doesn't understand a line.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Don't know how to parse the following line: "log4php.appender.default.not-layout.param = LoggerLayoutTTCC". Skipping.
- */
- public function testInvalidLineWarning2() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/ini/config_invalid_appender_declaration_2.ini';
- $adapter = new LoggerConfigurationAdapterINI();
- $adapter->convert($url);
- }
-
- /**
- * Check that various boolean equivalents from ini file convert properly
- * to boolean.
- */
- public function testBooleanValues() {
- $values = parse_ini_file(PHPUNIT_CONFIG_DIR . '/adapters/ini/values.ini');
-
- $actual = LoggerOptionConverter::toBooleanEx($values['unquoted_true']);
- self::assertTrue($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['unquoted_yes']);
- self::assertTrue($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['unquoted_false']);
- self::assertFalse($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['unquoted_no']);
- self::assertFalse($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['quoted_true']);
- self::assertTrue($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['quoted_false']);
- self::assertFalse($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['unquoted_one']);
- self::assertTrue($actual);
-
- $actual = LoggerOptionConverter::toBooleanEx($values['unquoted_zero']);
- self::assertFalse($actual);
- }
-
-}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/configurators/LoggerConfigurationAdapterPHPTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/configurators/LoggerConfigurationAdapterPHPTest.php b/src/test/php/configurators/LoggerConfigurationAdapterPHPTest.php
deleted file mode 100644
index 23a0c1e..0000000
--- a/src/test/php/configurators/LoggerConfigurationAdapterPHPTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group configurators
- */
-class LoggerConfigurationAdapterPHPTest extends PHPUnit_Framework_TestCase {
-
- private $expected1 = array(
- 'rootLogger' => array(
- 'level' => 'info',
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- )
- )
- )
- );
-
- public function testConfig() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_valid.php';
- $adapter = new LoggerConfigurationAdapterPHP();
- $actual = $adapter->convert($url);
-
- $this->assertSame($this->expected1, $actual);
- }
-
- /**
- * Test exception is thrown when file cannot be found.
- * @expectedException LoggerException
- * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
- */
- public function testNonExistantFileWarning() {
- $adapter = new LoggerConfigurationAdapterPHP();
- $adapter->convert('you/will/never/find/me.conf');
- }
-
- /**
- * Test exception is thrown when file is not valid.
- * @expectedException LoggerException
- * @expectedExceptionMessage Error parsing configuration: syntax error
- */
- public function testInvalidFileWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_invalid_syntax.php';
- $adapter = new LoggerConfigurationAdapterPHP();
- $adapter->convert($url);
- }
-
- /**
- * Test exception is thrown when the configuration is empty.
- * @expectedException LoggerException
- * @expectedExceptionMessage Invalid configuration: empty configuration array.
- */
- public function testEmptyConfigWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_empty.php';
- $adapter = new LoggerConfigurationAdapterPHP();
- $adapter->convert($url);
- }
-
- /**
- * Test exception is thrown when the configuration does not contain an array.
- * @expectedException LoggerException
- * @expectedExceptionMessage Invalid configuration: not an array.
- */
- public function testInvalidConfigWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/php/config_not_an_array.php';
- $adapter = new LoggerConfigurationAdapterPHP();
- $adapter->convert($url);
- }
-}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php b/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php
deleted file mode 100644
index ff71ef1..0000000
--- a/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group configurators
- */
-class LoggerConfigurationAdapterXMLTest extends PHPUnit_Framework_TestCase {
-
- /** Expected output of parsing config1.xml.*/
- private $expected1 = array(
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutTTCC',
- ),
- 'filters' => array(
- array(
- 'class' => 'LoggerFilterLevelRange',
- 'params' => array(
- 'levelMin' => 'ERROR',
- 'levelMax' => 'FATAL',
- 'acceptOnMatch' => 'false',
- ),
- ),
- array(
- 'class' => 'LoggerFilterDenyAll',
- ),
- ),
- ),
- 'file' => array(
- 'class' => 'LoggerAppenderDailyFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'params' => array(
- 'conversionPattern' => '%d{ISO8601} [%p] %c: %m (at %F line %L)%n',
- ),
- ),
- 'params' => array(
- 'datePattern' => 'Ymd',
- 'file' => 'target/examples/daily_%s.log',
- ),
- 'threshold' => 'warn'
- ),
- ),
- 'loggers' => array(
- 'foo.bar.baz' => array(
- 'level' => 'trace',
- 'additivity' => 'false',
- 'appenders' => array('default'),
- ),
- 'foo.bar' => array(
- 'level' => 'debug',
- 'additivity' => 'true',
- 'appenders' => array('file'),
- ),
- 'foo' => array(
- 'level' => 'warn',
- 'appenders' => array('default', 'file'),
- ),
- ),
- 'renderers' => array(
- array(
- 'renderedClass' => 'Fruit',
- 'renderingClass' => 'FruitRenderer',
- ),
- array(
- 'renderedClass' => 'Beer',
- 'renderingClass' => 'BeerRenderer',
- ),
- ),
- 'threshold' => 'debug',
- 'rootLogger' => array(
- 'level' => 'DEBUG',
- 'appenders' => array('default'),
- ),
- );
-
- public function setUp() {
- Logger::resetConfiguration();
- }
-
- public function tearDown() {
- Logger::resetConfiguration();
- }
-
- public function testConversion() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid.xml';
- $adapter = new LoggerConfigurationAdapterXML();
- $actual = $adapter->convert($url);
- $this->assertEquals($this->expected1, $actual);
- }
-
- public function testConversion2() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid_underscore.xml';
- $adapter = new LoggerConfigurationAdapterXML();
- $actual = $adapter->convert($url);
-
- $this->assertEquals($this->expected1, $actual);
- }
-
- /**
- * Test exception is thrown when file cannot be found.
- * @expectedException LoggerException
- * @expectedExceptionMessage File [you/will/never/find/me.conf] does not exist.
- */
- public function testNonExistantFile() {
- $adapter = new LoggerConfigurationAdapterXML();
- $adapter->convert('you/will/never/find/me.conf');
- }
-
- /**
- * Test exception is thrown when file contains invalid XML.
- * @expectedException LoggerException
- * @expectedExceptionMessage Error loading configuration file: Premature end of data in tag configuration line
- */
- public function testInvalidXMLFile() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_invalid_syntax.xml';
- $adapter = new LoggerConfigurationAdapterXML();
- $adapter->convert($url);
- }
-
- /**
- * Test that a warning is triggered when two loggers with the same name
- * are defined.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Duplicate logger definition [foo]. Overwriting
- */
- public function testDuplicateLoggerWarning() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
- $adapter = new LoggerConfigurationAdapterXML();
- $adapter->convert($url);
- }
-
-
- /**
- * Test that when two loggers with the same name are defined, the second
- * one will overwrite the first.
- */
- public function testDuplicateLoggerConfig() {
- $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_duplicate_logger.xml';
- $adapter = new LoggerConfigurationAdapterXML();
-
- // Supress the warning so that test can continue
- $config = @$adapter->convert($url);
-
- // Second definition of foo has level set to warn (the first to info)
- $this->assertEquals('warn', $config['loggers']['foo']['level']);
- }
-}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/filters/LoggerFilterDenyAllTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/filters/LoggerFilterDenyAllTest.php b/src/test/php/filters/LoggerFilterDenyAllTest.php
deleted file mode 100644
index 1e9bb3d..0000000
--- a/src/test/php/filters/LoggerFilterDenyAllTest.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage filters
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group filters
- */
-class LoggerFilterDenyAllTest extends PHPUnit_Framework_TestCase {
-
- public function testDecide() {
- $filter = new LoggerFilterDenyAll();
-
- $events = array(
- LoggerTestHelper::getTraceEvent(),
- LoggerTestHelper::getDebugEvent(),
- LoggerTestHelper::getInfoEvent(),
- LoggerTestHelper::getWarnEvent(),
- LoggerTestHelper::getErrorEvent(),
- LoggerTestHelper::getFatalEvent(),
- );
-
- foreach($events as $event) {
- $actual = $filter->decide($event);
- self::assertEquals(LoggerFilter::DENY, $actual);
- }
- }
-
- public function testConfiguration() {
- $config = LoggerConfiguratorDefault::getDefaultConfiguration();
- $config['appenders']['default']['filters'] = array(
- array(
- 'class' => 'LoggerFilterDenyAll'
- )
- );
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
-
- ob_start();
- $logger->trace('Test');
- $logger->debug('Test');
- $logger->info('Test');
- $logger->warn('Test');
- $logger->error('Test');
- $logger->fatal('Test');
- $actual = ob_get_clean();
-
- $this->assertEmpty($actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/filters/LoggerFilterLevelMatchTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/filters/LoggerFilterLevelMatchTest.php b/src/test/php/filters/LoggerFilterLevelMatchTest.php
deleted file mode 100644
index c402030..0000000
--- a/src/test/php/filters/LoggerFilterLevelMatchTest.php
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage filters
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group filters
- */
-class LoggerFilterLevelMatchTest extends PHPUnit_Framework_TestCase {
-
- /**
- * Tests all possible combinations of event level and filter levelToMatch
- * option, with acceptOnMatch set to TRUE.
- */
- public function testDecideAccept() {
- $filter = new LoggerFilterLevelMatch();
- $filter->setAcceptOnMatch("true");
-
- $levels = LoggerTestHelper::getAllLevels();
- $events = LoggerTestHelper::getAllEvents();
-
- foreach($levels as $level) {
- $filter->setLevelToMatch($level);
-
- foreach($events as $event) {
- // Expecting given level to be accepted, neutral for others
- $expected = ($event->getLevel() == $level) ? LoggerFilter::ACCEPT : LoggerFilter::NEUTRAL;
- $actual = $filter->decide($event);
-
- // Get string represenations for logging
- $sExpected = LoggerTestHelper::decisionToString($expected);
- $sActual = LoggerTestHelper::decisionToString($actual);
-
- $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
- }
- }
- }
-
- /**
- * Tests all possible combinations of event level and filter levelToMatch
- * option, with acceptOnMatch set to TRUE.
- */
- public function testDecideDeny() {
- $filter = new LoggerFilterLevelMatch();
- $filter->setAcceptOnMatch("false");
-
- $levels = LoggerTestHelper::getAllLevels();
- $events = LoggerTestHelper::getAllEvents();
-
- foreach($levels as $level) {
- $filter->setLevelToMatch($level);
-
- foreach($events as $event) {
- // Expecting given level to be denied, neutral for others
- $expected = ($event->getLevel() == $level) ? LoggerFilter::DENY : LoggerFilter::NEUTRAL;
- $actual = $filter->decide($event);
-
- // Get string represenations for logging
- $sExpected = LoggerTestHelper::decisionToString($expected);
- $sActual = LoggerTestHelper::decisionToString($actual);
-
- $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
- }
- }
- }
-
- /** Test that filter always decides NEUTRAL when levelToMatch is not set. */
- public function testDecideNull() {
- $filter = new LoggerFilterLevelMatch();
- $events = LoggerTestHelper::getAllEvents();
-
- foreach($events as $event) {
- $expected = LoggerFilter::NEUTRAL;
- $actual = $filter->decide($event);
-
- // Get string represenations for logging
- $sExpected = LoggerTestHelper::decisionToString($expected);
- $sActual = LoggerTestHelper::decisionToString($actual);
- $level = $event->getLevel();
-
- $this->assertSame($expected, $actual, "Failed asserting filter decision for event level <$level>. Expected <$sExpected>, found <$sActual>.");
- }
- }
-
- /** Test logger configuration. */
- public function testAcceptConfig() {
- $config = LoggerTestHelper::getEchoConfig();
-
- // Add filters to default appender
- $config['appenders']['default']['filters'] = array(
-
- // Accepts only INFO events
- array(
- 'class' => 'LoggerFilterLevelMatch',
- 'params' => array(
- 'levelToMatch' => 'info',
- 'acceptOnMatch' => true
- )
- ),
-
- // Denies all events not accepted by first filter
- array(
- 'class' => 'LoggerFilterDenyAll',
- )
- );
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
-
- ob_start();
- $logger->trace('Test');
- $logger->debug('Test');
- $logger->info('Test');
- $logger->warn('Test');
- $logger->error('Test');
- $logger->fatal('Test');
-
- $actual = ob_get_clean();
-
-
- $expected = "INFO - Test" . PHP_EOL;
- }
-
- public function testDenyConfig() {
- $config = LoggerTestHelper::getEchoConfig();
-
- // Add filter which denies INFO events
- $config['appenders']['default']['filters'] = array(
- array(
- 'class' => 'LoggerFilterLevelMatch',
- 'params' => array(
- 'levelToMatch' => 'info',
- 'acceptOnMatch' => false
- )
- )
- );
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
-
- ob_start();
- $logger->trace('Test');
- $logger->debug('Test');
- $logger->info('Test');
- $logger->warn('Test');
- $logger->error('Test');
- $logger->fatal('Test');
-
- $actual = ob_get_clean();
-
- // Should log all except info
- $expected =
- "TRACE - Test" . PHP_EOL .
- "DEBUG - Test" . PHP_EOL .
- "WARN - Test" . PHP_EOL .
- "ERROR - Test" . PHP_EOL .
- "FATAL - Test" . PHP_EOL;
-
- $this->assertSame($expected, $actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/filters/LoggerFilterLevelRangeTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/filters/LoggerFilterLevelRangeTest.php b/src/test/php/filters/LoggerFilterLevelRangeTest.php
deleted file mode 100644
index 7f16590..0000000
--- a/src/test/php/filters/LoggerFilterLevelRangeTest.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage filters
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group filters
- */
-class LoggerFilterLevelRangeTest extends PHPUnit_Framework_TestCase {
-
- public function testDecide() {
- $filter = new LoggerFilterLevelRange();
- $filter->setAcceptOnMatch("true");
- $filter->setLevelMin(LoggerLevel::getLevelWarn());
- $filter->setLevelMax(LoggerLevel::getLevelError());
-
- $eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
- $eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, LoggerFilter::ACCEPT);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, LoggerFilter::DENY);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, LoggerFilter::ACCEPT);
- }
-
- public function testDecideAcceptFalse() {
- $filter = new LoggerFilterLevelRange();
- $filter->setAcceptOnMatch("false");
- $filter->setLevelMin(LoggerLevel::getLevelWarn());
- $filter->setLevelMax(LoggerLevel::getLevelError());
-
- $eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
- $eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, LoggerFilter::DENY);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
- }
- }
[16/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/css/bootstrap.min.css
----------------------------------------------------------------------
diff --git a/src/site/resources/css/bootstrap.min.css b/src/site/resources/css/bootstrap.min.css
deleted file mode 100644
index 3119038..0000000
--- a/src/site/resources/css/bootstrap.min.css
+++ /dev/null
@@ -1,9 +0,0 @@
-/*!
- * Bootstrap v2.1.0
- *
- * Copyright 2012 Twitter, Inc
- * Licensed under the Apache License v2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Designed and built with all the love in the world @twitter by @mdo and @fat.
- */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:con
tent-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0
1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offs
et1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.9
14893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluid .offset8{mar
gin-left:70.2127659574468%;*margin-left:70.10638297872339%}.row-fluid .offset8:first-child{margin-left:68.08510638297872%;*margin-left:67.9787234042553%}.row-fluid .offset7{margin-left:61.70212765957446%;*margin-left:61.59574468085106%}.row-fluid .offset7:first-child{margin-left:59.574468085106375%;*margin-left:59.46808510638297%}.row-fluid .offset6{margin-left:53.191489361702125%;*margin-left:53.085106382978715%}.row-fluid .offset6:first-child{margin-left:51.063829787234035%;*margin-left:50.95744680851063%}.row-fluid .offset5{margin-left:44.68085106382979%;*margin-left:44.57446808510638%}.row-fluid .offset5:first-child{margin-left:42.5531914893617%;*margin-left:42.4468085106383%}.row-fluid .offset4{margin-left:36.170212765957444%;*margin-left:36.06382978723405%}.row-fluid .offset4:first-child{margin-left:34.04255319148936%;*margin-left:33.93617021276596%}.row-fluid .offset3{margin-left:27.659574468085104%;*margin-left:27.5531914893617%}.row-fluid .offset3:first-child{margin-left:25
.53191489361702%;*margin-left:25.425531914893618%}.row-fluid .offset2{margin-left:19.148936170212764%;*margin-left:19.04255319148936%}.row-fluid .offset2:first-child{margin-left:17.02127659574468%;*margin-left:16.914893617021278%}.row-fluid .offset1{margin-left:10.638297872340425%;*margin-left:10.53191489361702%}.row-fluid .offset1:first-child{margin-left:8.51063829787234%;*margin-left:8.404255319148938%}[class*="span"].hide,.row-fluid [class*="span"].hide{display:none}[class*="span"].pull-right,.row-fluid [class*="span"].pull-right{float:right}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;line-height:0;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;line-height:0;content:""}.container-fluid:after{clear:both}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:20px;font-weight:200;line-height:30px}small{font-size:8
5%}strong{font-weight:bold}em{font-style:italic}cite{font-style:normal}.muted{color:#999}h1,h2,h3,h4,h5,h6{margin:10px 0;font-family:inherit;font-weight:bold;line-height:1;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;line-height:1;color:#999}h1{font-size:36px;line-height:40px}h2{font-size:30px;line-height:40px}h3{font-size:24px;line-height:40px}h4{font-size:18px;line-height:20px}h5{font-size:14px;line-height:20px}h6{font-size:12px;line-height:20px}h1 small{font-size:24px}h2 small{font-size:18px}h3 small{font-size:14px}h4 small{font-size:14px}.page-header{padding-bottom:9px;margin:20px 0 30px;border-bottom:1px solid #eee}ul,ol{padding:0;margin:0 0 10px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}li{line-height:20px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}dl{margin-bottom:20px}dt,dd{line-height:20px}dt{font-weight:bold}dd{margin-left:10px}.dl-horizontal dt{float:left;width:120px;overflow:hidden;
clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:130px}hr{margin:20px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}abbr[title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:25px}blockquote small{display:block;line-height:20px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}blockquote.pull-right small:before{content:''}blockquote.pull-right small:after{content:'\00A0 \2014'}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:20px;font-style:normal;line-height:20px}code,pre{padding:0 3px 2px
;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:20px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:20px}pre code{padding:0;color:inherit;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 20px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333;border:0;border-bottom:1px solid #e5e5e5}legend small{font-size:15px;color:#999}label,input,button,select,textarea{font-size:14px;font-we
ight:normal;line-height:20px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:20px;padding:4px 6px;margin-bottom:9px;font-size:14px;line-height:20px;color:#555;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}input,textarea{width:210px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"]
,.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-
box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;*margin-top:0;line-height:normal;cursor:pointer}input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}select,input[type="file"]{height:30px;*margin-top:4px;line-height:30px}select{width:220px;background-color:#fff;border:1px solid #bbb}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.uneditable-input,.uneditable-textarea{color:#999;cursor:not-allowed;background-color:#fcfcfc;border-color:#ccc;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)
;box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}.uneditable-input{overflow:hidden;white-space:nowrap}.uneditable-textarea{width:auto;height:auto}input:-moz-placeholder,textarea:-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}.radio,.checkbox{min-height:18px;padding-left:18px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-18px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*
="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:926px}input.span11,textarea.span11,.uneditable-input.span11{width:846px}input.span10,textarea.span10,.uneditable-input.span10{width:766px}input.span9,textarea.span9,.uneditable-input.span9{width:686px}input.span8,textarea.span8,.unedit
able-input.span8{width:606px}input.span7,textarea.span7,.uneditable-input.span7{width:526px}input.span6,textarea.span6,.uneditable-input.span6{width:446px}input.span5,textarea.span5,.uneditable-input.span5{width:366px}input.span4,textarea.span4,.uneditable-input.span4{width:286px}input.span3,textarea.span3,.uneditable-input.span3{width:206px}input.span2,textarea.span2,.uneditable-input.span2{width:126px}input.span1,textarea.span1,.uneditable-input.span1{width:46px}.controls-row{*zoom:1}.controls-row:before,.controls-row:after{display:table;line-height:0;content:""}.controls-row:after{clear:both}.controls-row [class*="span"]{float:left}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning>label,.control-group.warning .h
elp-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853;border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.warning .checkbox:focus,.control-group.warning .radio:focus,.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error>label,.control-group.error
.help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48;border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.error .checkbox:focus,.control-group.error .radio:focus,.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success>label,.control-group.success .help-block,.control
-group.success .help-inline{color:#468847}.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847;border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.success .checkbox:focus,.control-group.success .radio:focus,.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}input:focus:required:invalid,textarea:focus:required:invalid,selec
t:focus:required:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:required:invalid:focus,textarea:focus:required:invalid:focus,select:focus:required:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:19px 20px 20px;margin-top:20px;margin-bottom:20px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1}.form-actions:before,.form-actions:after{display:table;line-height:0;content:""}.form-actions:after{clear:both}.help-block,.help-inline{color:#595959}.help-block{display:block;margin-bottom:10px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-append,.input-prepend{margin-bottom:5px;font-size:0;white-space:nowrap}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;font-size:1
4px;vertical-align:top;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-append input:focus,.input-prepend input:focus,.input-append select:focus,.input-prepend select:focus,.input-append .uneditable-input:focus,.input-prepend .uneditable-input:focus{z-index:2}.input-append .add-on,.input-prepend .add-on{display:inline-block;width:auto;height:20px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:20px;text-align:center;text-shadow:0 1px 0 #fff;background-color:#eee;border:1px solid #ccc}.input-append .add-on,.input-prepend .add-on,.input-append .btn,.input-prepend .btn{margin-left:-1px;vertical-align:top;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-append .active,.input-prepend .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:3px 0 0
3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append .add-on:last-child,.input-append .btn:last-child{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}input.search-query{padding-right:14px;pad
ding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.form-search .input-append .search-query,.form-search .input-prepend .search-query{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.form-search .input-append .search-query{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search .input-append .btn{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .search-query{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .btn{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.for
m-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;vertical-align:middle;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label,.form-search .btn-group,.form-inline .btn-group{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inli
ne .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:10px}legend+.control-group{margin-top:20px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:20px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;line-height:0;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:140px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:160px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:160px}.form-horizontal .help-block{margin-top:10px;margin-bottom:0}.form-horizontal .form-actions{padding-left:160px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:20px}.table th,.table td{padding:8px;line-height:20px;text-alig
n:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapse;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child
td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child th:first-child,.table-bordered tbody:first-child tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child th:last-child,.table-bordered tbody:first-child tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child th:first-child,.table-bordered tbody:last-child tr:last-child td:first-child,.table-bordered tfoot:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-b
ordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child tr:last-child td:last-child,.table-bordered tfoot:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-bordered caption+thead tr:first-child th:first-child,.table-bordered caption+tbody tr:first-child td:first-child,.table-bordered colgroup+thead tr:first-child th:first-child,.table-bordered colgroup+tbody tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered caption+thead tr:first-child th:last-child,.table-bordered caption+tbody tr:first-child td:last-child,.table-bordered colgroup+thead tr:first-child th:last-child,.table-bordered colgroup+tbody tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-right-topleft:4px}.table-striped tbody tr:nth-child(odd) td,.table-s
triped tbody tr:nth-child(odd) th{background-color:#f9f9f9}.table-hover tbody tr:hover td,.table-hover tbody tr:hover th{background-color:#f5f5f5}table [class*=span],.row-fluid table [class*=span]{display:table-cell;float:none;margin-left:0}table .span1{float:none;width:44px;margin-left:0}table .span2{float:none;width:124px;margin-left:0}table .span3{float:none;width:204px;margin-left:0}table .span4{float:none;width:284px;margin-left:0}table .span5{float:none;width:364px;margin-left:0}table .span6{float:none;width:444px;margin-left:0}table .span7{float:none;width:524px;margin-left:0}table .span8{float:none;width:604px;margin-left:0}table .span9{float:none;width:684px;margin-left:0}table .span10{float:none;width:764px;margin-left:0}table .span11{float:none;width:844px;margin-left:0}table .span12{float:none;width:924px;margin-left:0}table .span13{float:none;width:1004px;margin-left:0}table .span14{float:none;width:1084px;margin-left:0}table .span15{float:none;width:1164px;margin-left:
0}table .span16{float:none;width:1244px;margin-left:0}table .span17{float:none;width:1324px;margin-left:0}table .span18{float:none;width:1404px;margin-left:0}table .span19{float:none;width:1484px;margin-left:0}table .span20{float:none;width:1564px;margin-left:0}table .span21{float:none;width:1644px;margin-left:0}table .span22{float:none;width:1724px;margin-left:0}table .span23{float:none;width:1804px;margin-left:0}table .span24{float:none;width:1884px;margin-left:0}.table tbody tr.success td{background-color:#dff0d8}.table tbody tr.error td{background-color:#f2dede}.table tbody tr.info td{background-color:#d9edf7}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;margin-top:1px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}.icon-white,.nav>.active>a>[class^="icon-"],.nav>.active>a>[class*=" icon-"],.dropdown-menu>li>a:hover>[clas
s^="icon-"],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>.active>a>[class^="icon-"],.dropdown-menu>.active>a>[class*=" icon-"]{background-image:url("../img/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{back
ground-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.ic
on-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72p
x}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px
}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{backgrou
nd-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{width:16px;background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{background-position:-384px -120px}.icon-folder-open{width:16px;background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-
certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.car
et{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:""}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu a{display:blo
ck;padding:3px 20px;clear:both;font-weight:normal;line-height:20px;color:#333;white-space:nowrap}.dropdown-menu li>a:hover,.dropdown-menu li>a:focus,.dropdown-submenu:hover>a{color:#fff;text-decoration:none;background-color:#08c;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu .active>a,.dropdown-menu .active>a:hover{color:#fff;text-decoration:none;background-color:#08c;background-color:#0081c2;background-image:linear-gradient(to bottom,#08c,#0077b3);background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100
%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-repeat:repeat-x;outline:0;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu .disabled>a,.dropdown-menu .disabled>a:hover{color:#999}.dropdown-menu .disabled>a:hover{text-decoration:none;cursor:default;background-color:transparent}.open{*z-index:1000}.open>.dropdown-menu{display:block}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:"\2191"}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.dropdown-submenu{position:relative}.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px}.d
ropdown-submenu:hover .dropdown-menu{display:block}.dropdown-submenu>a:after{display:block;float:right;width:0;height:0;margin-top:5px;margin-right:-10px;border-color:transparent;border-left-color:#ccc;border-style:solid;border-width:5px 0 5px 5px;content:" "}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown .dropdown-menu .nav-header{padding-right:20px;padding-left:20px}.typeahead{margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-rad
ius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{position:relative;height:0;overflow:hidden;overflow:visible \9;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:20px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 14px;margin-bottom:0;*margin-left:.3em;font-size:14px;line-height:20px;*line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);
vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #bbb;*border:0;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-bottom-color:#a2a2a2;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-
shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover{color:#333;text-decoration:none;background-color:#e6e6e6;*background-color:#d9d9d9;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-color:#e6e6e6;background-color:#d9d9d9 \9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2p
x rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-color:#e6e6e6;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:9px 14px;font-size:16px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.btn-large [class^="icon-"]{margin-top:2px}.btn-small{padding:3px 9px;font-size:12px;line-height:18px}.btn-small [class^="icon-"]{margin-top:0}.btn-mini{padding:2px 6px;font-size:11px;line-height:16px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn{border-color:#c5c5c5;border-color:rgba(0,0,0,0.15) rgba(0,0,0,0.15) rgba(0,0,0,0.25)}.btn-primary{color:#fff;text-shadow:0 -1p
x 0 rgba(0,0,0,0.25);background-color:#006dcc;*background-color:#04c;background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-image:-moz-linear-gradient(top,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;*background-color:#f89406
;background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#da4f49;*background-color:#bd362f;background-image:-webkit-g
radient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffbd362f',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{color:#fff;background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#5bb75b;*background-color:#51a351;background-image:-webkit-gradient(linear,0 0,0 100%,from(#6
2c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(to bottom,#62c462,#51a351);background-image:-moz-linear-gradient(top,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff51a351',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{color:#fff;background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#49afcd;*background-color:#2f96b4;background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));backgroun
d-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(to bottom,#5bc0de,#2f96b4);background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff2f96b4',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{color:#fff;background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#363636;*background-color:#222;background-image:-webkit-gradient(linear,0 0,0 100%,from(#444),to(#222));background-image:-webkit-linear-gradient(top,#444,#222);backgroun
d-image:-o-linear-gradient(top,#444,#222);background-image:linear-gradient(to bottom,#444,#222);background-image:-moz-linear-gradient(top,#444,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff444444',endColorstr='#ff222222',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{color:#fff;background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:3px;*padding-bottom:3px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*paddi
ng-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-link,.btn-link:active{background-color:transparent;background-image:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-link{color:#08c;cursor:pointer;border-color:transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-link:hover{color:#005580;text-decoration:underline;background-color:transparent}.btn-group{position:relative;*margin-left:.3em;font-size:0;white-space:nowrap}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:10px;margin-bottom:10px;font-size:0}.btn-toolbar .btn-group{display:inline-block;*display:inline;*zoom:1}.btn-toolbar .btn+.btn,.btn-toolbar .btn-group+.btn,.btn-toolbar .btn+.btn-group{margin-left:5px}.btn-group>.btn{position:relative;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn+.btn{margin-left:-1px}.btn-group>.btn,
.btn-group>.dropdown-menu{font-size:14px}.btn-group>.btn-mini{font-size:11px}.btn-group>.btn-small{font-size:12px}.btn-group>.btn-large{font-size:16px}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-
top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{*padding-top:5px;padding-right:8px;*padding-bottom:5px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini+.dropdown-toggle{*padding-top:2px;padding-right:5px;*padding-bottom:2px;padding-left:5px}.btn-group>.btn-small+.dropdown-toggle{*padding-top:5px;*padding-bottom:4px}.btn-group>.btn-large
+.dropdown-toggle{*padding-top:7px;padding-right:12px;*padding-bottom:7px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#04c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:8px;margin-left:0}.btn-mini .caret,.btn-small .caret,.btn-large .caret{margin-top:6px}.btn-large .caret{border-top-width:5px;bord
er-right-width:5px;border-left-width:5px}.dropup .btn-large .caret{border-top:0;border-bottom:5px solid #000}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff}.btn-group-vertical{display:inline-block;*display:inline;*zoom:1}.btn-group-vertical .btn{display:block;float:none;width:100%;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group-vertical .btn+.btn{margin-top:-1px;margin-left:0}.btn-group-vertical .btn:first-child{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.btn-group-vertical .btn:last-child{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.btn-group-vertical .btn-large:first-child{-webkit-border-radius:6px 6px 0 0;-moz-border-radius:6px 6px 0 0;border-radius:6px 6px 0 0}.btn-group-vertical .btn-large:last-child{-webkit-border-radius:0 0 6px 6px;-moz-border-r
adius:0 0 6px 6px;border-radius:0 0 6px 6px}.alert{padding:8px 35px 8px 14px;margin-bottom:20px;color:#c09853;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert h4{margin:0}.alert .close{position:relative;top:-2px;right:-21px;line-height:20px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:20px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>.pull-right{float:right}.nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:20px;color:#999;text-sh
adow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;line-height:0;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom
:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:20px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-m
oz-border-radius-topright:4px;-moz-border-radius-topleft:4px}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-moz-border-radius-bottomleft:4px}.nav-tabs.nav-stacked>li>a:hover{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.nav-pills .dropdown-menu{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.nav .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav .dropdown-toggle:hover .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .dropdown-toggle .caret{margin-top:8px}.nav .active .dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.nav-t
abs .active .dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.nav>.dropdown.active>a:hover{cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;line-height:0;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-
border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0
4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.nav>.disabled>a{color:#999}.nav>.disabled>a:hover{text-decoration:none;cursor:default;background-color:transparent}.navbar{*position:relative;*z-index:2;margin-bottom:20px;overflow:visible;color:#555}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#fafafa;background-image:-moz-linear-gradient(top,#fff,#f2f2f2);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f2f2f2));background-image:-webkit-linear-gradient(top,#fff,#f2f2f2);background-image:-o-linear-gradient(top,#fff,#f2f2f2);background-image:linear-gradient(to bottom,#fff,#f2f2f2);background-repeat:repeat-x;border:1px solid #d4d4d4;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:d
ximagetransform.microsoft.gradient(startColorstr='#ffffffff',endColorstr='#fff2f2f2',GradientType=0);-webkit-box-shadow:0 1px 4px rgba(0,0,0,0.065);-moz-box-shadow:0 1px 4px rgba(0,0,0,0.065);box-shadow:0 1px 4px rgba(0,0,0,0.065)}.navbar .container{width:auto}.nav-collapse.collapse{height:auto}.navbar .brand{display:block;float:left;padding:10px 20px 10px;margin-left:-20px;font-size:20px;font-weight:200;color:#555;text-shadow:0 1px 0 #fff}.navbar .brand:hover{text-decoration:none}.navbar-text{margin-bottom:0;line-height:40px}.navbar-link{color:#555}.navbar-link:hover{color:#333}.navbar .divider-vertical{height:40px;margin:0 9px;border-right:1px solid #fff;border-left:1px solid #f2f2f2}.navbar .btn,.navbar .btn-group{margin-top:6px}.navbar .btn-group .btn{margin:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;line-height:0;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .chec
kbox{margin-top:5px}.navbar-form input,.navbar-form select,.navbar-form .btn{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:6px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:5px;margin-bottom:0}.navbar-search .search-query{padding:4px 14px;margin-bottom:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.navbar-static-top{position:static;width:100%;margin-bottom:0}.navbar-static-top .navbar-inner{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,
.navbar-fixed-bottom .navbar-inner,.navbar-static-top .navbar-inner{border:0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.1),0 1px 10px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.1),0 1px 10px rgba(0,0,0,0.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.1),0 1px 10px rgba(0,0,0,0.1)}.navbar-fixed-bottom{bottom:0}.navbar-fixed-bottom .navbar-inner{-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,0.1),0 -1px 10px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 0 rgba(0,0,0,0.1),0 -1px 10px rgba(0,0,0,0.1);box-shadow:inset 0 1px 0 rgba(0,0,0,0.1),0 -1px 10px rgba(0,0,0,0.1)}.navbar .nav{position:relative;left:0;display:block;float:left;m
argin:0 10px 0 0}.navbar .nav.pull-right{float:right}.navbar .nav>li{float:left}.navbar .nav>li>a{float:none;padding:10px 15px 10px;color:#555;text-decoration:none;text-shadow:0 1px 0 #fff}.navbar .nav .dropdown-toggle .caret{margin-top:8px}.navbar .nav>li>a:focus,.navbar .nav>li>a:hover{color:#333;text-decoration:none;background-color:transparent}.navbar .nav>.active>a,.navbar .nav>.active>a:hover,.navbar .nav>.active>a:focus{color:#555;text-decoration:none;background-color:#e5e5e5;-webkit-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);-moz-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);box-shadow:inset 0 3px 8px rgba(0,0,0,0.125)}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#ededed;*background-color:#e5e5e5;background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#e5e5e5));background-image:-webkit-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-o-linea
r-gradient(top,#f2f2f2,#e5e5e5);background-image:linear-gradient(to bottom,#f2f2f2,#e5e5e5);background-image:-moz-linear-gradient(top,#f2f2f2,#e5e5e5);background-repeat:repeat-x;border-color:#e5e5e5 #e5e5e5 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fff2f2f2',endColorstr='#ffe5e5e5',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{color:#fff;background-color:#e5e5e5;*background-color:#d9d9d9}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#ccc \9}.navbar .
btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .nav>li>.dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .nav>li>.dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .nav>li>.dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .nav>li>.dropdown-menu:after{top:auto;bottom:-6px;border-top:6px sol
id #fff;border-bottom:0}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{color:#555;background-color:#e5e5e5}.navbar .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.navbar .nav li.dropdown.open>.dropdown-toggle .caret,.navbar .nav li.dropdown.active>.dropdown-toggle .caret,.navbar .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.navbar .pull-right>li>.dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right>li>.dropdown-menu:before,.navbar .nav>li>.dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right>li>.dropdown-menu:after,.navbar .nav>li>.dropdown-menu.pull-right:after{right:13px;left:auto}.navbar .pull-right>li>.dropdown-menu .dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right .dropdown-menu{right:100%;left:auto;margin-right:-1p
x;margin-left:0;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.navbar-inverse{color:#999}.navbar-inverse .navbar-inner{background-color:#1b1b1b;background-image:-moz-linear-gradient(top,#222,#111);background-image:-webkit-gradient(linear,0 0,0 100%,from(#222),to(#111));background-image:-webkit-linear-gradient(top,#222,#111);background-image:-o-linear-gradient(top,#222,#111);background-image:linear-gradient(to bottom,#222,#111);background-repeat:repeat-x;border-color:#252525;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff222222',endColorstr='#ff111111',GradientType=0)}.navbar-inverse .brand,.navbar-inverse .nav>li>a{color:#999;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar-inverse .brand:hover,.navbar-inverse .nav>li>a:hover{color:#fff}.navbar-inverse .nav>li>a:focus,.navbar-inverse .nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .nav .active>a,.navbar-inverse .nav .active>a:hover,.navbar-i
nverse .nav .active>a:focus{color:#fff;background-color:#111}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.navbar-inverse .divider-vertical{border-right-color:#222;border-left-color:#111}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle{color:#fff;background-color:#111}.navbar-inverse .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#999;border-bottom-color:#999}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .navbar-search .search-query{color:#fff;background-color:#515151;border-color:#111;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgb
a(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.navbar-inverse .navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:-ms-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:focus,.navbar-inverse .navbar-search .search-query.focused{padding:5px 15px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-inverse .btn-navbar{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e0e0e;*background-color:#040404;background-image:-webkit-gradient(linear,0 0,0 100%,from(#151515),to(#040404));background-image:-webkit-linear-gradien
t(top,#151515,#040404);background-image:-o-linear-gradient(top,#151515,#040404);background-image:linear-gradient(to bottom,#151515,#040404);background-image:-moz-linear-gradient(top,#151515,#040404);background-repeat:repeat-x;border-color:#040404 #040404 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff151515',endColorstr='#ff040404',GradientType=0);filter:progid:dximagetransform.microsoft.gradient(enabled=false)}.navbar-inverse .btn-navbar:hover,.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active,.navbar-inverse .btn-navbar.disabled,.navbar-inverse .btn-navbar[disabled]{color:#fff;background-color:#040404;*background-color:#000}.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active{background-color:#000 \9}.breadcrumb{padding:8px 15px;margin:0 0 20px;list-style:none;background-color:#f5f5f5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.breadcr
umb li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb .divider{padding:0 5px;color:#ccc}.breadcrumb .active{color:#999}.pagination{height:40px;margin:20px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination li{display:inline}.pagination a,.pagination span{float:left;padding:0 14px;line-height:38px;text-decoration:none;background-color:#fff;border:1px solid #ddd;border-left-width:0}.pagination a:hover,.pagination .active a,.pagination .active span{background-color:#f5f5f5}.pagination .active a,.pagination .active span{color:#999;cursor:default}.pagination .disabled span,.pagination .disabled a,.pagination .disabled a:hover{color:#999;cursor:default;background-color:transparent}.pagination li:first-child a,.p
agination li:first-child span{border-left-width:1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.pagination li:last-child a,.pagination li:last-child span{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pager{margin:20px 0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;line-height:0;content:""}.pager:after{clear:both}.pager li{display:inline}.pager a{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager a:hover{text-decoration:none;background-color:#f5f5f5}.pager .next a{float:right}.pager .previous a{float:left}.pager .disabled a,.pager .disabled a:hover{color:#999;cursor:default;background-color:#fff}.modal-open .dropdown-menu{z-index:2050}.modal-open .dropdown.open{*z-index:2050}
.modal-open .popover{z-index:2060}.modal-open .tooltip{z-index:2080}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:50%;left:50%;z-index:1050;width:560px;margin:-250px 0 0 -280px;overflow:auto;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fad
e.in{top:50%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-header h3{margin:0;line-height:30px}.modal-body{max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;line-height:0;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.tooltip{position:absolute;z-index:1030;display:block;padding:5px;font-size:11px;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{margin-top:-3px}.toolt
ip.right{margin-left:3px}.tooltip.bottom{margin-top:3px}.tooltip.left{margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;width:236px;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius
:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.popover.top{margin-bottom:10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-right:10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover-content p,.popover-content ul,.popover-content ol{margin-bottom:0}.popover .arrow,.popover .arrow:after{position:absolute;display:inline-block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow:after{z-index:-1;content:""}.popover.top .arrow{bottom:-10px;left:50%;margin-left:-10px;border-top-c
olor:#fff;border-width:10px 10px 0}.popover.top .arrow:after{bottom:-1px;left:-11px;border-top-color:rgba(0,0,0,0.25);border-width:11px 11px 0}.popover.right .arrow{top:50%;left:-10px;margin-top:-10px;border-right-color:#fff;border-width:10px 10px 10px 0}.popover.right .arrow:after{bottom:-11px;left:-1px;border-right-color:rgba(0,0,0,0.25);border-width:11px 11px 11px 0}.popover.bottom .arrow{top:-10px;left:50%;margin-left:-10px;border-bottom-color:#fff;border-width:0 10px 10px}.popover.bottom .arrow:after{top:-1px;left:-11px;border-bottom-color:rgba(0,0,0,0.25);border-width:0 11px 11px}.popover.left .arrow{top:50%;right:-10px;margin-top:-10px;border-left-color:#fff;border-width:10px 0 10px 10px}.popover.left .arrow:after{right:-1px;bottom:-11px;border-left-color:rgba(0,0,0,0.25);border-width:11px 0 11px 11px}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;line-height:0;content:""}.thumbnails:after{clear:both}.row-fluid .thumbn
ails{margin-left:0}.thumbnails>li{float:left;margin-bottom:20px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:20px;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.055);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.055);box-shadow:0 1px 3px rgba(0,0,0,0.055);-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}a.thumbnail:hover{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px;color:#555}.label,.badge{font-size:11.844px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{padding:1px 4px 2p
x;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding:1px 9px 2px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}a.label:hover,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}.btn .label,.btn .badge{position:relative;top:-1px}.btn-mini .label,.btn-mini .badge{top:0}@-webkit-keyframes progress-bar-stripes{from{background-position:
40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(to bottom,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='
#fff9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{float:left;width:0;height:100%;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(to bottom,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff149bdf',endColorstr='#ff0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:borde
r-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress .bar+.bar{-webkit-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15)}.progress-striped .bar{background-color:#149bdf;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%
,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar,.progress .bar-danger{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);backgrou
nd-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(to bottom,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffc43c35',GradientType=0)}.progress-danger.progress-striped .bar,.progress-striped .bar-danger{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,
rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar,.progress .bar-success{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(to bottom,#62c462,#57a957);background-repeat:repeat-x;filter:progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462'
,endColorstr='#ff57a957',GradientType=0)}.progress-success.progress-striped .bar,.progress-striped .bar-success{ba
<TRUNCATED>
[14/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/site/resources/js/bootstrap.min.js
----------------------------------------------------------------------
diff --git a/src/site/resources/js/bootstrap.min.js b/src/site/resources/js/bootstrap.min.js
deleted file mode 100644
index 66e887b..0000000
--- a/src/site/resources/js/bootstrap.min.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/*!
-* Bootstrap.js by @fat & @mdo
-* Copyright 2012 Twitter, Inc.
-* http://www.apache.org/licenses/LICENSE-2.0.txt
-*/
-!function(e){e(function(){"use strict";e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),type
of t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(function(){e("body").on("click.alert.data-api",t,n.prototype.close)})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.parent('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(function(){e("body")
.on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.su
pport.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f=e.Event("slide",{relatedTarget:i[0]});this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u]();if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.ad
dClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(function(){e("body").on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=!i.data("modal")&&e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=th
is.$element.hasClass("width");return e?"width":"height"},show:function(){var t,n,r,i;if(this.transitioning)return;t=this.dimension(),n=e.camelCase(["scroll",t].join("-")),r=this.$parent&&this.$parent.find("> .accordion-group > .in");if(r&&r.length){i=r.data("collapse");if(i&&i.transitioning)return;r.collapse("hide"),i||r.data("collapse",null)}this.$element[t](0),this.transition("addClass",e.Event("show"),"shown"),e.support.transition&&this.$element[t](this.$element[0][n])},hide:function(){var t;if(this.transitioning)return;t=this.dimension(),this.reset(this.$element[t]()),this.transition("removeClass",e.Event("hide"),"hidden"),this.$element[t](0)},reset:function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this},transition:function(t,n,r){var i=this,s=function(){n.type=="show"&&i.reset(),i.transitioning=0,i.$element.trigger(r)};this.$element.trigger(n);if(n.isDefaultPr
evented())return;this.transitioning=1,this.$element[t]("in"),e.support.transition&&this.$element.hasClass("collapse")?this.$element.one(e.support.transition.end,s):s()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},e.fn.collapse=function(n){return this.each(function(){var r=e(this),i=r.data("collapse"),s=typeof n=="object"&&n;i||r.data("collapse",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.collapse.defaults={toggle:!0},e.fn.collapse.Constructor=t,e(function(){e("body").on("click.collapse.data-api","[data-toggle=collapse]",function(t){var n=e(this),r,i=n.attr("data-target")||t.preventDefault()||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,""),s=e(i).data("collapse")?"toggle":n.data();n[e(i).hasClass("in")?"addClass":"removeClass"]("collapsed"),e(i).collapse(s)})})}(window.jQuery),!function(e){"use strict";function r(){i(e(t)).removeClass("open")}function i(t){var n=t.attr("data-target"),r;return n||(n=t.attr("href"),n=n&&n.replace(/.*(?=#[^\s]*$)/,"
")),r=e(n),r.length||(r=t.parent()),r}var t="[data-toggle=dropdown]",n=function(t){var n=e(t).on("click.dropdown.data-api",this.toggle);e("html").on("click.dropdown.data-api",function(){n.parent().removeClass("open")})};n.prototype={constructor:n,toggle:function(t){var n=e(this),s,o;if(n.is(".disabled, :disabled"))return;return s=i(n),o=s.hasClass("open"),r(),o||(s.toggleClass("open"),n.focus()),!1},keydown:function(t){var n,r,s,o,u,a;if(!/(38|40|27)/.test(t.keyCode))return;n=e(this),t.preventDefault(),t.stopPropagation();if(n.is(".disabled, :disabled"))return;o=i(n),u=o.hasClass("open");if(!u||u&&t.keyCode==27)return n.click();r=e("[role=menu] li:not(.divider) a",o);if(!r.length)return;a=r.index(r.filter(":focus")),t.keyCode==38&&a>0&&a--,t.keyCode==40&&a<r.length-1&&a++,~a||(a=0),r.eq(a).focus()}},e.fn.dropdown=function(t){return this.each(function(){var r=e(this),i=r.data("dropdown");i||r.data("dropdown",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.dropdown.Constructor
=n,e(function(){e("html").on("click.dropdown.data-api touchstart.dropdown.data-api",r),e("body").on("click.dropdown touchstart.dropdown.data-api",".dropdown",function(e){e.stopPropagation()}).on("click.dropdown.data-api touchstart.dropdown.data-api",t,n.prototype.toggle).on("keydown.dropdown.data-api touchstart.dropdown.data-api",t+", [role=menu]",n.prototype.keydown)})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.options=n,this.$element=e(t).delegate('[data-dismiss="modal"]',"click.dismiss.modal",e.proxy(this.hide,this)),this.options.remote&&this.$element.find(".modal-body").load(this.options.remote)};t.prototype={constructor:t,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var t=this,n=e.Event("show");this.$element.trigger(n);if(this.isShown||n.isDefaultPrevented())return;e("body").addClass("modal-open"),this.isShown=!0,this.escape(),this.backdrop(function(){var n=e.support.transition&&t.$element.hasClass("fade");t.$element.paren
t().length||t.$element.appendTo(document.body),t.$element.show(),n&&t.$element[0].offsetWidth,t.$element.addClass("in").attr("aria-hidden",!1).focus(),t.enforceFocus(),n?t.$element.one(e.support.transition.end,function(){t.$element.trigger("shown")}):t.$element.trigger("shown")})},hide:function(t){t&&t.preventDefault();var n=this;t=e.Event("hide"),this.$element.trigger(t);if(!this.isShown||t.isDefaultPrevented())return;this.isShown=!1,e("body").removeClass("modal-open"),this.escape(),e(document).off("focusin.modal"),this.$element.removeClass("in").attr("aria-hidden",!0),e.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal()},enforceFocus:function(){var t=this;e(document).on("focusin.modal",function(e){t.$element[0]!==e.target&&!t.$element.has(e.target).length&&t.$element.focus()})},escape:function(){var e=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(t){t.which==27&&e.hide()}):this.isShown||this.$ele
ment.off("keyup.dismiss.modal")},hideWithTransition:function(){var t=this,n=setTimeout(function(){t.$element.off(e.support.transition.end),t.hideModal()},500);this.$element.one(e.support.transition.end,function(){clearTimeout(n),t.hideModal()})},hideModal:function(e){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(t){var n=this,r=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var i=e.support.transition&&r;this.$backdrop=e('<div class="modal-backdrop '+r+'" />').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.rem
oveBackdrop,this)):this.removeBackdrop()):t&&t()}},e.fn.modal=function(n){return this.each(function(){var r=e(this),i=r.data("modal"),s=e.extend({},e.fn.modal.defaults,r.data(),typeof n=="object"&&n);i||r.data("modal",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},e.fn.modal.Constructor=t,e(function(){e("body").on("click.modal.data-api",'[data-toggle="modal"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("modal")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data());t.preventDefault(),i.modal(s).one("hide",function(){n.focus()})})})}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("tooltip",e,t)};t.prototype={constructor:t,init:function(t,n,r){var i,s;this.type=t,this.$element=e(n),this.options=this.getOptions(r),this.enabled=!0,this.options.trigger=="click"?this.$element.on("click."+this.type,this.options.selector,
e.proxy(this.toggle,this)):this.options.trigger!="manual"&&(i=this.options.trigger=="hover"?"mouseenter":"focus",s=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(i+"."+this.type,this.options.selector,e.proxy(this.enter,this)),this.$element.on(s+"."+this.type,this.options.selector,e.proxy(this.leave,this))),this.options.selector?this._options=e.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(t){return t=e.extend({},e.fn[this.type].defaults,t,this.$element.data()),t.delay&&typeof t.delay=="number"&&(t.delay={show:t.delay,hide:t.delay}),t},enter:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);if(!n.options.delay||!n.options.delay.show)return n.show();clearTimeout(this.timeout),n.hoverState="in",this.timeout=setTimeout(function(){n.hoverState=="in"&&n.show()},n.options.delay.show)},leave:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(t
his.timeout);if(!n.options.delay||!n.options.delay.hide)return n.hide();n.hoverState="out",this.timeout=setTimeout(function(){n.hoverState=="out"&&n.hide()},n.options.delay.hide)},show:function(){var e,t,n,r,i,s,o;if(this.hasContent()&&this.enabled){e=this.tip(),this.setContent(),this.options.animation&&e.addClass("fade"),s=typeof this.options.placement=="function"?this.options.placement.call(this,e[0],this.$element[0]):this.options.placement,t=/in/.test(s),e.remove().css({top:0,left:0,display:"block"}).appendTo(t?this.$element:document.body),n=this.getPosition(t),r=e[0].offsetWidth,i=e[0].offsetHeight;switch(t?s.split(" ")[1]:s){case"bottom":o={top:n.top+n.height,left:n.left+n.width/2-r/2};break;case"top":o={top:n.top-i,left:n.left+n.width/2-r/2};break;case"left":o={top:n.top+n.height/2-i/2,left:n.left-r};break;case"right":o={top:n.top+n.height/2-i/2,left:n.left+n.width}}e.css(o).addClass(s).addClass("in")}},setContent:function(){var e=this.tip(),t=this.getTitle();e.find(".tooltip-
inner")[this.options.html?"html":"text"](t),e.removeClass("fade in top bottom left right")},hide:function(){function r(){var t=setTimeout(function(){n.off(e.support.transition.end).remove()},500);n.one(e.support.transition.end,function(){clearTimeout(t),n.remove()})}var t=this,n=this.tip();return n.removeClass("in"),e.support.transition&&this.$tip.hasClass("fade")?r():n.remove(),this},fixTitle:function(){var e=this.$element;(e.attr("title")||typeof e.attr("data-original-title")!="string")&&e.attr("data-original-title",e.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(t){return e.extend({},t?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-original-title")||(typeof n.title=="function"?n.title.call(t[0]):n.title),e},tip:function(){return this.$tip=this.$tip||e(this.options.template)},v
alidate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}},e.fn.tooltip=function(n){return this.each(function(){var r=e(this),i=r.data("tooltip"),s=typeof n=="object"&&n;i||r.data("tooltip",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.tooltip.Constructor=t,e.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0,html:!0}}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("popover",e,t)};t.prototype=e.extend({},e.fn.tooltip.Constructor.prototype,{constructor:t,setContent:function(){var e=this.tip(),t=this
.getTitle(),n=this.getContent();e.find(".popover-title")[this.options.html?"html":"text"](t),e.find(".popover-content > *")[this.options.html?"html":"text"](n),e.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-content")||(typeof n.content=="function"?n.content.call(t[0]):n.content),e},tip:function(){return this.$tip||(this.$tip=e(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}}),e.fn.popover=function(n){return this.each(function(){var r=e(this),i=r.data("popover"),s=typeof n=="object"&&n;i||r.data("popover",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.popover.Constructor=t,e.fn.popover.defaults=e.extend({},e.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="p
opover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(e){"use strict";function t(t,n){var r=e.proxy(this.process,this),i=e(t).is("body")?e(window):e(t),s;this.options=e.extend({},e.fn.scrollspy.defaults,n),this.$scrollElement=i.on("scroll.scroll-spy.data-api",r),this.selector=(this.options.target||(s=e(t).attr("href"))&&s.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=e("body"),this.refresh(),this.process()}t.prototype={constructor:t,refresh:function(){var t=this,n;this.offsets=e([]),this.targets=e([]),n=this.$body.find(this.selector).map(function(){var t=e(this),n=t.data("target")||t.attr("href"),r=/^#\w/.test(n)&&e(n);return r&&r.length&&[[r.position().top,n]]||null}).sort(function(e,t){return e[0]-t[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},process:function(){var e=this.$scrollElement.scrollTop()+this.options.offset,t=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,n=t-this
.$scrollElement.height(),r=this.offsets,i=this.targets,s=this.activeTarget,o;if(e>=n)return s!=(o=i.last()[0])&&this.activate(o);for(o=r.length;o--;)s!=i[o]&&e>=r[o]&&(!r[o+1]||e<=r[o+1])&&this.activate(i[o])},activate:function(t){var n,r;this.activeTarget=t,e(this.selector).parent(".active").removeClass("active"),r=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',n=e(r).parent("li").addClass("active"),n.parent(".dropdown-menu").length&&(n=n.closest("li.dropdown").addClass("active")),n.trigger("activate")}},e.fn.scrollspy=function(n){return this.each(function(){var r=e(this),i=r.data("scrollspy"),s=typeof n=="object"&&n;i||r.data("scrollspy",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.scrollspy.Constructor=t,e.fn.scrollspy.defaults={offset:10},e(window).on("load",function(){e('[data-spy="scroll"]').each(function(){var t=e(this);t.scrollspy(t.data())})})}(window.jQuery),!function(e){"use strict";var t=function(t){this.element=e(t)};t.prototype={constructo
r:t,show:function(){var t=this.element,n=t.closest("ul:not(.dropdown-menu)"),r=t.attr("data-target"),i,s,o;r||(r=t.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,""));if(t.parent("li").hasClass("active"))return;i=n.find(".active a").last()[0],o=e.Event("show",{relatedTarget:i}),t.trigger(o);if(o.isDefaultPrevented())return;s=e(r),this.activate(t.parent("li"),n),this.activate(s,s.parent(),function(){t.trigger({type:"shown",relatedTarget:i})})},activate:function(t,n,r){function o(){i.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),t.addClass("active"),s?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu")&&t.closest("li.dropdown").addClass("active"),r&&r()}var i=n.find("> .active"),s=r&&e.support.transition&&i.hasClass("fade");s?i.one(e.support.transition.end,o):o(),i.removeClass("in")}},e.fn.tab=function(n){return this.each(function(){var r=e(this),i=r.data("tab");i||r.data("tab",i=new t(this)),typeof n=="string"&&i[n]()})}
,e.fn.tab.Constructor=t,e(function(){e("body").on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(t){t.preventDefault(),e(this).tab("show")})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.typeahead.defaults,n),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.$menu=e(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};t.prototype={constructor:t,select:function(){var e=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(e)).change(),this.hide()},updater:function(e){return e},show:function(){var t=e.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:t.top+t.height,left:t.left}),this.$menu.show(),this.shown=!0,this},h
ide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(t){var n;return this.query=this.$element.val(),!this.query||this.query.length<this.options.minLength?this.shown?this.hide():this:(n=e.isFunction(this.source)?this.source(this.query,e.proxy(this.process,this)):this.source,n?this.process(n):this)},process:function(t){var n=this;return t=e.grep(t,function(e){return n.matcher(e)}),t=this.sorter(t),t.length?this.render(t.slice(0,this.options.items)).show():this.shown?this.hide():this},matcher:function(e){return~e.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(e){var t=[],n=[],r=[],i;while(i=e.shift())i.toLowerCase().indexOf(this.query.toLowerCase())?~i.indexOf(this.query)?n.push(i):r.push(i):t.push(i);return t.concat(n,r)},highlighter:function(e){var t=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return e.replace(new RegExp("("+t+")","ig"),function(e,t){return"<strong>"+t+"</strong>"})},render:function(t){var n=this;return t=e(t).map
(function(t,r){return t=e(n.options.item).attr("data-value",r),t.find("a").html(n.highlighter(r)),t[0]}),t.first().addClass("active"),this.$menu.html(t),this},next:function(t){var n=this.$menu.find(".active").removeClass("active"),r=n.next();r.length||(r=e(this.$menu.find("li")[0])),r.addClass("active")},prev:function(e){var t=this.$menu.find(".active").removeClass("active"),n=t.prev();n.length||(n=this.$menu.find("li").last()),n.addClass("active")},listen:function(){this.$element.on("blur",e.proxy(this.blur,this)).on("keypress",e.proxy(this.keypress,this)).on("keyup",e.proxy(this.keyup,this)),(e.browser.webkit||e.browser.msie)&&this.$element.on("keydown",e.proxy(this.keydown,this)),this.$menu.on("click",e.proxy(this.click,this)).on("mouseenter","li",e.proxy(this.mouseenter,this))},move:function(e){if(!this.shown)return;switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),this.prev();break;case 40:e.preventDefault(),this.next()}e.stopPropagati
on()},keydown:function(t){this.suppressKeyPressRepeat=!~e.inArray(t.keyCode,[40,38,9,13,27]),this.move(t)},keypress:function(e){if(this.suppressKeyPressRepeat)return;this.move(e)},keyup:function(e){switch(e.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}e.stopPropagation(),e.preventDefault()},blur:function(e){var t=this;setTimeout(function(){t.hide()},150)},click:function(e){e.stopPropagation(),e.preventDefault(),this.select()},mouseenter:function(t){this.$menu.find(".active").removeClass("active"),e(t.currentTarget).addClass("active")}},e.fn.typeahead=function(n){return this.each(function(){var r=e(this),i=r.data("typeahead"),s=typeof n=="object"&&n;i||r.data("typeahead",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>',minLength:1},e.fn.typeahead.Const
ructor=t,e(function(){e("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(t){var n=e(this);if(n.data("typeahead"))return;t.preventDefault(),n.typeahead(n.data())})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.options=e.extend({},e.fn.affix.defaults,n),this.$window=e(window).on("scroll.affix.data-api",e.proxy(this.checkPosition,this)),this.$element=e(t),this.checkPosition()};t.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var t=e(document).height(),n=this.$window.scrollTop(),r=this.$element.offset(),i=this.options.offset,s=i.bottom,o=i.top,u="affix affix-top affix-bottom",a;typeof i!="object"&&(s=o=i),typeof o=="function"&&(o=i.top()),typeof s=="function"&&(s=i.bottom()),a=this.unpin!=null&&n+this.unpin<=r.top?!1:s!=null&&r.top+this.$element.height()>=t-s?"bottom":o!=null&&n<=o?"top":!1;if(this.affixed===a)return;this.affixed=a,this.unpin=a=="bottom"?r.top-n:null,this.$element.removeClass(u).addClass("affi
x"+(a?"-"+a:""))},e.fn.affix=function(n){return this.each(function(){var r=e(this),i=r.data("affix"),s=typeof n=="object"&&n;i||r.data("affix",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.affix.Constructor=t,e.fn.affix.defaults={offset:0},e(window).on("load",function(){e('[data-spy="affix"]').each(function(){var t=e(this),n=t.data();n.offset=n.offset||{},n.offsetBottom&&(n.offset.bottom=n.offsetBottom),n.offsetTop&&(n.offset.top=n.offsetTop),t.affix(n)})})}(window.jQuery);
\ No newline at end of file
[03/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/AppenderPoolTest.php
----------------------------------------------------------------------
diff --git a/tests/src/AppenderPoolTest.php b/tests/src/AppenderPoolTest.php
new file mode 100644
index 0000000..86ba9d9
--- /dev/null
+++ b/tests/src/AppenderPoolTest.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\AppenderPool;
+
+use Mockery as m;
+
+/**
+ * @group filters
+ */
+class AppenderPoolTest extends \PHPUnit_Framework_TestCase {
+
+ public function setUp() {
+ AppenderPool::clear();
+ }
+
+ public function tearDown() {
+ AppenderPool::clear();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Cannot add unnamed appender to pool.
+ */
+ public function testAppenderHasNoName() {
+
+ $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
+ ->shouldReceive('getName')->andReturn('')
+ ->shouldReceive('close')
+ ->mock();
+
+ AppenderPool::add($mockAppender);
+ }
+
+ public function testAppenderIsAdded() {
+
+ $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
+ ->shouldReceive('getName')->andReturn('foo')
+ ->shouldReceive('close')
+ ->mock();
+
+ AppenderPool::add($mockAppender);
+
+ $expected = 1;
+ $actual = count(AppenderPool::getAppenders());
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage log4php: Appender [foo] already exists in pool. Overwriting existing appender.
+ */
+ public function testDuplicateAppenderName() {
+
+ $mockAppender = m::mock('Apache\\Log4php\\Appenders\\ConsoleAppender')
+ ->shouldReceive('getName')->andReturn('foo')
+ ->shouldReceive('close')
+ ->mock();
+
+ AppenderPool::add($mockAppender);
+ AppenderPool::add($mockAppender);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/AppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/AppenderTest.php b/tests/src/AppenderTest.php
new file mode 100644
index 0000000..d1fe009
--- /dev/null
+++ b/tests/src/AppenderTest.php
@@ -0,0 +1,181 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests;
+
+use Apache\Log4php\Appenders\EchoAppender;
+use Apache\Log4php\Appenders\NullAppender;
+use Apache\Log4php\Filters\DenyAllFilter;
+use Apache\Log4php\Filters\LevelMatchFilter;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group appenders
+ */
+class AppenderTest extends \PHPUnit_Framework_TestCase {
+
+ public function testThreshold() {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+
+ $warn = Level::getLevelWarn();
+ $appender->setThreshold($warn);
+ $appender->activateOptions();
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelFatal(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "FATAL - testmessage" . PHP_EOL;
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "ERROR - testmessage" . PHP_EOL;
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelWarn(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "WARN - testmessage" . PHP_EOL;
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelInfo(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "";
+ self::assertEquals($e, $v);
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelDebug(), "testmessage");
+ ob_start();
+ $appender->doAppend($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+ $e = "";
+ self::assertEquals($e, $v);
+ }
+
+ public function testGetThreshold() {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+
+ $warn = Level::getLevelWarn();
+ $appender->setThreshold($warn);
+
+ $a = $appender->getThreshold();
+ self::assertEquals($warn, $a);
+ }
+
+ public function testSetStringThreshold() {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+
+ $warn = Level::getLevelWarn();
+ $appender->setThreshold('WARN');
+ $a = $appender->getThreshold();
+ self::assertEquals($warn, $a);
+
+ $e = Level::getLevelFatal();
+ $appender->setThreshold('FATAL');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+
+ $e = Level::getLevelError();
+ $appender->setThreshold('ERROR');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+
+ $e = Level::getLevelDebug();
+ $appender->setThreshold('DEBUG');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+
+ $e = Level::getLevelInfo();
+ $appender->setThreshold('INFO');
+ $a = $appender->getThreshold();
+ self::assertEquals($e, $a);
+ }
+
+ public function testSetFilter() {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+
+ $filter = new DenyAllFilter();
+ $appender->addFilter($filter);
+
+ $filter2 = new LevelMatchFilter();
+ $appender->addFilter($filter2);
+
+ $first = $appender->getFilter();
+ self::assertEquals($first, $filter);
+
+ $next = $first->getNext();
+ self::assertEquals($next, $filter2);
+
+ $appender->clearFilters();
+ $nullfilter = $appender->getFilter();
+ self::assertNull($nullfilter);
+ }
+
+ public function testInstanciateWithLayout() {
+ $appender = new EchoAppender("LoggerAppenderTest");
+
+ $expected = "Apache\\Log4php\\Layouts\\SimpleLayout";
+ $actual = $appender->getLayout();
+ $this->assertInstanceof($expected, $actual);
+ }
+
+ public function testOverwriteLayout() {
+ $layout = new SimpleLayout();
+ $appender = new EchoAppender("LoggerAppenderTest");
+ $appender->setLayout($layout);
+
+ $actual = $appender->getLayout();
+ $this->assertEquals($layout, $actual);
+ }
+
+ public function testRequiresNoLayout() {
+ $appender = new NullAppender("LoggerAppenderTest");
+
+ $actual = $appender->getLayout();
+ $this->assertNull($actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/ConsoleAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/ConsoleAppenderTest.php b/tests/src/Appenders/ConsoleAppenderTest.php
new file mode 100644
index 0000000..a99a407
--- /dev/null
+++ b/tests/src/Appenders/ConsoleAppenderTest.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Logger;
+use Apache\Log4php\Appenders\ConsoleAppender;
+
+/**
+ * @group appenders
+ */
+class ConsoleAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ private $config = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'ConsoleAppender',
+ 'layout' => array(
+ 'class' => 'PatternLayout',
+ 'params' => array(
+ // Intentionally blank so output doesn't clutter phpunit output
+ 'conversionPattern' => ''
+ )
+ ),
+ )
+ )
+ );
+
+ public function testRequiresLayout() {
+ $appender = new ConsoleAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testAppendDefault() {
+ Logger::configure($this->config);
+ $log = Logger::getRootLogger();
+
+ $expected = ConsoleAppender::STDOUT;
+ $actual = $log->getAppender('default')->getTarget();
+ $this->assertSame($expected, $actual);
+
+ $log->info("hello");
+ }
+
+ public function testAppendStdout() {
+ $this->config['appenders']['default']['params']['target'] = 'stdout';
+
+ Logger::configure($this->config);
+ $log = Logger::getRootLogger();
+
+ $expected = ConsoleAppender::STDOUT;
+ $actual = $log->getAppender('default')->getTarget();
+ $this->assertSame($expected, $actual);
+
+ $log->info("hello");
+ }
+
+ public function testAppendStderr() {
+ $this->config['appenders']['default']['params']['target'] = 'stderr';
+ Logger::configure($this->config);
+ $log = Logger::getRootLogger();
+ $expected = ConsoleAppender::STDERR;
+
+ $actual = $log->getAppender('default')->getTarget();
+ $this->assertSame($expected, $actual);
+
+ $log->info("hello");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/DailyFileAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/DailyFileAppenderTest.php b/tests/src/Appenders/DailyFileAppenderTest.php
new file mode 100644
index 0000000..e5f3acf
--- /dev/null
+++ b/tests/src/Appenders/DailyFileAppenderTest.php
@@ -0,0 +1,194 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\DailyFileAppender;
+use Apache\Log4php\Level;
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Tests\TestHelper;
+
+/**
+ * @group appenders
+ */
+class DailyFileAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ protected function setUp() {
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Ymd'));
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Y'));
+ }
+
+ public function testRequiresLayout() {
+ $appender = new DailyFileAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testDefaultLayout() {
+ $appender = new DailyFileAppender();
+ $actual = $appender->getLayout();
+ self::assertInstanceOf('Apache\\Log4php\\Layouts\\SimpleLayout', $actual);
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'file' not set.
+ */
+ public function testRequiredParamWarning1() {
+ $appender = new DailyFileAppender();
+ $appender->activateOptions();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'datePattern' not set.
+ */
+ public function testRequiredParamWarning2() {
+ $appender = new DailyFileAppender();
+ $appender->setFile('file.log');
+ $appender->setDatePattern('');
+ $appender->activateOptions();
+ }
+
+ public function testGetDatePattern() {
+ $appender = new DailyFileAppender();
+
+ // Default pattern
+ $actual = $appender->getDatePattern();
+ self::assertEquals('Ymd', $actual);
+
+ // Custom pattern
+ $appender->setDatePattern('xyz');
+ $actual = $appender->getDatePattern();
+ self::assertEquals('xyz', $actual);
+ }
+
+ /**
+ * For greater code coverage!
+ * Override the warning so remaining code is reached.
+ */
+ public function testRequiredParamWarning3() {
+ $appender = new DailyFileAppender();
+ $appender->setFile('file.log');
+ $appender->setDatePattern('');
+ @$appender->activateOptions();
+ }
+
+ public function testLazyFileOpen() {
+ $event = TestHelper::getWarnEvent("my message");
+ $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
+ $pattern = 'Y-m-d';
+
+ $date = date($pattern, $event->getTimeStamp());
+ $path = PHPUNIT_TEMP_DIR . "/lazy-file.$date.log";
+
+ if (file_exists($path)) {
+ unlink($path);
+ }
+
+ $appender = new DailyFileAppender();
+ $appender->setFile($file);
+ $appender->setDatePattern('Y-m-d');
+ $appender->activateOptions();
+
+ // File should not exist before first append
+ self::assertFileNotExists($path);
+ $appender->append($event);
+ self::assertFileExists($path);
+ }
+
+ public function testRollover()
+ {
+ $message = uniqid();
+ $level = Level::getLevelDebug();
+
+ $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
+ $pattern = 'Y-m-d';
+
+ // Get some timestamps for events - different date for each
+ $ts1 = mktime(10, 0, 0, 7, 3, 1980);
+ $ts2 = mktime(10, 0, 0, 7, 4, 1980);
+ $ts3 = mktime(10, 0, 0, 7, 5, 1980);
+
+ $e1 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts1);
+ $e2 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts2);
+ $e3 = new LoggingEvent(__CLASS__, 'test', $level, $message, $ts3);
+
+ // Expected paths
+ $path1 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-03.log';
+ $path2 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-04.log';
+ $path3 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-05.log';
+
+ @unlink($path1);
+ @unlink($path2);
+ @unlink($path3);
+
+ $appender = new DailyFileAppender();
+ $appender->setFile($file);
+ $appender->setDatePattern('Y-m-d');
+ $appender->activateOptions();
+
+ $appender->append($e1);
+ $appender->append($e2);
+ $appender->append($e3);
+
+ $actual1 = file_get_contents($path1);
+ $actual2 = file_get_contents($path2);
+ $actual3 = file_get_contents($path3);
+
+ $expected1 = "DEBUG - $message" . PHP_EOL;
+ $expected2 = "DEBUG - $message" . PHP_EOL;
+ $expected3 = "DEBUG - $message" . PHP_EOL;
+
+ self::assertSame($expected1, $actual1);
+ self::assertSame($expected2, $actual2);
+ self::assertSame($expected3, $actual3);
+ }
+
+ public function testSimpleLogging() {
+ $event = TestHelper::getWarnEvent("my message");
+
+ $appender = new DailyFileAppender();
+ $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Ymd"));
+ $expected = "WARN - my message".PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testChangedDateFormat() {
+ $event = TestHelper::getWarnEvent("my message");
+
+ $appender = new DailyFileAppender();
+ $appender->setDatePattern('Y');
+ $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Y"));
+ $expected = "WARN - my message".PHP_EOL;
+ self::assertEquals($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/EchoAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/EchoAppenderTest.php b/tests/src/Appenders/EchoAppenderTest.php
new file mode 100644
index 0000000..57f2c12
--- /dev/null
+++ b/tests/src/Appenders/EchoAppenderTest.php
@@ -0,0 +1,170 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\EchoAppender;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group appenders
+ */
+class EchoAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ private $config1 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ )
+ )
+ );
+
+ private $config2 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array(
+ 'htmlLineBreaks' => true
+ )
+ )
+ )
+ );
+
+ private $config3 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'EchoAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array(
+ 'htmlLineBreaks' => 'foo'
+ )
+ )
+ )
+ );
+
+ public function testAppend() {
+ Logger::configure($this->config1);
+ $log = Logger::getRootLogger();
+
+ $hlb = $log->getAppender('default')->getHtmlLineBreaks();
+ $this->assertSame(false, $hlb);
+
+ ob_start();
+ $log->info("This is a test");
+ $log->debug("And this too");
+ $actual = ob_get_clean();
+ $expected = "INFO - This is a test" . PHP_EOL . "DEBUG - And this too". PHP_EOL;
+
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testHtmlLineBreaks() {
+ Logger::configure($this->config2);
+ $log = Logger::getRootLogger();
+
+ $hlb = $log->getAppender('default')->getHtmlLineBreaks();
+ $this->assertSame(true, $hlb);
+
+ ob_start();
+ $log->info("This is a test" . PHP_EOL . "With more than one line");
+ $log->debug("And this too");
+ $actual = ob_get_clean();
+ $expected = "INFO - This is a test<br />" . PHP_EOL . "With more than one line<br />" . PHP_EOL . "DEBUG - And this too<br />" . PHP_EOL;
+
+ $this->assertSame($expected, $actual);
+ }
+
+// public function testHtmlLineBreaksInvalidOption() {
+// Logger::configure($this->config3);
+// }
+
+
+ public function testEcho() {
+ $appender = new EchoAppender("myname ");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->activateOptions();
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $expected = "ERROR - testmessage" . PHP_EOL;
+ ob_start();
+ $appender->append($event);
+ $actual = ob_get_clean();
+
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testRequiresLayout() {
+ $appender = new EchoAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testEchoHtml() {
+ $appender = new EchoAppender("myname ");
+ $appender->setHtmlLineBreaks(true);
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->activateOptions();
+
+ // Single line message
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $expected = "ERROR - testmessage<br />" . PHP_EOL;
+ ob_start();
+ $appender->append($event);
+ $actual = ob_get_clean();
+ self::assertEquals($expected, $actual);
+
+ // Multi-line message
+ $msg = "This message\nis in several lines\r\nto test various line breaks.";
+ $expected = "ERROR - This message<br />\nis in several lines<br />\r\nto test various line breaks.<br />" . PHP_EOL;
+
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), $msg);
+ ob_start();
+ $appender->append($event);
+ $actual = ob_get_clean();
+ self::assertEquals($expected, $actual);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/FileAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/FileAppenderTest.php b/tests/src/Appenders/FileAppenderTest.php
new file mode 100644
index 0000000..e8ed539
--- /dev/null
+++ b/tests/src/Appenders/FileAppenderTest.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @package log4php
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\FileAppender;
+use Apache\Log4php\Logger;
+use Apache\Log4php\Tests\TestHelper;
+
+/**
+ * @group appenders
+ */
+class FileAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ private $config1 = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'FileAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ 'params' => array()
+ )
+ )
+ );
+
+ private $testPath;
+
+ public function __construct() {
+ $this->testPath = PHPUNIT_TEMP_DIR . '/TEST.txt';
+ }
+
+ public function setUp() {
+ Logger::resetConfiguration();
+ if(file_exists($this->testPath)) {
+ unlink($this->testPath);
+ }
+ }
+
+ public function tearDown() {
+ Logger::resetConfiguration();
+ if(file_exists($this->testPath)) {
+ unlink($this->testPath);
+ }
+ }
+
+ public function testRequiresLayout() {
+ $appender = new FileAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testActivationDoesNotCreateTheFile() {
+ $path = PHPUNIT_TEMP_DIR . "/doesnotexisthopefully.log";
+ @unlink($path);
+ $appender = new FileAppender();
+ $appender->setFile($path);
+ $appender->activateOptions();
+
+ self::assertFalse(file_exists($path));
+
+ $event = TestHelper::getInfoEvent('bla');
+ $appender->append($event);
+
+ self::assertTrue(file_exists($path));
+ }
+
+ public function testSimpleLogging() {
+ $config = $this->config1;
+ $config['appenders']['default']['params']['file'] = $this->testPath;
+
+ Logger::configure($config);
+
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ $expected = "INFO - This is a test" . PHP_EOL;
+ $actual = file_get_contents($this->testPath);
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testAppendFlagTrue() {
+ $config = $this->config1;
+ $config['appenders']['default']['params']['file'] = $this->testPath;
+ $config['appenders']['default']['params']['append'] = true;
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ $expected = "INFO - This is a test" . PHP_EOL . "INFO - This is a test" . PHP_EOL;
+ $actual = file_get_contents($this->testPath);
+ $this->assertSame($expected, $actual);
+ }
+
+ public function testAppendFlagFalse() {
+ $config = $this->config1;
+ $config['appenders']['default']['params']['file'] = $this->testPath;
+ $config['appenders']['default']['params']['append'] = false;
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ Logger::configure($config);
+ $logger = Logger::getRootLogger();
+ $logger->info('This is a test');
+
+ $expected = "INFO - This is a test" . PHP_EOL;
+ $actual = file_get_contents($this->testPath);
+ $this->assertSame($expected, $actual);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/MailAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/MailAppenderTest.php b/tests/src/Appenders/MailAppenderTest.php
new file mode 100644
index 0000000..73c7e83
--- /dev/null
+++ b/tests/src/Appenders/MailAppenderTest.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\MailAppender;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group appenders
+ */
+class MailAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ public function testRequiresLayout() {
+ $appender = new MailAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testMail() {
+ $appender = new MailAppender("myname ");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->setDry(true);
+ $appender->setTo('test@example.com');
+ $appender->setFrom('Testsender');
+
+ $appender->activateOptions();
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $event2 = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage2");
+
+ ob_start();
+ $appender->append($event);
+ $appender->append($event2);
+ $appender->close();
+ $v = ob_get_contents();
+ ob_end_clean();
+
+ $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with content: ERROR - testmessage".PHP_EOL."ERROR - testmessage2".PHP_EOL;
+ self::assertEquals($e, $v);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/MailEventAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/MailEventAppenderTest.php b/tests/src/Appenders/MailEventAppenderTest.php
new file mode 100644
index 0000000..2199f83
--- /dev/null
+++ b/tests/src/Appenders/MailEventAppenderTest.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\MailEventAppender;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group appenders
+ */
+class MailEventAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ public function testRequiresLayout() {
+ $appender = new MailEventAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testMail() {
+ $appender = new MailEventAppender("myname");
+
+ $layout = new SimpleLayout();
+ $appender->setLayout($layout);
+ $appender->setDry(true);
+ $appender->setTo('test@example.com');
+ $appender->setFrom('Testsender');
+
+ $appender->activateOptions();
+ $event = new LoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ ob_start();
+ $appender->append($event);
+ $v = ob_get_contents();
+ ob_end_clean();
+
+ $e = "DRY MODE OF MAIL APP.: Send mail to: test@example.com with additional headers 'From: Testsender' and content: ERROR - testmessage".PHP_EOL;
+ self::assertEquals($e, $v);
+ $appender->close();
+ }
+
+ /**
+ * Check an error is reported if 'to' is not set.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'to' not set.
+ */
+ public function testEmptyTo() {
+ $appender = new MailEventAppender("myname");
+ $appender->setLayout(new SimpleLayout());
+ $appender->setFrom('info@example.com');
+ $appender->activateOptions();
+ }
+
+ /**
+ * Check an error is reported if 'from' is not set.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage Required parameter 'from' not set.
+ */
+ public function testEmptyFrom() {
+ $appender = new MailEventAppender("myname");
+ $appender->setLayout(new SimpleLayout());
+ $appender->setTo('info@example.com');
+ $appender->activateOptions();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/MongoDBAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/MongoDBAppenderTest.php b/tests/src/Appenders/MongoDBAppenderTest.php
new file mode 100644
index 0000000..e4622dd
--- /dev/null
+++ b/tests/src/Appenders/MongoDBAppenderTest.php
@@ -0,0 +1,213 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\MongoDBAppender;
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Logger;
+use Apache\Log4php\Level;
+use Apache\Log4php\Tests\TestHelper;
+
+/**
+ * Testclass for the MongoDB appender.
+ *
+ * This class has been originally contributed from Vladimir Gorej
+ * (http://github.com/log4mongo/log4mongo-php).
+ *
+ * @group appenders
+ */
+class MongoDBAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ protected $appender;
+ protected $event;
+
+ protected function setUp() {
+ if (!extension_loaded('mongo')) {
+ $this->markTestSkipped(
+ 'The Mongo extension is not available.'
+ );
+ } else {
+ $this->appender = new MongoDBAppender('mongo_appender');
+ $this->event = TestHelper::getErrorEvent('mongo logging event', 'test_mongo');
+ }
+ }
+
+ protected function tearDown() {
+ unset($this->appender);
+ }
+
+ public function testHost() {
+ $expected = 'mongodb://localhost';
+ $this->appender->setHost($expected);
+ $result = $this->appender->getHost();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testPort() {
+ $expected = 27017;
+ $this->appender->setPort($expected);
+ $result = $this->appender->getPort();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testDatabaseName() {
+ $expected = 'log4php_mongodb';
+ $this->appender->setDatabaseName($expected);
+ $result = $this->appender->getDatabaseName();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testCollectionName() {
+ $expected = 'logs';
+ $this->appender->setCollectionName($expected);
+ $result = $this->appender->getCollectionName();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testUserName() {
+ $expected = 'char0n';
+ $this->appender->setUserName($expected);
+ $result = $this->appender->getUserName();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testPassword() {
+ $expected = 'secret pass';
+ $this->appender->setPassword($expected);
+ $result = $this->appender->getPassword();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testTimeout() {
+ $expected = 4000;
+ $this->appender->setTimeout($expected);
+ $result = $this->appender->getTimeout();
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testActivateOptions() {
+ $this->appender->activateOptions();
+ $this->assertInstanceOf('Mongo', $this->appender->getConnection());
+ $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
+ }
+
+ public function testActivateOptionsNoCredentials() {
+ $this->appender->setUserName(null);
+ $this->appender->setPassword(null);
+ $this->appender->activateOptions();
+ $this->assertInstanceOf('Mongo', $this->appender->getConnection());
+ $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
+ }
+
+ public function testFormat() {
+ $this->appender->activateOptions();
+ $record = $this->logOne($this->event);
+
+ $this->assertEquals('ERROR', $record['level']);
+ $this->assertEquals('mongo logging event', $record['message']);
+ $this->assertEquals('test_mongo', $record['loggerName']);
+
+ $this->assertEquals('NA', $record['fileName']);
+ $this->assertEquals('getLocationInformation', $record['method']);
+ $this->assertEquals('NA', $record['lineNumber']);
+ $this->assertEquals('Apache\\Log4php\\LoggingEvent', $record['className']);
+
+ $this->assertTrue(is_int($record['thread']));
+ $this->assertSame(getmypid(), $record['thread']);
+ $this->assertTrue(is_int($record['lineNumber']) || $record['lineNumber'] == 'NA');
+ }
+
+ public function testFormatThrowableInfo() {
+ $this->appender->activateOptions();
+ $event = new LoggingEvent(
+ 'testFqcn',
+ new Logger('test.Logger'),
+ Level::getLevelWarn(),
+ 'test message',
+ microtime(true),
+ new \Exception('test exception', 1)
+ );
+
+ $record = $this->logOne($event);
+
+ $this->assertArrayHasKey('exception', $record);
+ $this->assertEquals(1, $record['exception']['code']);
+ $this->assertEquals('test exception', $record['exception']['message']);
+
+ $this->assertContains('[internal function]: ' . __CLASS__, $record['exception']['stackTrace']);
+ }
+
+ public function testFormatThrowableInfoWithInnerException() {
+
+ // Skip test if PHP version is lower than 5.3.0 (no inner exception support)
+ if (version_compare(PHP_VERSION, '5.3.0') < 0) {
+ $this->markTestSkipped();
+ }
+
+ $this->appender->activateOptions();
+ $event = new LoggingEvent(
+ 'testFqcn',
+ new Logger('test.Logger'),
+ Level::getLevelWarn(),
+ 'test message',
+ microtime(true),
+ new \Exception('test exception', 1, new \Exception('test exception inner', 2))
+ );
+
+ $record = $this->logOne($event);
+
+ $this->assertArrayHasKey('exception', $record);
+ $this->assertEquals(1, $record['exception']['code']);
+ $this->assertEquals('test exception', $record['exception']['message']);
+ $this->assertContains('[internal function]: ' . __CLASS__, $record['exception']['stackTrace']);
+
+ $this->assertArrayHasKey('innerException', $record['exception']);
+ $this->assertEquals(2, $record['exception']['innerException']['code']);
+ $this->assertEquals('test exception inner', $record['exception']['innerException']['message']);
+ }
+
+
+ public function testClose() {
+ $this->appender->activateOptions();
+ $this->assertInstanceOf('Mongo', $this->appender->getConnection());
+ $this->assertInstanceOf('MongoCollection', $this->appender->getCollection());
+ $this->appender->close();
+ $this->assertNull($this->appender->getConnection());
+ $this->assertNull($this->appender->getCollection());
+ }
+
+ /**
+ * Logs the event and returns the record from the database.
+ * @param LoggingEvent $event
+ * @return array
+ */
+ private function logOne($event)
+ {
+ $collection = $this->appender->getCollection();
+ $collection->drop();
+ $this->appender->append($event);
+ $record = $collection->findOne();
+ $this->assertNotNull($record, 'Could not read the record from the database.');
+ return $record;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/NullAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/NullAppenderTest.php b/tests/src/Appenders/NullAppenderTest.php
new file mode 100644
index 0000000..5c7a96e
--- /dev/null
+++ b/tests/src/Appenders/NullAppenderTest.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\NullAppender;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * @group appenders
+ */
+class NullAppenderTest extends \PHPUnit_Framework_TestCase {
+ /**
+ * The Null appender does nothing - nothing to assert.
+ * Just here for the sake of completness and a good testing ratio :-)
+ */
+ public function testActivateOptions() {
+ $event = new LoggingEvent("LoggerAppenderNullTest", new Logger("TEST"), Level::getLevelInfo(), "testmessage");
+
+ $appender = new NullAppender("TEST");
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+ }
+
+ public function testRequiresLayout() {
+ $appender = new NullAppender();
+ self::assertFalse($appender->requiresLayout());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/PDOAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/PDOAppenderTest.php b/tests/src/Appenders/PDOAppenderTest.php
new file mode 100644
index 0000000..b325e04
--- /dev/null
+++ b/tests/src/Appenders/PDOAppenderTest.php
@@ -0,0 +1,170 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\PDOAppender;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+use PDO;
+
+/**
+ * @group appenders
+ */
+class PDOAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ const FILENAME = 'pdotest.sqlite';
+ private static $dsn;
+ private static $file;
+
+ public static function setUpBeforeClass() {
+
+ self::$file = PHPUNIT_TEMP_DIR . '/' . self::FILENAME;
+ self::$dsn = 'sqlite:' . self::$file;
+
+ if(extension_loaded('pdo_sqlite')) {
+ $drop = 'DROP TABLE IF EXISTS log4php_log;';
+ $create = 'CREATE TABLE log4php_log (
+ timestamp VARCHAR(256),
+ logger VARCHAR(256),
+ level VARCHAR(32),
+ message VARCHAR(4000),
+ thread INTEGER,
+ file VARCHAR(255),
+ line VARCHAR(10)
+ );';
+
+ $pdo = new PDO(self::$dsn);
+ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $pdo->exec($drop);
+ $pdo->exec($create);
+ }
+ }
+
+ /** To start with an empty database for each single test. */
+ public function setUp() {
+ if(!extension_loaded('pdo_sqlite')) {
+ self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
+ }
+ }
+
+ /** Clean up after the last test was run. */
+ public static function tearDownAfterClass() {
+ @unlink(self::$file);
+ }
+
+ public function testRequiresLayout() {
+ $appender = new PDOAppender();
+ self::assertFalse($appender->requiresLayout());
+ }
+
+ /** Tests new-style logging using prepared statements and the default SQL definition. */
+ public function testSimpleWithDefaults() {
+ // Log event
+ $event = new LoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $appender = new PDOAppender("myname");
+ $appender->setDSN(self::$dsn);
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ // Test the default pattern
+ $db = new PDO(self::$dsn);
+ $query = "SELECT * FROM log4php_log";
+ $sth = $db->query($query);
+ $row = $sth->fetch(PDO::FETCH_NUM);
+
+ self::assertTrue(is_array($row), "No rows found.");
+ self::assertEquals(7, count($row));
+ self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row[0])); // datetime
+ self::assertEquals('TEST', $row[1]); // logger name
+ self::assertEquals('ERROR', $row[2]); // level
+ self::assertEquals('testmessage', $row[3]); // message
+ if (function_exists('posix_getpid')) {
+ self::assertEquals(posix_getpid(), $row[4]); // process id
+ }
+ self::assertEquals('NA', $row[5]); // file, NA due to phpunit magic
+ self::assertEquals('NA', $row[6]); // line, NA due to phpunit magic
+ }
+
+
+ /** Tests new style prepared statment logging with customized SQL. */
+ public function testCustomizedSql() {
+
+ $dateFormat = "Y-m-d H:i:s";
+
+ // Prepare appender
+ $appender = new PDOAppender("myname");
+ $appender->setDSN(self::$dsn);
+ $appender->setInsertSql("INSERT INTO log4php_log (file, line, thread, timestamp, logger, level, message) VALUES (?,?,?,?,?,?,?)");
+ $appender->setInsertPattern("%F,%L,%t,%d\{$dateFormat\},%c,%p,%m");
+ $appender->activateOptions();
+
+ // Action!
+ $event = new LoggingEvent("LoggerAppenderPDOTest2", new Logger("TEST"), Level::getLevelError(), "testmessage");
+ $appender->append($event);
+
+ // Check
+ $db = new PDO(self::$dsn);
+ $result = $db->query("SELECT * FROM log4php_log");
+ $row = $result->fetch(PDO::FETCH_OBJ);
+ self::assertTrue(is_object($row));
+ self::assertEquals("NA", $row->file); // "NA" due to phpunit magic
+ self::assertEquals("NA", $row->line); // "NA" due to phpunit magic
+ if (function_exists('posix_getpid')) {
+ self::assertEquals(posix_getpid(), $row->thread);
+ }
+ self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row->timestamp));
+ self::assertEquals('TEST', $row->logger);
+ self::assertEquals('ERROR', $row->level);
+ self::assertEquals('testmessage', $row->message);
+ }
+
+ /**
+ * Tests a warning is shown when connecting to invalid dns.
+ * @expectedException PHPUnit_Framework_Error
+ * @expectedExceptionMessage invalid data source name
+ */
+ public function testException() {
+ $dsn = 'doenotexist';
+ $appender = new PDOAppender("myname");
+ $appender->setDSN($dsn);
+ $appender->activateOptions();
+ }
+
+ /**
+ * Check whether close() actually closes the database connection.
+ */
+ public function testClose() {
+ $event = new LoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), Level::getLevelError(), "testmessage");
+
+ $appender = new PDOAppender("myname");
+ $appender->setDSN(self::$dsn);
+ $appender->activateOptions();
+ $appender->append($event);
+ $appender->close();
+
+ self::assertNull($appender->getDatabaseHandle());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/PhpAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/PhpAppenderTest.php b/tests/src/Appenders/PhpAppenderTest.php
new file mode 100644
index 0000000..0653f65
--- /dev/null
+++ b/tests/src/Appenders/PhpAppenderTest.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\PhpAppender;
+use Apache\Log4php\Logger;
+
+/**
+ * @group appenders
+ */
+class PhpAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ public static $expectedMessage;
+
+ public static $expectedError;
+
+ private $config = array(
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ 'level' => 'trace'
+ ),
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'PhpAppender',
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ ),
+ )
+ )
+ );
+
+ protected function setUp() {
+ $that = $this; // hack for PHP 5.3
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
+ $that::assertEquals($that::$expectedError, $errno);
+ $that::assertEquals($that::$expectedMessage, $errstr);
+ });
+ }
+
+ public function testRequiresLayout() {
+ $appender = new PhpAppender();
+ $this->assertTrue($appender->requiresLayout());
+ }
+
+ public function testPhp() {
+ Logger::configure($this->config);
+ $logger = Logger::getRootLogger();
+
+
+ self::$expectedError = E_USER_ERROR;
+ self::$expectedMessage = "FATAL - This is a test" . PHP_EOL;
+ $logger->fatal("This is a test");
+
+ self::$expectedError = E_USER_ERROR;
+ self::$expectedMessage = "ERROR - This is a test" . PHP_EOL;
+ $logger->error("This is a test");
+
+ self::$expectedError = E_USER_WARNING;
+ self::$expectedMessage = "WARN - This is a test" . PHP_EOL;
+ $logger->warn("This is a test");
+
+ self::$expectedError = E_USER_NOTICE;
+ self::$expectedMessage = "INFO - This is a test" . PHP_EOL;
+ $logger->info("This is a test");
+
+ self::$expectedError = E_USER_NOTICE;
+ self::$expectedMessage = "DEBUG - This is a test" . PHP_EOL;
+ $logger->debug("This is a test");
+
+ self::$expectedError = E_USER_NOTICE;
+ self::$expectedMessage = "TRACE - This is a test" . PHP_EOL;
+ $logger->trace("This is a test");
+ }
+
+ protected function tearDown() {
+ restore_error_handler();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/RollingFileAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/RollingFileAppenderTest.php b/tests/src/Appenders/RollingFileAppenderTest.php
new file mode 100644
index 0000000..d284f3c
--- /dev/null
+++ b/tests/src/Appenders/RollingFileAppenderTest.php
@@ -0,0 +1,212 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\RollingFileAppender;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\Tests\TestHelper;
+use Apache\Log4php\LoggingEvent;
+use Apache\Log4php\Logger;
+use Apache\Log4php\Level;
+
+/**
+ * @group appenders
+ */
+class RollingFileAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ const WARNING_MASSAGE = 'WARN - my messageXYZ';
+
+ protected function setUp() {
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1');
+ @unlink(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2');
+ }
+
+ public function testRequiresLayout() {
+ $appender = new RollingFileAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testMaxFileSize() {
+ $appender = new RollingFileAppender("mylogger");
+
+ $appender->setMaxFileSize('1KB');
+ self::assertEquals(1024, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('2KB');
+ self::assertEquals(2048, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('1MB');
+ self::assertEquals(1048576, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('3MB');
+ self::assertEquals(3145728, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('1GB');
+ self::assertEquals(1073741824, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('10000');
+ self::assertEquals(10000, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('100.5');
+ self::assertEquals(100, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('1000.6');
+ self::assertEquals(1000, $appender->getMaxFileSize());
+
+ $appender->setMaxFileSize('1.5MB');
+ self::assertEquals(1572864, $appender->getMaxFileSize());
+ }
+
+ /**
+ * @return RollingFileAppender
+ */
+ private function createRolloverAppender() {
+ $layout = new SimpleLayout();
+
+ $appender = new RollingFileAppender("mylogger");
+ $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-rolling.txt');
+ $appender->setLayout($layout);
+ $appender->setMaxFileSize('1KB');
+ $appender->setMaxBackupIndex(2);
+ $appender->activateOptions();
+
+ return $appender;
+ }
+
+ public function testSimpleLogging() {
+ $appender = $this->createRolloverAppender();
+
+ $event = TestHelper::getWarnEvent("my message123");
+
+ for($i = 0; $i < 1000; $i++) {
+ $appender->append($event);
+ }
+
+ $appender->append(TestHelper::getWarnEvent("my messageXYZ"));
+
+ $appender->close();
+
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
+ $data = file($file);
+ $line = $data[count($data)-1];
+ $e = "WARN - my messageXYZ".PHP_EOL;
+ self::assertEquals($e, $line);
+
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
+ $this->checkFileContent($file);
+
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
+ $this->checkFileContent($file);
+
+ // Should not roll over three times
+ $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'));
+ }
+
+ public function testLoggingViaLogger() {
+ $logger = Logger::getLogger('mycat');
+ $logger->setAdditivity(false);
+
+ $appender = $this->createRolloverAppender();
+
+ $logger->addAppender($appender);
+
+ for($i = 0; $i < 1000; $i++) {
+ $logger->warn("my message123");
+ }
+
+ $logger->warn("my messageXYZ");
+
+ $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt';
+ $data = file($file);
+
+ $line = $data[count($data)-1];
+ $e = "WARN - my messageXYZ".PHP_EOL;
+ self::assertEquals($e, $line);
+
+ $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1';
+ $this->checkFileContent($file);
+
+ $file = PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2';
+ $this->checkFileContent($file);
+
+ $this->assertFalse(file_exists(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.3'), 'should not roll over three times');
+ }
+
+ public function testRolloverWithCompression() {
+ $logger = Logger::getLogger('mycat');
+ $logger->setAdditivity(false);
+
+ $appender = $this->createRolloverAppender();
+ $appender->setCompress(true);
+
+ $logger->addAppender($appender);
+
+ for($i = 0; $i < 1000; $i++) {
+ $logger->warn(self::WARNING_MASSAGE. $i);
+ }
+
+ $logger->warn("my messageXYZ");
+
+ $file = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt';
+ $data = file($file);
+
+ $line = $data[count($data)-1];
+ $e = self::WARNING_MASSAGE.PHP_EOL;
+ self::assertEquals($e, $line);
+
+ $firstCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1.gz';
+ $this->assertTrue(file_exists($firstCompressedRollingFile),'TEST-rolling.txt.1.gz not found');
+
+ $firstUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.1';
+ $this->assertFalse(file_exists($firstUncompressedRollingField),'TEST-rolling.txt.1 should be replaced by compressed');
+
+ $secondCompressedRollingFile = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2.gz';
+ $this->assertTrue(file_exists($secondCompressedRollingFile), 'TEST-rolling.txt.2.gz not found');
+
+ $secondUncompressedRollingField = PHPUNIT_TEMP_DIR . '/TEST-rolling.txt.2';
+ $this->assertFalse(file_exists($secondUncompressedRollingField),'TEST-rolling.txt.2 should be replaced by compressed');
+
+ }
+
+ private function checkFileContent($file) {
+ $data = file($file);
+ $this->checkText($data);
+ }
+
+ private function checkText($text) {
+ $line = $text[count($text)-1];
+ $e = "WARN - my message123".PHP_EOL;
+ foreach($text as $r) {
+ self::assertEquals($e, $r);
+ }
+ }
+
+ protected function tearDown() {
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.1.gz');
+ @unlink(PHPUNIT_TEMP_DIR.'/TEST-rolling.txt.2.gz');
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/SocketAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/SocketAppenderTest.php b/tests/src/Appenders/SocketAppenderTest.php
new file mode 100644
index 0000000..9cd1482
--- /dev/null
+++ b/tests/src/Appenders/SocketAppenderTest.php
@@ -0,0 +1,151 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\SocketAppender;
+use Apache\Log4php\Logger;
+
+/**
+ * @group appenders
+ */
+class SocketAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ /** Port on which the socket server will run. */
+ const SOCKET_PORT = 12345;
+
+ /** The socket server process resource. */
+ private $server;
+
+ /** The pipes array for the server process. */
+ private $pipes;
+
+ public function setUp() {
+ Logger::clear();
+ }
+
+ public function tearDown() {
+ Logger::clear();
+ }
+
+ public function testRequiresLayout() {
+ $appender = new SocketAppender();
+ self::assertTrue($appender->requiresLayout());
+ }
+
+ public function testLogging()
+ {
+ Logger::configure(array(
+ 'appenders' => array(
+ 'default' => array(
+ 'class' => 'SocketAppender',
+ 'params' => array(
+ 'remoteHost' => 'localhost',
+ 'port' => self::SOCKET_PORT
+ ),
+ 'layout' => array(
+ 'class' => 'SimpleLayout'
+ )
+ ),
+ ),
+ 'rootLogger' => array(
+ 'appenders' => array('default'),
+ ),
+ ));
+
+ $this->startServer();
+
+ $logger = Logger::getLogger("myLogger");
+ $logger->trace("This message is a test");
+ $logger->debug("This message is a test");
+ $logger->info("This message is a test");
+ $logger->warn("This message is a test");
+ $logger->error("This message is a test");
+ $logger->fatal("This message is a test");
+
+ $actual = $this->getPlayback();
+ $this->stopServer();
+
+ $expected = "DEBUG - This message is a test" .
+ "INFO - This message is a test" .
+ "WARN - This message is a test" .
+ "ERROR - This message is a test" .
+ "FATAL - This message is a test";
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /** Starts a socket server in a separate process. */
+ private function startServer() {
+ $serverLog = PHPUNIT_TEMP_DIR . '/socketServer.log';
+ $descriptorspec = array(
+ 0 => array("pipe", "r"), // stdin
+ 1 => array("file", $serverLog, "a"),// stdout
+ 2 => array("file", $serverLog, "a") // stderr
+ );
+
+ $cmd = "php " . dirname(__FILE__) . '/socketServer.php';
+ $this->server = proc_open($cmd, $descriptorspec, $this->pipes);
+ if ($this->server === false) {
+ throw new Exception("Failed starting the socket server process.");
+ }
+
+ // Sleep a bit to allow server to start
+ usleep(200000);
+
+ // Verify the server is running
+ $status = proc_get_status($this->server);
+ if (!$status['running']) {
+ throw new Exception("Socket server process failed to start. Check the log at [$serverLog].");
+ }
+ }
+
+ /** Sends a message to the socket server and returns the reply. */
+ private function socketSend($msg) {
+ $sock = fsockopen('localhost', self::SOCKET_PORT, $errno, $errstr);
+ if ($sock === false) {
+ throw new Exception("Unable to open socket. Error: [$errno] $errstr");
+ }
+
+ fputs($sock, "$msg\n");
+ $reply = '';
+ while(!feof($sock)) {
+ $reply .= fgets($sock);
+ }
+ fclose($sock);
+ return trim($reply);
+ }
+
+ /** Retrieves a playback of all sent messages from the socket server. */
+ private function getPlayback() {
+ return $this->socketSend('playback');
+ }
+
+ /** Stops the socket server and closes the process. */
+ private function stopServer() {
+ $this->socketSend('shutdown');
+ foreach($this->pipes as $pipe) {
+ fclose($pipe);
+ }
+ proc_close($this->server);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/SyslogAppenderTest.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/SyslogAppenderTest.php b/tests/src/Appenders/SyslogAppenderTest.php
new file mode 100644
index 0000000..91b1568
--- /dev/null
+++ b/tests/src/Appenders/SyslogAppenderTest.php
@@ -0,0 +1,253 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ */
+
+namespace Apache\Log4php\Tests\Appenders;
+
+use Apache\Log4php\Appenders\SyslogAppender;
+use Apache\Log4php\Layouts\SimpleLayout;
+use Apache\Log4php\Level;
+use Apache\Log4php\Logger;
+use Apache\Log4php\LoggingEvent;
+
+/**
+ * Tests the syslog appender.
+ *
+ * Many of these tests rely on reflection features introduced in 5.3 and
+ * will be skipped if run on a lower version.
+ *
+ * This test will only write a single entry to the syslog.
+ *
+ * @group appenders
+ */
+class SyslogAppenderTest extends \PHPUnit_Framework_TestCase {
+
+ public function testSettersGetters() {
+
+ // Setters should accept any value, without validation
+ $expected = "Random string value";
+
+ $appender = new SyslogAppender();
+ $appender->setIdent($expected);
+ $appender->setFacility($expected);
+ $appender->setOverridePriority($expected);
+ $appender->setPriority($expected);
+ $appender->setOption($expected);
+
+ $actuals = array(
+ $appender->getIdent(),
+ $appender->getFacility(),
+ $appender->getOverridePriority(),
+ $appender->getPriority(),
+ $appender->getOption()
+ );
+
+ foreach($actuals as $actual) {
+ $this->assertSame($expected, $actual);
+ }
+ }
+
+ public function testRequiresLayout() {
+ $appender = new SyslogAppender();
+ $this->assertTrue($appender->requiresLayout());
+ }
+
+ public function testLogging() {
+ $appender = new SyslogAppender("myname");
+ $appender->setLayout(new SimpleLayout());
+ $appender->activateOptions();
+
+ $event = new LoggingEvent(__CLASS__, new Logger("TestLogger"), Level::getLevelError(), "testmessage");
+ $appender->append($event);
+ }
+
+ /** Tests parsing of "option" parameter. */
+ public function testOption() {
+ $options = array(
+ 'CONS' => LOG_CONS,
+ 'NDELAY' => LOG_NDELAY,
+ 'ODELAY' => LOG_ODELAY,
+ 'PERROR' => LOG_PERROR,
+ 'PID' => LOG_PID,
+
+ // test some combinations
+ 'CONS|NDELAY' => LOG_CONS | LOG_NDELAY,
+ 'PID|PERROR' => LOG_PID | LOG_PERROR,
+ 'CONS|PID|NDELAY' => LOG_CONS | LOG_PID | LOG_NDELAY
+ );
+
+ // Defaults
+ $defaultStr = "PID|CONS";
+ $default = LOG_PID | LOG_CONS;
+
+ // This makes reading of a private property possible
+ $property = new \ReflectionProperty('Apache\\Log4php\Appenders\\SyslogAppender', 'intOption');
+ $property->setAccessible(true);
+
+ // Check default value first
+ $appender = new SyslogAppender();
+ $appender->activateOptions();
+ $actual = $property->getValue($appender);
+ $this->assertSame($default, $actual, "Failed setting default option [$defaultStr]");
+
+ foreach($options as $option => $expected) {
+ $appender = new SyslogAppender();
+ $appender->setOption($option);
+ $appender->activateOptions();
+
+ $actual = $property->getValue($appender);
+ $this->assertSame($expected, $actual, "Failed setting option [$option].");
+ }
+ }
+
+ /** Tests parsing of "priority" parameter. */
+ public function testPriority() {
+ $default = null;
+ $defaultStr = 'null';
+
+ $priorities = array(
+ 'EMERG' => LOG_EMERG,
+ 'ALERT' => LOG_ALERT,
+ 'CRIT' => LOG_CRIT,
+ 'ERR' => LOG_ERR,
+ 'WARNING' => LOG_WARNING,
+ 'NOTICE' => LOG_NOTICE,
+ 'INFO' => LOG_INFO,
+ 'DEBUG' => LOG_DEBUG
+ );
+
+ // This makes reading of a private property possible
+ $property = new \ReflectionProperty('Apache\\Log4php\\Appenders\\SyslogAppender', 'intPriority');
+ $property->setAccessible(true);
+
+ // Check default value first
+ $appender = new SyslogAppender();
+ $appender->activateOptions();
+ $actual = $property->getValue($appender);
+ $this->assertSame($default, $actual, "Failed setting default priority [$defaultStr].");
+
+ foreach($priorities as $priority => $expected) {
+ $appender = new SyslogAppender();
+ $appender->setPriority($priority);
+ $appender->activateOptions();
+
+ $actual = $property->getValue($appender);
+ $this->assertSame($expected, $actual, "Failed setting priority [$priority].");
+ }
+ }
+
+ /** Tests parsing of "facility" parameter. */
+ public function testFacility() {
+ // Default value is the same on all OSs
+ $default = LOG_USER;
+ $defaultStr = 'USER';
+
+ // All possible facility strings (some of which might not exist depending on the OS)
+ $strings = array(
+ 'KERN', 'USER', 'MAIL', 'DAEMON', 'AUTH',
+ 'SYSLOG', 'LPR', 'NEWS', 'UUCP', 'CRON', 'AUTHPRIV',
+ 'LOCAL0', 'LOCAL1', 'LOCAL2', 'LOCAL3', 'LOCAL4',
+ 'LOCAL5', 'LOCAL6', 'LOCAL7',
+ );
+
+ // Only test facilities which exist on this OS
+ $facilities = array();
+ foreach($strings as $string) {
+ $const = "LOG_$string";
+ if (defined($const)) {
+ $facilities[$string] = constant($const);
+ }
+ }
+
+ // This makes reading of a private property possible
+ $property = new \ReflectionProperty('Apache\\Log4php\\Appenders\\SyslogAppender', 'intFacility');
+ $property->setAccessible(true);
+
+ // Check default value first
+ $appender = new SyslogAppender();
+ $appender->activateOptions();
+ $actual = $property->getValue($appender);
+ $this->assertSame($default, $default, "Failed setting default facility [$defaultStr].");
+
+ foreach($facilities as $facility => $expected) {
+ $appender = new SyslogAppender();
+ $appender->setFacility($facility);
+ $appender->activateOptions();
+
+ $actual = $property->getValue($appender);
+ $this->assertSame($expected, $actual, "Failed setting priority [$facility].");
+ }
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testInvalidOption() {
+ $appender = new SyslogAppender();
+ $appender->setOption('CONS|XYZ');
+ $appender->activateOptions();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testInvalidPriority() {
+ $appender = new SyslogAppender();
+ $appender->setPriority('XYZ');
+ $appender->activateOptions();
+ }
+
+ /**
+ * @expectedException PHPUnit_Framework_Error
+ */
+ public function testInvalidFacility() {
+ $appender = new SyslogAppender();
+ $appender->setFacility('XYZ');
+ $appender->activateOptions();
+ }
+
+
+ public function testPriorityOverride() {
+ $appender = new SyslogAppender();
+ $appender->setPriority('EMERG');
+ $appender->setOverridePriority(true);
+ $appender->activateOptions();
+
+ $levels = array(
+ Level::getLevelTrace(),
+ Level::getLevelDebug(),
+ Level::getLevelInfo(),
+ Level::getLevelWarn(),
+ Level::getLevelError(),
+ Level::getLevelFatal(),
+ );
+
+ $expected = LOG_EMERG;
+
+ $method = new \ReflectionMethod('Apache\\Log4php\\Appenders\\SyslogAppender', 'getSyslogPriority');
+ $method->setAccessible(true);
+
+ foreach($levels as $level) {
+ $actual = $method->invoke($appender, $level);
+ $this->assertSame($expected, $actual);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/tests/src/Appenders/socketServer.php
----------------------------------------------------------------------
diff --git a/tests/src/Appenders/socketServer.php b/tests/src/Appenders/socketServer.php
new file mode 100644
index 0000000..19a7b7c
--- /dev/null
+++ b/tests/src/Appenders/socketServer.php
@@ -0,0 +1,95 @@
+<?php
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @category tests
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php
+ *
+ * A simple socket server used in LoggerAppenderSocketTest.
+ */
+
+// Port on which to start the server
+define('SERVER_PORT', 12345);
+
+// Prevent hangs
+set_time_limit(0);
+
+// Create a socket
+$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+if ($sock === false) {
+ die("Failed creating socket: " . socket_strerror(socket_last_error()));
+}
+
+if (socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1) === false) {
+ die("Failed setting socket options: " . socket_strerror(socket_last_error()));
+}
+
+if (socket_bind($sock, 'localhost', SERVER_PORT) === false) {
+ die("Failed binding socket: " . socket_strerror(socket_last_error()));
+}
+
+if (socket_listen($sock, 100) === false) {
+ die("Failed binding socket: " . socket_strerror(socket_last_error()));
+}
+
+socket_getsockname($sock, $addr, $port);
+myLog("Server Listening on $addr:$port");
+
+// Buffer which will store incoming messages
+$playback = "";
+
+while(true) {
+ myLog("Waiting for incoming connections...");
+
+ $msgsock = socket_accept($sock);
+ if ($msgsock === false) {
+ myLog("Failed accepting a connection: " . socket_strerror(socket_last_error()));
+ break;
+ }
+
+ $buf = socket_read($msgsock, 2048, PHP_NORMAL_READ);
+
+ myLog('Received: "' . trim($buf) . '"');
+
+ // Shutdown command
+ if (trim($buf) == 'shutdown') {
+ myLog("Shutting down.");
+ socket_close($msgsock);
+ break;
+ }
+ // Playback command
+ else if (trim($buf) == 'playback') {
+ myLog("Returning playback: \"$playback\"");
+ socket_write($msgsock, $playback);
+ }
+ // Default: add to playback buffer
+ else {
+ $playback .= trim($buf);
+ }
+
+ socket_close($msgsock);
+}
+
+myLog("Closing socket.");
+socket_close($sock);
+
+function myLog($msg) {
+ echo date("Y-m-d H:i:s") . " $msg\n";
+}
+
+?>
[37/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/PdoAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/PdoAppender.php b/src/Appenders/PdoAppender.php
index 87c81bf..431b9d6 100644
--- a/src/Appenders/PdoAppender.php
+++ b/src/Appenders/PdoAppender.php
@@ -44,244 +44,263 @@ use PDOException;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/pdo.html Appender documentation
*/
-class PDOAppender extends AbstractAppender {
-
- // ******************************************
- // *** Configurable parameters ***
- // ******************************************
-
- /**
- * DSN string used to connect to the database.
- * @see http://www.php.net/manual/en/pdo.construct.php
- */
- protected $dsn;
-
- /** Database user name. */
- protected $user;
-
- /** Database password. */
- protected $password;
-
- /**
- * The insert query.
- *
- * The __TABLE__ placeholder will be replaced by the table name from
- * {@link $table}.
- *
- * The questionmarks are part of the prepared statement, and they must
- * match the number of conversion specifiers in {@link insertPattern}.
- */
- protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
-
- /**
- * A comma separated list of {@link LoggerPatternLayout} format strings
- * which replace the "?" in {@link $insertSQL}.
- *
- * Must contain the same number of comma separated conversion patterns as
- * there are question marks in {@link insertSQL}.
- *
- * @see LoggerPatternLayout For conversion patterns.
- */
- protected $insertPattern = "%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line";
-
- /** Name of the table to which to append log events. */
- protected $table = 'log4php_log';
-
- /** The number of recconect attempts to make on failed append. */
- protected $reconnectAttempts = 3;
-
-
- // ******************************************
- // *** Private memebers ***
- // ******************************************
-
- /**
- * The PDO instance.
- * @var PDO
- */
- protected $db;
-
- /**
- * Prepared statement for the insert query.
- * @var PDOStatement
- */
- protected $preparedInsert;
-
- /** This appender does not require a layout. */
- protected $requiresLayout = false;
-
-
- // ******************************************
- // *** Appender methods ***
- // ******************************************
-
- /**
- * 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 = PatternLayout::getDefaultConverterMap();
- foreach($pieces as $pattern) {
- $parser = new PatternParser($pattern, $converterMap);
- $this->converters[] = $parser->parse();
- }
-
- $this->closed = false;
- }
-
- /**
- * Connects to the database, and prepares the insert query.
- * @throws PDOException If connect or prepare fails.
- */
- protected function establishConnection() {
- // Acquire database connection
- $this->db = new PDO($this->dsn, $this->user, $this->password);
- $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- // Prepare the insert statement
- $insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
- $this->preparedInsert = $this->db->prepare($insertSQL);
- }
-
- /**
- * Appends a new event to the database.
- *
- * If writing to database fails, it will retry by re-establishing the
- * connection up to $reconnectAttempts times. If writing still fails,
- * the appender will close.
- */
- public function append(LoggingEvent $event) {
-
- for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
- try {
- // Attempt to write to database
- $this->preparedInsert->execute($this->format($event));
- $this->preparedInsert->closeCursor();
- break;
- } catch (PDOException $e) {
- $this->warn("Failed writing to database: ". $e->getMessage());
-
- // Close the appender if it's the last attempt
- if ($attempt > $this->reconnectAttempts) {
- $this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
- $this->close();
- // Otherwise reconnect and try to write again
- } else {
- $this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
- $this->establishConnection();
- }
- }
- }
- }
-
- /**
- * Converts the logging event to a series of database parameters by using
- * the converter chain which was set up on activation.
- */
- protected function format(LoggingEvent $event) {
- $params = array();
- foreach($this->converters as $converter) {
- $buffer = '';
- while ($converter !== null) {
- $converter->format($buffer, $event);
- $converter = $converter->next;
- }
- $params[] = $buffer;
- }
- return $params;
- }
-
- /**
- * Closes the connection to the logging database
- */
- public function close() {
- // Close the connection (if any)
- $this->db = null;
-
- // Close the appender
- $this->closed = true;
- }
-
- // ******************************************
- // *** Accessor methods ***
- // ******************************************
-
- /**
- * Returns the active database handle or null if not established.
- * @return PDO
- */
- public function getDatabaseHandle() {
- return $this->db;
- }
-
- /** Sets the username. */
- public function setUser($user) {
- $this->setString('user', $user);
- }
-
- /** Returns the username. */
- public function getUser($user) {
- return $this->user;
- }
-
- /** Sets the password. */
- public function setPassword($password) {
- $this->setString('password', $password);
- }
-
- /** Returns the password. */
- public function getPassword($password) {
- return $this->password;
- }
-
- /** Sets the insert SQL. */
- public function setInsertSQL($sql) {
- $this->setString('insertSQL', $sql);
- }
-
- /** Returns the insert SQL. */
- public function getInsertSQL($sql) {
- return $this->insertSQL;
- }
-
- /** Sets the insert pattern. */
- public function setInsertPattern($pattern) {
- $this->setString('insertPattern', $pattern);
- }
-
- /** Returns the insert pattern. */
- public function getInsertPattern($pattern) {
- return $this->insertPattern;
- }
-
- /** Sets the table name. */
- public function setTable($table) {
- $this->setString('table', $table);
- }
-
- /** Returns the table name. */
- public function getTable($table) {
- return $this->table;
- }
-
- /** Sets the DSN string. */
- public function setDSN($dsn) {
- $this->setString('dsn', $dsn);
- }
-
- /** Returns the DSN string. */
- public function getDSN($dsn) {
- return $this->setString('dsn', $dsn);
- }
+class PdoAppender extends AbstractAppender
+{
+ // ******************************************
+ // *** Configurable parameters ***
+ // ******************************************
+
+ /**
+ * DSN string used to connect to the database.
+ * @see http://www.php.net/manual/en/pdo.construct.php
+ */
+ protected $dsn;
+
+ /** Database user name. */
+ protected $user;
+
+ /** Database password. */
+ protected $password;
+
+ /**
+ * The insert query.
+ *
+ * The __TABLE__ placeholder will be replaced by the table name from
+ * {@link $table}.
+ *
+ * The questionmarks are part of the prepared statement, and they must
+ * match the number of conversion specifiers in {@link insertPattern}.
+ */
+ protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
+
+ /**
+ * A comma separated list of {@link LoggerPatternLayout} format strings
+ * which replace the "?" in {@link $insertSQL}.
+ *
+ * Must contain the same number of comma separated conversion patterns as
+ * there are question marks in {@link insertSQL}.
+ *
+ * @see LoggerPatternLayout For conversion patterns.
+ */
+ protected $insertPattern = "%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line";
+
+ /** Name of the table to which to append log events. */
+ protected $table = 'log4php_log';
+
+ /** The number of recconect attempts to make on failed append. */
+ protected $reconnectAttempts = 3;
+
+
+ // ******************************************
+ // *** Private memebers ***
+ // ******************************************
+
+ /**
+ * The PDO instance.
+ * @var PDO
+ */
+ protected $db;
+
+ /**
+ * Prepared statement for the insert query.
+ * @var PDOStatement
+ */
+ protected $preparedInsert;
+
+ /** This appender does not require a layout. */
+ protected $requiresLayout = false;
+
+
+ // ******************************************
+ // *** Appender methods ***
+ // ******************************************
+
+ /**
+ * 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 = PatternLayout::getDefaultConverterMap();
+ foreach ($pieces as $pattern) {
+ $parser = new PatternParser($pattern, $converterMap);
+ $this->converters[] = $parser->parse();
+ }
+
+ $this->closed = false;
+ }
+
+ /**
+ * Connects to the database, and prepares the insert query.
+ * @throws PDOException If connect or prepare fails.
+ */
+ protected function establishConnection()
+ {
+ // Acquire database connection
+ $this->db = new PDO($this->dsn, $this->user, $this->password);
+ $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ // Prepare the insert statement
+ $insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
+ $this->preparedInsert = $this->db->prepare($insertSQL);
+ }
+
+ /**
+ * Appends a new event to the database.
+ *
+ * If writing to database fails, it will retry by re-establishing the
+ * connection up to $reconnectAttempts times. If writing still fails,
+ * the appender will close.
+ */
+ public function append(LoggingEvent $event)
+ {
+ for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
+ try {
+ // Attempt to write to database
+ $this->preparedInsert->execute($this->format($event));
+ $this->preparedInsert->closeCursor();
+ break;
+ } catch (PDOException $e) {
+ $this->warn("Failed writing to database: ". $e->getMessage());
+
+ // Close the appender if it's the last attempt
+ if ($attempt > $this->reconnectAttempts) {
+ $this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
+ $this->close();
+ // Otherwise reconnect and try to write again
+ } else {
+ $this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
+ $this->establishConnection();
+ }
+ }
+ }
+ }
+
+ /**
+ * Converts the logging event to a series of database parameters by using
+ * the converter chain which was set up on activation.
+ */
+ protected function format(LoggingEvent $event)
+ {
+ $params = array();
+ foreach ($this->converters as $converter) {
+ $buffer = '';
+ while ($converter !== null) {
+ $converter->format($buffer, $event);
+ $converter = $converter->next;
+ }
+ $params[] = $buffer;
+ }
+
+ return $params;
+ }
+
+ /**
+ * Closes the connection to the logging database
+ */
+ public function close()
+ {
+ // Close the connection (if any)
+ $this->db = null;
+
+ // Close the appender
+ $this->closed = true;
+ }
+
+ // ******************************************
+ // *** Accessor methods ***
+ // ******************************************
+
+ /**
+ * Returns the active database handle or null if not established.
+ * @return PDO
+ */
+ public function getDatabaseHandle()
+ {
+ return $this->db;
+ }
+
+ /** Sets the username. */
+ public function setUser($user)
+ {
+ $this->setString('user', $user);
+ }
+
+ /** Returns the username. */
+ public function getUser($user)
+ {
+ return $this->user;
+ }
+
+ /** Sets the password. */
+ public function setPassword($password)
+ {
+ $this->setString('password', $password);
+ }
+
+ /** Returns the password. */
+ public function getPassword($password)
+ {
+ return $this->password;
+ }
+
+ /** Sets the insert SQL. */
+ public function setInsertSQL($sql)
+ {
+ $this->setString('insertSQL', $sql);
+ }
+
+ /** Returns the insert SQL. */
+ public function getInsertSQL($sql)
+ {
+ return $this->insertSQL;
+ }
+
+ /** Sets the insert pattern. */
+ public function setInsertPattern($pattern)
+ {
+ $this->setString('insertPattern', $pattern);
+ }
+
+ /** Returns the insert pattern. */
+ public function getInsertPattern($pattern)
+ {
+ return $this->insertPattern;
+ }
+
+ /** Sets the table name. */
+ public function setTable($table)
+ {
+ $this->setString('table', $table);
+ }
+
+ /** Returns the table name. */
+ public function getTable($table)
+ {
+ return $this->table;
+ }
+
+ /** Sets the DSN string. */
+ public function setDSN($dsn)
+ {
+ $this->setString('dsn', $dsn);
+ }
+
+ /** Returns the DSN string. */
+ public function getDSN($dsn)
+ {
+ return $this->setString('dsn', $dsn);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/PhpAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/PhpAppender.php b/src/Appenders/PhpAppender.php
index 287c56a..6d6c6c9 100644
--- a/src/Appenders/PhpAppender.php
+++ b/src/Appenders/PhpAppender.php
@@ -35,16 +35,17 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation
*/
-class PhpAppender extends AbstractAppender {
-
- public function append(LoggingEvent $event) {
- $level = $event->getLevel();
- if($level->isGreaterOrEqual(Level::getLevelError())) {
- trigger_error($this->layout->format($event), E_USER_ERROR);
- } else if ($level->isGreaterOrEqual(Level::getLevelWarn())) {
- trigger_error($this->layout->format($event), E_USER_WARNING);
- } else {
- trigger_error($this->layout->format($event), E_USER_NOTICE);
- }
- }
+class PhpAppender extends AbstractAppender
+{
+ public function append(LoggingEvent $event)
+ {
+ $level = $event->getLevel();
+ if ($level->isGreaterOrEqual(Level::getLevelError())) {
+ trigger_error($this->layout->format($event), E_USER_ERROR);
+ } elseif ($level->isGreaterOrEqual(Level::getLevelWarn())) {
+ trigger_error($this->layout->format($event), E_USER_WARNING);
+ } else {
+ trigger_error($this->layout->format($event), E_USER_NOTICE);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/RollingFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/RollingFileAppender.php b/src/Appenders/RollingFileAppender.php
index 8d54a4a..8e7024b 100644
--- a/src/Appenders/RollingFileAppender.php
+++ b/src/Appenders/RollingFileAppender.php
@@ -18,8 +18,6 @@
namespace Apache\Log4php\Appenders;
-use Apache\Log4php\LoggingEvent;
-
/**
* RollingFileAppender writes logging events to a specified file. The
* file is rolled over after a specified size has been reached.
@@ -40,264 +38,280 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/rolling-file.html Appender documentation
*/
-class RollingFileAppender extends FileAppender {
-
- /** Compressing backup files is done in chunks, this determines how large. */
- const COMPRESS_CHUNK_SIZE = 102400; // 100KB
-
- /**
- * The maximum size (in bytes) that the output file is allowed to reach
- * before being rolled over to backup files.
- *
- * The default maximum file size is 10MB (10485760 bytes). Maximum value
- * for this option may depend on the file system.
- *
- * @var integer
- */
- protected $maxFileSize = 10485760;
-
- /**
- * Set the maximum number of backup files to keep around.
- *
- * Determines how many backup files are kept before the oldest is erased.
- * This option takes a positive integer value. If set to zero, then there
- * will be no backup files and the log file will be truncated when it
- * reaches <var>maxFileSize</var>.
- *
- * There is one backup file by default.
- *
- * @var integer
- */
- protected $maxBackupIndex = 1;
-
- /**
- * The <var>compress</var> parameter determindes the compression with zlib.
- * If set to true, the rollover files are compressed and saved with the .gz extension.
- * @var boolean
- */
- protected $compress = false;
-
- /**
- * Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
- * supports conditional clearing of statistics.
- * @var boolean
- * @see http://php.net/manual/en/function.clearstatcache.php
- */
- private $clearConditional = false;
-
- /**
- * Get the maximum size that the output file is allowed to reach
- * before being rolled over to backup files.
- * @return integer
- */
- public function getMaximumFileSize() {
- return $this->maxFileSize;
- }
-
- public function __construct($name = '') {
- parent::__construct($name);
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
- $this->clearConditional = true;
- }
- }
-
- /**
- * Implements the usual roll over behaviour.
- *
- * If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
- * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
- *
- * If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
- *
- * Rollover must be called while the file is locked so that it is safe for concurrent access.
- *
- * @throws LoggerException If any part of the rollover procedure fails.
- */
- private function rollOver() {
- // If maxBackups <= 0, then there is no file renaming to be done.
- if($this->maxBackupIndex > 0) {
- // Delete the oldest file, to keep Windows happy.
- $file = $this->file . '.' . $this->maxBackupIndex;
-
- if (file_exists($file) && !unlink($file)) {
- throw new LoggerException("Unable to delete oldest backup file from [$file].");
- }
-
- // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- $this->renameArchievedLogs($this->file);
-
- // Backup the active file
- $this->moveToBackup($this->file);
- }
-
- // Truncate the active file
- ftruncate($this->fp, 0);
- rewind($this->fp);
- }
-
- private function moveToBackup($source) {
- if ($this->compress) {
- $target = $source . '.1.gz';
- $this->compressFile($source, $target);
- } else {
- $target = $source . '.1';
- copy($source, $target);
- }
- }
-
- private function compressFile($source, $target) {
- $target = 'compress.zlib://' . $target;
-
- $fin = fopen($source, 'rb');
- if ($fin === false) {
- throw new LoggerException("Unable to open file for reading: [$source].");
- }
-
- $fout = fopen($target, 'wb');
- if ($fout === false) {
- throw new LoggerException("Unable to open file for writing: [$target].");
- }
-
- while (!feof($fin)) {
- $chunk = fread($fin, self::COMPRESS_CHUNK_SIZE);
- if (false === fwrite($fout, $chunk)) {
- throw new LoggerException("Failed writing to compressed file.");
- }
- }
-
- fclose($fin);
- fclose($fout);
- }
-
- private function renameArchievedLogs($fileName) {
- for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
-
- $source = $fileName . "." . $i;
- if ($this->compress) {
- $source .= '.gz';
- }
-
- if(file_exists($source)) {
- $target = $fileName . '.' . ($i + 1);
- if ($this->compress) {
- $target .= '.gz';
- }
-
- rename($source, $target);
- }
- }
- }
-
- /**
- * Writes a string to the target file. Opens file if not already open.
- * @param string $string Data to write.
- */
- protected function write($string) {
- // Lazy file open
- if(!isset($this->fp)) {
- if ($this->openFile() === false) {
- return; // Do not write if file open failed.
- }
- }
-
- // Lock the file while writing and possible rolling over
- if(flock($this->fp, LOCK_EX)) {
-
- // Write to locked file
- if(fwrite($this->fp, $string) === false) {
- $this->warn("Failed writing to file. Closing appender.");
- $this->closed = true;
- }
-
- // Stats cache must be cleared, otherwise filesize() returns cached results
- // If supported (PHP 5.3+), clear only the state cache for the target file
- if ($this->clearConditional) {
- clearstatcache(true, $this->file);
- } else {
- clearstatcache();
- }
-
- // Rollover if needed
- if (filesize($this->file) > $this->maxFileSize) {
- try {
- $this->rollOver();
- } catch (LoggerException $ex) {
- $this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
- $this->closed = true;
- }
- }
-
- flock($this->fp, LOCK_UN);
- } else {
- $this->warn("Failed locking file for writing. Closing appender.");
- $this->closed = true;
- }
- }
-
- public function activateOptions() {
- parent::activateOptions();
-
- if ($this->compress && !extension_loaded('zlib')) {
- $this->warn("The 'zlib' extension is required for file compression. Disabling compression.");
- $this->compression = false;
- }
- }
-
- /**
- * Set the 'maxBackupIndex' parameter.
- * @param integer $maxBackupIndex
- */
- public function setMaxBackupIndex($maxBackupIndex) {
- $this->setPositiveInteger('maxBackupIndex', $maxBackupIndex);
- }
-
- /**
- * Returns the 'maxBackupIndex' parameter.
- * @return integer
- */
- public function getMaxBackupIndex() {
- return $this->maxBackupIndex;
- }
-
- /**
- * Set the 'maxFileSize' parameter.
- * @param mixed $maxFileSize
- */
- public function setMaxFileSize($maxFileSize) {
- $this->setFileSize('maxFileSize', $maxFileSize);
- }
-
- /**
- * Returns the 'maxFileSize' parameter.
- * @return integer
- */
- public function getMaxFileSize() {
- return $this->maxFileSize;
- }
-
- /**
- * Set the 'maxFileSize' parameter (kept for backward compatibility).
- * @param mixed $maxFileSize
- * @deprecated Use setMaxFileSize() instead.
- */
- public function setMaximumFileSize($maxFileSize) {
- $this->warn("The 'maximumFileSize' parameter is deprecated. Use 'maxFileSize' instead.");
- return $this->setMaxFileSize($maxFileSize);
- }
-
- /**
- * Sets the 'compress' parameter.
- * @param boolean $compress
- */
- public function setCompress($compress) {
- $this->setBoolean('compress', $compress);
- }
-
- /**
- * Returns the 'compress' parameter.
- * @param boolean
- */
- public function getCompress() {
- return $this->compress;
- }
+class RollingFileAppender extends FileAppender
+{
+ /** Compressing backup files is done in chunks, this determines how large. */
+ const COMPRESS_CHUNK_SIZE = 102400; // 100KB
+
+ /**
+ * The maximum size (in bytes) that the output file is allowed to reach
+ * before being rolled over to backup files.
+ *
+ * The default maximum file size is 10MB (10485760 bytes). Maximum value
+ * for this option may depend on the file system.
+ *
+ * @var integer
+ */
+ protected $maxFileSize = 10485760;
+
+ /**
+ * Set the maximum number of backup files to keep around.
+ *
+ * Determines how many backup files are kept before the oldest is erased.
+ * This option takes a positive integer value. If set to zero, then there
+ * will be no backup files and the log file will be truncated when it
+ * reaches <var>maxFileSize</var>.
+ *
+ * There is one backup file by default.
+ *
+ * @var integer
+ */
+ protected $maxBackupIndex = 1;
+
+ /**
+ * The <var>compress</var> parameter determindes the compression with zlib.
+ * If set to true, the rollover files are compressed and saved with the .gz extension.
+ * @var boolean
+ */
+ protected $compress = false;
+
+ /**
+ * Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
+ * supports conditional clearing of statistics.
+ * @var boolean
+ * @see http://php.net/manual/en/function.clearstatcache.php
+ */
+ private $clearConditional = false;
+
+ /**
+ * Get the maximum size that the output file is allowed to reach
+ * before being rolled over to backup files.
+ * @return integer
+ */
+ public function getMaximumFileSize()
+ {
+ return $this->maxFileSize;
+ }
+
+ public function __construct($name = '')
+ {
+ parent::__construct($name);
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+ $this->clearConditional = true;
+ }
+ }
+
+ /**
+ * Implements the usual roll over behaviour.
+ *
+ * If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
+ * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
+ *
+ * If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
+ *
+ * Rollover must be called while the file is locked so that it is safe for concurrent access.
+ *
+ * @throws LoggerException If any part of the rollover procedure fails.
+ */
+ private function rollOver()
+ {
+ // If maxBackups <= 0, then there is no file renaming to be done.
+ if ($this->maxBackupIndex > 0) {
+ // Delete the oldest file, to keep Windows happy.
+ $file = $this->file . '.' . $this->maxBackupIndex;
+
+ if (file_exists($file) && !unlink($file)) {
+ throw new LoggerException("Unable to delete oldest backup file from [$file].");
+ }
+
+ // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
+ $this->renameArchievedLogs($this->file);
+
+ // Backup the active file
+ $this->moveToBackup($this->file);
+ }
+
+ // Truncate the active file
+ ftruncate($this->fp, 0);
+ rewind($this->fp);
+ }
+
+ private function moveToBackup($source)
+ {
+ if ($this->compress) {
+ $target = $source . '.1.gz';
+ $this->compressFile($source, $target);
+ } else {
+ $target = $source . '.1';
+ copy($source, $target);
+ }
+ }
+
+ private function compressFile($source, $target)
+ {
+ $target = 'compress.zlib://' . $target;
+
+ $fin = fopen($source, 'rb');
+ if ($fin === false) {
+ throw new LoggerException("Unable to open file for reading: [$source].");
+ }
+
+ $fout = fopen($target, 'wb');
+ if ($fout === false) {
+ throw new LoggerException("Unable to open file for writing: [$target].");
+ }
+
+ while (!feof($fin)) {
+ $chunk = fread($fin, self::COMPRESS_CHUNK_SIZE);
+ if (false === fwrite($fout, $chunk)) {
+ throw new LoggerException("Failed writing to compressed file.");
+ }
+ }
+
+ fclose($fin);
+ fclose($fout);
+ }
+
+ private function renameArchievedLogs($fileName)
+ {
+ for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
+
+ $source = $fileName . "." . $i;
+ if ($this->compress) {
+ $source .= '.gz';
+ }
+
+ if (file_exists($source)) {
+ $target = $fileName . '.' . ($i + 1);
+ if ($this->compress) {
+ $target .= '.gz';
+ }
+
+ rename($source, $target);
+ }
+ }
+ }
+
+ /**
+ * Writes a string to the target file. Opens file if not already open.
+ * @param string $string Data to write.
+ */
+ protected function write($string)
+ {
+ // Lazy file open
+ if (!isset($this->fp)) {
+ if ($this->openFile() === false) {
+ return; // Do not write if file open failed.
+ }
+ }
+
+ // Lock the file while writing and possible rolling over
+ if (flock($this->fp, LOCK_EX)) {
+
+ // Write to locked file
+ if (fwrite($this->fp, $string) === false) {
+ $this->warn("Failed writing to file. Closing appender.");
+ $this->closed = true;
+ }
+
+ // Stats cache must be cleared, otherwise filesize() returns cached results
+ // If supported (PHP 5.3+), clear only the state cache for the target file
+ if ($this->clearConditional) {
+ clearstatcache(true, $this->file);
+ } else {
+ clearstatcache();
+ }
+
+ // Rollover if needed
+ if (filesize($this->file) > $this->maxFileSize) {
+ try {
+ $this->rollOver();
+ } catch (LoggerException $ex) {
+ $this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ flock($this->fp, LOCK_UN);
+ } else {
+ $this->warn("Failed locking file for writing. Closing appender.");
+ $this->closed = true;
+ }
+ }
+
+ public function activateOptions()
+ {
+ parent::activateOptions();
+
+ if ($this->compress && !extension_loaded('zlib')) {
+ $this->warn("The 'zlib' extension is required for file compression. Disabling compression.");
+ $this->compression = false;
+ }
+ }
+
+ /**
+ * Set the 'maxBackupIndex' parameter.
+ * @param integer $maxBackupIndex
+ */
+ public function setMaxBackupIndex($maxBackupIndex)
+ {
+ $this->setPositiveInteger('maxBackupIndex', $maxBackupIndex);
+ }
+
+ /**
+ * Returns the 'maxBackupIndex' parameter.
+ * @return integer
+ */
+ public function getMaxBackupIndex()
+ {
+ return $this->maxBackupIndex;
+ }
+
+ /**
+ * Set the 'maxFileSize' parameter.
+ * @param mixed $maxFileSize
+ */
+ public function setMaxFileSize($maxFileSize)
+ {
+ $this->setFileSize('maxFileSize', $maxFileSize);
+ }
+
+ /**
+ * Returns the 'maxFileSize' parameter.
+ * @return integer
+ */
+ public function getMaxFileSize()
+ {
+ return $this->maxFileSize;
+ }
+
+ /**
+ * Set the 'maxFileSize' parameter (kept for backward compatibility).
+ * @param mixed $maxFileSize
+ * @deprecated Use setMaxFileSize() instead.
+ */
+ public function setMaximumFileSize($maxFileSize)
+ {
+ $this->warn("The 'maximumFileSize' parameter is deprecated. Use 'maxFileSize' instead.");
+
+ return $this->setMaxFileSize($maxFileSize);
+ }
+
+ /**
+ * Sets the 'compress' parameter.
+ * @param boolean $compress
+ */
+ public function setCompress($compress)
+ {
+ $this->setBoolean('compress', $compress);
+ }
+
+ /**
+ * Returns the 'compress' parameter.
+ * @param boolean
+ */
+ public function getCompress()
+ {
+ return $this->compress;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/SocketAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/SocketAppender.php b/src/Appenders/SocketAppender.php
index 024c91f..4f8325b 100644
--- a/src/Appenders/SocketAppender.php
+++ b/src/Appenders/SocketAppender.php
@@ -35,89 +35,100 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/socket.html Appender documentation
*/
-class SocketAppender extends AbstractAppender {
-
- /**
- * Target host.
- * @see http://php.net/manual/en/function.fsockopen.php
- */
- protected $remoteHost;
-
- /** Target port */
- protected $port = 4446;
-
- /** Connection timeout in ms. */
- protected $timeout;
-
- // ******************************************
- // *** Appender methods ***
- // ******************************************
-
- /** Override the default layout to use serialized. */
- public function getDefaultLayout() {
- return new SerializedLayout();
- }
-
- public function activateOptions() {
- if (empty($this->remoteHost)) {
- $this->warn("Required parameter [remoteHost] not set. Closing appender.");
- $this->closed = true;
- return;
- }
-
- if (empty($this->timeout)) {
- $this->timeout = ini_get("default_socket_timeout");
- }
-
- $this->closed = false;
- }
-
- public function append(LoggingEvent $event) {
- $socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
- if ($socket === false) {
- $this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
- $this->closed = true;
- return;
- }
-
- if (false === fwrite($socket, $this->layout->format($event))) {
- $this->warn("Error writing to socket. Closing appender.");
- $this->closed = true;
- }
- fclose($socket);
- }
-
- // ******************************************
- // *** Accessor methods ***
- // ******************************************
-
- /** Sets the target host. */
- public function setRemoteHost($hostname) {
- $this->setString('remoteHost', $hostname);
- }
-
- /** Sets the target port */
- public function setPort($port) {
- $this->setPositiveInteger('port', $port);
- }
-
- /** Sets the timeout. */
- public function setTimeout($timeout) {
- $this->setPositiveInteger('timeout', $timeout);
- }
-
- /** Returns the target host. */
- public function getRemoteHost() {
- return $this->getRemoteHost();
- }
-
- /** Returns the target port. */
- public function getPort() {
- return $this->port;
- }
-
- /** Returns the timeout */
- public function getTimeout() {
- return $this->timeout;
- }
+class SocketAppender extends AbstractAppender
+{
+ /**
+ * Target host.
+ * @see http://php.net/manual/en/function.fsockopen.php
+ */
+ protected $remoteHost;
+
+ /** Target port */
+ protected $port = 4446;
+
+ /** Connection timeout in ms. */
+ protected $timeout;
+
+ // ******************************************
+ // *** Appender methods ***
+ // ******************************************
+
+ /** Override the default layout to use serialized. */
+ public function getDefaultLayout()
+ {
+ return new SerializedLayout();
+ }
+
+ public function activateOptions()
+ {
+ if (empty($this->remoteHost)) {
+ $this->warn("Required parameter [remoteHost] not set. Closing appender.");
+ $this->closed = true;
+
+ return;
+ }
+
+ if (empty($this->timeout)) {
+ $this->timeout = ini_get("default_socket_timeout");
+ }
+
+ $this->closed = false;
+ }
+
+ public function append(LoggingEvent $event)
+ {
+ $socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
+ if ($socket === false) {
+ $this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
+ $this->closed = true;
+
+ return;
+ }
+
+ if (false === fwrite($socket, $this->layout->format($event))) {
+ $this->warn("Error writing to socket. Closing appender.");
+ $this->closed = true;
+ }
+ fclose($socket);
+ }
+
+ // ******************************************
+ // *** Accessor methods ***
+ // ******************************************
+
+ /** Sets the target host. */
+ public function setRemoteHost($hostname)
+ {
+ $this->setString('remoteHost', $hostname);
+ }
+
+ /** Sets the target port */
+ public function setPort($port)
+ {
+ $this->setPositiveInteger('port', $port);
+ }
+
+ /** Sets the timeout. */
+ public function setTimeout($timeout)
+ {
+ $this->setPositiveInteger('timeout', $timeout);
+ }
+
+ /** Returns the target host. */
+ public function getRemoteHost()
+ {
+ return $this->getRemoteHost();
+ }
+
+ /** Returns the target port. */
+ public function getPort()
+ {
+ return $this->port;
+ }
+
+ /** Returns the timeout */
+ public function getTimeout()
+ {
+ return $this->timeout;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Appenders/SyslogAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/SyslogAppender.php b/src/Appenders/SyslogAppender.php
index ae7351b..b6fc0c0 100644
--- a/src/Appenders/SyslogAppender.php
+++ b/src/Appenders/SyslogAppender.php
@@ -70,235 +70,253 @@ use Apache\Log4php\LoggingEvent;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @link http://logging.apache.org/log4php/docs/appenders/syslog.html Appender documentation
*/
-class SyslogAppender extends AbstractAppender {
-
- /**
- * The ident string is added to each message. Typically the name of your application.
- *
- * @var string
- */
- protected $ident = "Apache log4php";
-
- /**
- * The syslog priority to use when overriding priority. This setting is
- * required if {@link overridePriority} is set to true.
- *
- * @var string
- */
- protected $priority;
-
- /**
- * The option used when opening the syslog connection.
- *
- * @var string
- */
- protected $option = 'PID|CONS';
-
- /**
- * The facility value indicates the source of the message.
- *
- * @var string
- */
- protected $facility = 'USER';
-
- /**
- * If set to true, the message priority will always use the value defined
- * in {@link $priority}, otherwise the priority will be determined by the
- * message's log level.
- *
- * @var string
- */
- protected $overridePriority = false;
-
- /**
- * Holds the int value of the {@link $priority}.
- * @var int
- */
- private $intPriority;
-
- /**
- * Holds the int value of the {@link $facility}.
- * @var int
- */
- private $intFacility;
-
- /**
- * Holds the int value of the {@link $option}.
- * @var int
- */
- private $intOption;
-
- /**
- * Sets the {@link $ident}.
- *
- * @param string $ident
- */
- public function setIdent($ident) {
- $this->ident = $ident;
- }
-
- /**
- * Sets the {@link $priority}.
- *
- * @param string $priority
- */
- public function setPriority($priority) {
- $this->priority = $priority;
- }
-
- /**
- * Sets the {@link $facility}.
- *
- * @param string $facility
- */
- public function setFacility($facility) {
- $this->facility = $facility;
- }
-
- /**
- * Sets the {@link $overridePriority}.
- *
- * @param string $overridePriority
- */
- public function setOverridePriority($overridePriority) {
- $this->overridePriority = $overridePriority;
- }
-
- /**
- * Sets the 'option' parameter.
- *
- * @param string $option
- */
- public function setOption($option) {
- $this->option = $option;
- }
-
- /**
- * Returns the 'ident' parameter.
- *
- * @return string $ident
- */
- public function getIdent() {
- return $this->ident;
- }
-
- /**
- * Returns the 'priority' parameter.
- *
- * @return string
- */
- public function getPriority() {
- return $this->priority;
- }
-
- /**
- * Returns the 'facility' parameter.
- *
- * @return string
- */
- public function getFacility() {
- return $this->facility;
- }
-
- /**
- * Returns the 'overridePriority' parameter.
- *
- * @return string
- */
- public function getOverridePriority() {
- return $this->overridePriority;
- }
-
- /**
- * Returns the 'option' parameter.
- *
- * @return string
- */
- public function getOption() {
- return $this->option;
- }
-
-
- public function activateOptions() {
- $this->intPriority = $this->parsePriority();
- $this->intOption = $this->parseOption();
- $this->intFacility = $this->parseFacility();
-
- $this->closed = false;
- }
-
- public function close() {
- if($this->closed != true) {
- closelog();
- $this->closed = true;
- }
- }
-
- /**
- * Appends the event to syslog.
- *
- * Log is opened and closed each time because if it is not closed, it
- * can cause the Apache httpd server to log to whatever ident/facility
- * was used in openlog().
- *
- * @see http://www.php.net/manual/en/function.syslog.php#97843
- */
- public function append(LoggingEvent $event) {
- $priority = $this->getSyslogPriority($event->getLevel());
- $message = $this->layout->format($event);
-
- openlog($this->ident, $this->intOption, $this->intFacility);
- syslog($priority, $message);
- closelog();
- }
-
- /** Determines which syslog priority to use based on the given level. */
- private function getSyslogPriority(Level $level) {
- if($this->overridePriority) {
- return $this->intPriority;
- }
- return $level->getSyslogEquivalent();
- }
-
- /** Parses a syslog option string and returns the correspodning int value. */
- private function parseOption() {
- $value = 0;
- $options = explode('|', $this->option);
-
- foreach($options as $option) {
- if (!empty($option)) {
- $constant = "LOG_" . trim($option);
- if (defined($constant)) {
- $value |= constant($constant);
- } else {
- trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING);
- }
- }
- }
- return $value;
- }
-
- /** Parses the facility string and returns the corresponding int value. */
- private function parseFacility() {
- if (!empty($this->facility)) {
- $constant = "LOG_" . trim($this->facility);
- if (defined($constant)) {
- return constant($constant);
- } else {
- trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING);
- }
- }
- }
-
- /** Parses the priority string and returns the corresponding int value. */
- private function parsePriority() {
- if (!empty($this->priority)) {
- $constant = "LOG_" . trim($this->priority);
- if (defined($constant)) {
- return constant($constant);
- } else {
- trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING);
- }
- }
- }
+class SyslogAppender extends AbstractAppender
+{
+ /**
+ * The ident string is added to each message. Typically the name of your application.
+ *
+ * @var string
+ */
+ protected $ident = "Apache log4php";
+
+ /**
+ * The syslog priority to use when overriding priority. This setting is
+ * required if {@link overridePriority} is set to true.
+ *
+ * @var string
+ */
+ protected $priority;
+
+ /**
+ * The option used when opening the syslog connection.
+ *
+ * @var string
+ */
+ protected $option = 'PID|CONS';
+
+ /**
+ * The facility value indicates the source of the message.
+ *
+ * @var string
+ */
+ protected $facility = 'USER';
+
+ /**
+ * If set to true, the message priority will always use the value defined
+ * in {@link $priority}, otherwise the priority will be determined by the
+ * message's log level.
+ *
+ * @var string
+ */
+ protected $overridePriority = false;
+
+ /**
+ * Holds the int value of the {@link $priority}.
+ * @var int
+ */
+ private $intPriority;
+
+ /**
+ * Holds the int value of the {@link $facility}.
+ * @var int
+ */
+ private $intFacility;
+
+ /**
+ * Holds the int value of the {@link $option}.
+ * @var int
+ */
+ private $intOption;
+
+ /**
+ * Sets the {@link $ident}.
+ *
+ * @param string $ident
+ */
+ public function setIdent($ident)
+ {
+ $this->ident = $ident;
+ }
+
+ /**
+ * Sets the {@link $priority}.
+ *
+ * @param string $priority
+ */
+ public function setPriority($priority)
+ {
+ $this->priority = $priority;
+ }
+
+ /**
+ * Sets the {@link $facility}.
+ *
+ * @param string $facility
+ */
+ public function setFacility($facility)
+ {
+ $this->facility = $facility;
+ }
+
+ /**
+ * Sets the {@link $overridePriority}.
+ *
+ * @param string $overridePriority
+ */
+ public function setOverridePriority($overridePriority)
+ {
+ $this->overridePriority = $overridePriority;
+ }
+
+ /**
+ * Sets the 'option' parameter.
+ *
+ * @param string $option
+ */
+ public function setOption($option)
+ {
+ $this->option = $option;
+ }
+
+ /**
+ * Returns the 'ident' parameter.
+ *
+ * @return string $ident
+ */
+ public function getIdent()
+ {
+ return $this->ident;
+ }
+
+ /**
+ * Returns the 'priority' parameter.
+ *
+ * @return string
+ */
+ public function getPriority()
+ {
+ return $this->priority;
+ }
+
+ /**
+ * Returns the 'facility' parameter.
+ *
+ * @return string
+ */
+ public function getFacility()
+ {
+ return $this->facility;
+ }
+
+ /**
+ * Returns the 'overridePriority' parameter.
+ *
+ * @return string
+ */
+ public function getOverridePriority()
+ {
+ return $this->overridePriority;
+ }
+
+ /**
+ * Returns the 'option' parameter.
+ *
+ * @return string
+ */
+ public function getOption()
+ {
+ return $this->option;
+ }
+
+ public function activateOptions()
+ {
+ $this->intPriority = $this->parsePriority();
+ $this->intOption = $this->parseOption();
+ $this->intFacility = $this->parseFacility();
+
+ $this->closed = false;
+ }
+
+ public function close()
+ {
+ if ($this->closed != true) {
+ closelog();
+ $this->closed = true;
+ }
+ }
+
+ /**
+ * Appends the event to syslog.
+ *
+ * Log is opened and closed each time because if it is not closed, it
+ * can cause the Apache httpd server to log to whatever ident/facility
+ * was used in openlog().
+ *
+ * @see http://www.php.net/manual/en/function.syslog.php#97843
+ */
+ public function append(LoggingEvent $event)
+ {
+ $priority = $this->getSyslogPriority($event->getLevel());
+ $message = $this->layout->format($event);
+
+ openlog($this->ident, $this->intOption, $this->intFacility);
+ syslog($priority, $message);
+ closelog();
+ }
+
+ /** Determines which syslog priority to use based on the given level. */
+ private function getSyslogPriority(Level $level)
+ {
+ if ($this->overridePriority) {
+ return $this->intPriority;
+ }
+
+ return $level->getSyslogEquivalent();
+ }
+
+ /** Parses a syslog option string and returns the correspodning int value. */
+ private function parseOption()
+ {
+ $value = 0;
+ $options = explode('|', $this->option);
+
+ foreach ($options as $option) {
+ if (!empty($option)) {
+ $constant = "LOG_" . trim($option);
+ if (defined($constant)) {
+ $value |= constant($constant);
+ } else {
+ trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING);
+ }
+ }
+ }
+
+ return $value;
+ }
+
+ /** Parses the facility string and returns the corresponding int value. */
+ private function parseFacility()
+ {
+ if (!empty($this->facility)) {
+ $constant = "LOG_" . trim($this->facility);
+ if (defined($constant)) {
+ return constant($constant);
+ } else {
+ trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING);
+ }
+ }
+ }
+
+ /** Parses the priority string and returns the corresponding int value. */
+ private function parsePriority()
+ {
+ if (!empty($this->priority)) {
+ $constant = "LOG_" . trim($this->priority);
+ if (defined($constant)) {
+ return constant($constant);
+ } else {
+ trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Autoloader.php
----------------------------------------------------------------------
diff --git a/src/Autoloader.php b/src/Autoloader.php
index fe6b8d3..d4fc666 100644
--- a/src/Autoloader.php
+++ b/src/Autoloader.php
@@ -23,31 +23,31 @@ namespace Apache\Log4php;
*/
class Autoloader
{
- const BASE_NAMESPACE = 'Apache\\Log4php\\';
+ const BASE_NAMESPACE = 'Apache\\Log4php\\';
- public function autoload($class)
- {
- // Base directory for the namespace prefix
- $baseDir = __DIR__ . '/../src/';
+ public function autoload($class)
+ {
+ // Base directory for the namespace prefix
+ $baseDir = __DIR__ . '/../src/';
- // Skip classes which are not in base namespace
- $len = strlen(self::BASE_NAMESPACE);
- if (strncmp(self::BASE_NAMESPACE, $class, $len) !== 0) {
- return;
- }
+ // Skip classes which are not in base namespace
+ $len = strlen(self::BASE_NAMESPACE);
+ if (strncmp(self::BASE_NAMESPACE, $class, $len) !== 0) {
+ return;
+ }
- // Locate the class in base dir, based on namespace
- $classPath = str_replace('\\', '/', substr($class, $len));
- $file = $baseDir . $classPath . '.php';
+ // Locate the class in base dir, based on namespace
+ $classPath = str_replace('\\', '/', substr($class, $len));
+ $file = $baseDir . $classPath . '.php';
- // If the file exists, require it
- if (file_exists($file)) {
- require $file;
- }
- }
+ // If the file exists, require it
+ if (file_exists($file)) {
+ require $file;
+ }
+ }
- public function register()
- {
- spl_autoload_register(array($this, 'autoload'));
- }
+ public function register()
+ {
+ spl_autoload_register(array($this, 'autoload'));
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configurable.php
----------------------------------------------------------------------
diff --git a/src/Configurable.php b/src/Configurable.php
index 352aa23..258e6ec 100644
--- a/src/Configurable.php
+++ b/src/Configurable.php
@@ -29,90 +29,98 @@ use Exception;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.2
*/
-abstract class Configurable {
+abstract class Configurable
+{
+ /** Setter function for boolean type. */
+ protected function setBoolean($property, $value)
+ {
+ try {
+ $this->$property = OptionConverter::toBooleanEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
+ }
+ }
- /** Setter function for boolean type. */
- protected function setBoolean($property, $value) {
- try {
- $this->$property = OptionConverter::toBooleanEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
- }
- }
+ /** Setter function for integer type. */
+ protected function setInteger($property, $value)
+ {
+ try {
+ $this->$property = OptionConverter::toIntegerEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed.");
+ }
+ }
- /** Setter function for integer type. */
- protected function setInteger($property, $value) {
- try {
- $this->$property = OptionConverter::toIntegerEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed.");
- }
- }
+ /** Setter function for Level values. */
+ protected function setLevel($property, $value)
+ {
+ try {
+ $this->$property = OptionConverter::toLevelEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
+ }
+ }
- /** Setter function for Level values. */
- protected function setLevel($property, $value) {
- try {
- $this->$property = OptionConverter::toLevelEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
- }
- }
+ /** Setter function for integer type. */
+ protected function setPositiveInteger($property, $value)
+ {
+ try {
+ $this->$property = OptionConverter::toPositiveIntegerEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed.");
+ }
+ }
- /** Setter function for integer type. */
- protected function setPositiveInteger($property, $value) {
- try {
- $this->$property = OptionConverter::toPositiveIntegerEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed.");
- }
- }
+ /** Setter for file size. */
+ protected function setFileSize($property, $value)
+ {
+ try {
+ $this->$property = OptionConverter::toFileSizeEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
+ }
+ }
- /** Setter for file size. */
- protected function setFileSize($property, $value) {
- try {
- $this->$property = OptionConverter::toFileSizeEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
- }
- }
+ /** Setter function for numeric type. */
+ protected function setNumeric($property, $value)
+ {
+ try {
+ $this->$property = OptionConverter::toNumericEx($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
+ }
+ }
- /** Setter function for numeric type. */
- protected function setNumeric($property, $value) {
- try {
- $this->$property = OptionConverter::toNumericEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
- }
- }
+ /** Setter function for string type. */
+ protected function setString($property, $value, $nullable = false)
+ {
+ if ($value === null) {
+ if ($nullable) {
+ $this->$property= null;
+ } else {
+ $this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
+ }
+ } else {
+ try {
+ $value = OptionConverter::toStringEx($value);
+ $this->$property = OptionConverter::substConstants($value);
+ } catch (Exception $ex) {
+ $value = var_export($value, true);
+ $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
+ }
+ }
+ }
- /** Setter function for string type. */
- protected function setString($property, $value, $nullable = false) {
- if ($value === null) {
- if($nullable) {
- $this->$property= null;
- } else {
- $this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
- }
- } else {
- try {
- $value = OptionConverter::toStringEx($value);
- $this->$property = OptionConverter::substConstants($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
- }
- }
- }
-
- /** Triggers a warning. */
- protected function warn($message) {
- $class = get_class($this);
- trigger_error("log4php: $class: $message", E_USER_WARNING);
- }
+ /** Triggers a warning. */
+ protected function warn($message)
+ {
+ $class = get_class($this);
+ trigger_error("log4php: $class: $message", E_USER_WARNING);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configuration/ConfiguratorInterface.php
----------------------------------------------------------------------
diff --git a/src/Configuration/ConfiguratorInterface.php b/src/Configuration/ConfiguratorInterface.php
index a4a8e21..f58fc41 100644
--- a/src/Configuration/ConfiguratorInterface.php
+++ b/src/Configuration/ConfiguratorInterface.php
@@ -27,15 +27,15 @@ use Apache\Log4php\Hierarchy;
*/
interface ConfiguratorInterface
{
- /**
- * Configures log4php based on the given configuration.
- *
- * All configurators implementations must implement this interface.
- *
- * @param Hierarchy $hierarchy The hierarchy on which to perform
- * the configuration.
- * @param mixed $input Either path to the config file or the
- * configuration as an array.
- */
- public function configure(Hierarchy $hierarchy, $input = null);
-}
\ No newline at end of file
+ /**
+ * Configures log4php based on the given configuration.
+ *
+ * All configurators implementations must implement this interface.
+ *
+ * @param Hierarchy $hierarchy The hierarchy on which to perform
+ * the configuration.
+ * @param mixed $input Either path to the config file or the
+ * configuration as an array.
+ */
+ public function configure(Hierarchy $hierarchy, $input = null);
+}
[19/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/filters/LoggerFilterLevelMatch.php
----------------------------------------------------------------------
diff --git a/src/main/php/filters/LoggerFilterLevelMatch.php b/src/main/php/filters/LoggerFilterLevelMatch.php
deleted file mode 100644
index cbd8950..0000000
--- a/src/main/php/filters/LoggerFilterLevelMatch.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This is a very simple filter based on level matching.
- *
- * <p>The filter admits two options <b><var>LevelToMatch</var></b> and
- * <b><var>AcceptOnMatch</var></b>. If there is an exact match between the value
- * of the <b><var>LevelToMatch</var></b> option and the level of the
- * {@link LoggerLoggingEvent}, then the {@link decide()} method returns
- * {@link LoggerFilter::ACCEPT} in case the <b><var>AcceptOnMatch</var></b>
- * option value is set to <i>true</i>, if it is <i>false</i> then
- * {@link LoggerFilter::DENY} is returned. If there is no match,
- * {@link LoggerFilter::NEUTRAL} is returned.</p>
- *
- * <p>
- * An example for this filter:
- *
- * {@example ../../examples/php/filter_levelmatch.php 19}
- *
- * <p>
- * The corresponding XML file:
- *
- * {@example ../../examples/resources/filter_levelmatch.xml 18}
- *
- * @version $Revision$
- * @package log4php
- * @subpackage filters
- * @since 0.6
- */
-class LoggerFilterLevelMatch extends LoggerFilter {
-
- /**
- * Indicates if this event should be accepted or denied on match
- * @var boolean
- */
- protected $acceptOnMatch = true;
-
- /**
- * The level, when to match
- * @var LoggerLevel
- */
- protected $levelToMatch;
-
- /**
- * @param boolean $acceptOnMatch
- */
- public function setAcceptOnMatch($acceptOnMatch) {
- $this->setBoolean('acceptOnMatch', $acceptOnMatch);
- }
-
- /**
- * @param string $l the level to match
- */
- public function setLevelToMatch($level) {
- $this->setLevel('levelToMatch', $level);
- }
-
- /**
- * 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;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/filters/LoggerFilterLevelRange.php
----------------------------------------------------------------------
diff --git a/src/main/php/filters/LoggerFilterLevelRange.php b/src/main/php/filters/LoggerFilterLevelRange.php
deleted file mode 100644
index ff22b07..0000000
--- a/src/main/php/filters/LoggerFilterLevelRange.php
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This is a very simple filter based on level matching, which can be
- * used to reject messages with priorities outside a certain range.
- *
- * <p>The filter admits three options <b><var>LevelMin</var></b>, <b><var>LevelMax</var></b>
- * and <b><var>AcceptOnMatch</var></b>.</p>
- *
- * <p>If the level of the {@link LoggerLoggingEvent} is not between Min and Max
- * (inclusive), then {@link LoggerFilter::DENY} is returned.</p>
- *
- * <p>If the Logging event level is within the specified range, then if
- * <b><var>AcceptOnMatch</var></b> is <i>true</i>,
- * {@link LoggerFilter::ACCEPT} is returned, and if
- * <b><var>AcceptOnMatch</var></b> is <i>false</i>,
- * {@link LoggerFilter::NEUTRAL} is returned.</p>
- *
- * <p>If <b><var>LevelMin</var></b> is not defined, then there is no
- * minimum acceptable level (i.e. a level is never rejected for
- * being too "low"/unimportant). If <b><var>LevelMax</var></b> is not
- * defined, then there is no maximum acceptable level (ie a
- * level is never rejected for being too "high"/important).</p>
- *
- * <p>Refer to the {@link LoggerAppender::setThreshold()} method
- * available to <b>all</b> appenders extending {@link LoggerAppender}
- * for a more convenient way to filter out events by level.</p>
- *
- * <p>
- * An example for this filter:
- *
- * {@example ../../examples/php/filter_levelrange.php 19}
- *
- * <p>
- * The corresponding XML file:
- *
- * {@example ../../examples/resources/filter_levelrange.xml 18}
- *
- * @author Simon Kitching
- * @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
- *
- * @version $Revision$
- * @package log4php
- * @subpackage filters
- * @since 0.6
- */
-class LoggerFilterLevelRange extends LoggerFilter {
-
- /**
- * @var boolean
- */
- protected $acceptOnMatch = true;
-
- /**
- * @var LoggerLevel
- */
- protected $levelMin;
-
- /**
- * @var LoggerLevel
- */
- protected $levelMax;
-
- /**
- * @param boolean $acceptOnMatch
- */
- public function setAcceptOnMatch($acceptOnMatch) {
- $this->setBoolean('acceptOnMatch', $acceptOnMatch);
- }
-
- /**
- * @param string $l the level min to match
- */
- public function setLevelMin($level) {
- $this->setLevel('levelMin', $level);
- }
-
- /**
- * @param string $l the level max to match
- */
- public function setLevelMax($level) {
- $this->setLevel('levelMax', $level);
- }
-
- /**
- * Return the decision of this filter.
- *
- * @param LoggerLoggingEvent $event
- * @return integer
- */
- public function decide(LoggerLoggingEvent $event) {
- $level = $event->getLevel();
-
- if($this->levelMin !== null) {
- if($level->isGreaterOrEqual($this->levelMin) == false) {
- // level of event is less than minimum
- return LoggerFilter::DENY;
- }
- }
-
- if($this->levelMax !== null) {
- if($level->toInt() > $this->levelMax->toInt()) {
- // level of event is greater than maximum
- // Alas, there is no Level.isGreater method. and using
- // a combo of isGreaterOrEqual && !Equal seems worse than
- // checking the int values of the level objects..
- return LoggerFilter::DENY;
- }
- }
-
- if($this->acceptOnMatch) {
- // this filter set up to bypass later filters and always return
- // accept if level in range
- return LoggerFilter::ACCEPT;
- } else {
- // event is ok for this filter; allow later filters to have a look..
- return LoggerFilter::NEUTRAL;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/filters/LoggerFilterStringMatch.php
----------------------------------------------------------------------
diff --git a/src/main/php/filters/LoggerFilterStringMatch.php b/src/main/php/filters/LoggerFilterStringMatch.php
deleted file mode 100644
index 746f84d..0000000
--- a/src/main/php/filters/LoggerFilterStringMatch.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This is a very simple filter based on string matching.
- *
- * <p>The filter admits two options {@link $stringToMatch} and
- * {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos}
- * between the value of the {@link $stringToMatch} option and the message
- * of the {@link LoggerLoggingEvent},
- * then the {@link decide()} method returns {@link LoggerFilter::ACCEPT} if
- * the <b>AcceptOnMatch</b> option value is true, if it is false then
- * {@link LoggerFilter::DENY} is returned. If there is no match, {@link LoggerFilter::NEUTRAL}
- * is returned.</p>
- *
- * <p>
- * An example for this filter:
- *
- * {@example ../../examples/php/filter_stringmatch.php 19}
- *
- * <p>
- * The corresponding XML file:
- *
- * {@example ../../examples/resources/filter_stringmatch.xml 18}
- *
- * @version $Revision$
- * @package log4php
- * @subpackage filters
- * @since 0.3
- */
-class LoggerFilterStringMatch extends LoggerFilter {
-
- /**
- * @var boolean
- */
- protected $acceptOnMatch = true;
-
- /**
- * @var string
- */
- protected $stringToMatch;
-
- /**
- * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
- */
- public function setAcceptOnMatch($acceptOnMatch) {
- $this->setBoolean('acceptOnMatch', $acceptOnMatch);
- }
-
- /**
- * @param string $s the string to match
- */
- public function setStringToMatch($string) {
- $this->setString('stringToMatch', $string);
- }
-
- /**
- * @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;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/helpers/LoggerFormattingInfo.php
----------------------------------------------------------------------
diff --git a/src/main/php/helpers/LoggerFormattingInfo.php b/src/main/php/helpers/LoggerFormattingInfo.php
deleted file mode 100644
index a8a54a6..0000000
--- a/src/main/php/helpers/LoggerFormattingInfo.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This class encapsulates the information obtained when parsing
- * formatting modifiers in conversion modifiers.
- *
- * @package log4php
- * @subpackage helpers
- * @since 0.3
- */
-class LoggerFormattingInfo {
-
- /**
- * Minimal output length. If output is shorter than this value, it will be
- * padded with spaces.
- */
- public $min = 0;
-
- /**
- * Maximum output length. If output is longer than this value, it will be
- * trimmed.
- */
- public $max = PHP_INT_MAX;
-
- /**
- * Whether to pad the string from the left. If set to false, the string
- * will be padded from the right.
- */
- public $padLeft = true;
-
- /**
- * Whether to trim the string from the left. If set to false, the string
- * will be trimmed from the right.
- */
- public $trimLeft = false;
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/helpers/LoggerOptionConverter.php
----------------------------------------------------------------------
diff --git a/src/main/php/helpers/LoggerOptionConverter.php b/src/main/php/helpers/LoggerOptionConverter.php
deleted file mode 100644
index a4ef554..0000000
--- a/src/main/php/helpers/LoggerOptionConverter.php
+++ /dev/null
@@ -1,226 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * A convenience class to convert property values to specific types.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage helpers
- * @since 0.5
- */
-class LoggerOptionConverter {
-
- /** String values which are converted to boolean TRUE. */
- private static $trueValues = array('1', 'true', 'yes', 'on');
-
- /**
- * String values which are converted to boolean FALSE.
- *
- * Note that an empty string must convert to false, because
- * parse_ini_file() which is used for parsing configuration
- * converts the value _false_ to an empty string.
- */
- private static $falseValues = array('0', 'false', 'no', 'off', '');
-
- /**
- * Read a predefined var.
- *
- * It returns a value referenced by <var>$key</var> using this search criteria:
- * - if <var>$key</var> is a constant then return it. Else
- * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
- * - return <var>$def</var>.
- *
- * @param string $key The key to search for.
- * @param string $def The default value to return.
- * @return string the string value of the system property, or the default
- * value if there is no property with that key.
- */
- public static function getSystemProperty($key, $def) {
- if(defined($key)) {
- return (string)constant($key);
- } else if(isset($_SERVER[$key])) {
- return (string)$_SERVER[$key];
- } else if(isset($_ENV[$key])) {
- return (string)$_ENV[$key];
- } else {
- return $def;
- }
- }
-
- /** Converts $value to boolean, or throws an exception if not possible. */
- public static function toBooleanEx($value) {
- if (isset($value)) {
- if (is_bool($value)) {
- return $value;
- }
- $value = strtolower(trim($value));
- if (in_array($value, self::$trueValues)) {
- return true;
- }
- if (in_array($value, self::$falseValues)) {
- return false;
- }
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
- }
-
- /**
- * Converts $value to integer, or throws an exception if not possible.
- * Floats cannot be converted to integer.
- */
- public static function toIntegerEx($value) {
- if (is_integer($value)) {
- return $value;
- }
- if (is_numeric($value) && ($value == (integer) $value)) {
- return (integer) $value;
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
- }
-
- /**
- * Converts $value to integer, or throws an exception if not possible.
- * Floats cannot be converted to integer.
- */
- public static function toPositiveIntegerEx($value) {
- if (is_integer($value) && $value > 0) {
- return $value;
- }
- if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
- return (integer) $value;
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
- }
-
- /** Converts the value to a level. Throws an exception if not possible. */
- public static function toLevelEx($value) {
- if ($value instanceof LoggerLevel) {
- return $value;
- }
- $level = LoggerLevel::toLevel($value);
- if ($level === null) {
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
- }
- return $level;
- }
-
- /**
- * Converts a value to a valid file size (integer).
- *
- * Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
- *
- * The final value will be rounded to the nearest integer.
- *
- * Examples:
- * - '100' => 100
- * - '100.12' => 100
- * - '100KB' => 102400
- * - '1.5MB' => 1572864
- *
- * @param mixed $value File size (optionally with suffix).
- * @return integer Parsed file size.
- */
- public static function toFileSizeEx($value) {
-
- if (empty($value)) {
- throw new LoggerException("Empty value cannot be converted to a file size.");
- }
-
- if (is_numeric($value)) {
- return (integer) $value;
- }
-
- if (!is_string($value)) {
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
- }
-
- $str = strtoupper(trim($value));
- $count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
-
- if ($count > 0) {
- $size = $matches[1];
- $unit = $matches[2];
-
- switch($unit) {
- case 'KB': $size *= pow(1024, 1); break;
- case 'MB': $size *= pow(1024, 2); break;
- case 'GB': $size *= pow(1024, 3); break;
- }
-
- return (integer) $size;
- }
-
- throw new LoggerException("Given value [$value] cannot be converted to a file size.");
- }
-
- /**
- * Converts a value to string, or throws an exception if not possible.
- *
- * Objects can be converted to string if they implement the magic
- * __toString() method.
- *
- */
- public static function toStringEx($value) {
- if (is_string($value)) {
- return $value;
- }
- if (is_numeric($value)) {
- return (string) $value;
- }
- if (is_object($value) && method_exists($value, '__toString')) {
- return (string) $value;
- }
-
- throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
- }
-
- /**
- * Performs value substitution for string options.
- *
- * An option can contain PHP constants delimited by '${' and '}'.
- *
- * E.g. for input string "some ${FOO} value", the method will attempt
- * to substitute ${FOO} with the value of constant FOO if it exists.
- *
- * Therefore, if FOO is a constant, and it has value "bar", the resulting
- * string will be "some bar value".
- *
- * If the constant is not defined, it will be replaced by an empty string,
- * and the resulting string will be "some value".
- *
- * @param string $string String on which to perform substitution.
- * @return string
- */
- public static function substConstants($string) {
- preg_match_all('/\${([^}]+)}/', $string, $matches);
-
- foreach($matches[1] as $key => $match) {
- $match = trim($match);
- $search = $matches[0][$key];
- $replacement = defined($match) ? constant($match) : '';
- $string = str_replace($search, $replacement, $string);
- }
- return $string;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/helpers/LoggerPatternParser.php
----------------------------------------------------------------------
diff --git a/src/main/php/helpers/LoggerPatternParser.php b/src/main/php/helpers/LoggerPatternParser.php
deleted file mode 100644
index a2ed911..0000000
--- a/src/main/php/helpers/LoggerPatternParser.php
+++ /dev/null
@@ -1,237 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Most of the work of the {@link LoggerPatternLayout} class
- * is delegated to the {@link LoggerPatternParser} class.
- *
- * <p>It is this class that parses conversion patterns and creates
- * a chained list of {@link LoggerPatternConverter} converters.</p>
- *
- * @version $Revision$
- * @package log4php
- * @subpackage helpers
- *
- * @since 0.3
- */
-class LoggerPatternParser {
-
- /** Escape character for conversion words in the conversion pattern. */
- const ESCAPE_CHAR = '%';
-
- /** Maps conversion words to relevant converters. */
- private $converterMap;
-
- /** Conversion pattern used in layout. */
- private $pattern;
-
- /** Regex pattern used for parsing the conversion pattern. */
- private $regex;
-
- /**
- * First converter in the chain.
- * @var LoggerPatternConverter
- */
- private $head;
-
- /** Last converter in the chain. */
- private $tail;
-
- public function __construct($pattern, $converterMap) {
- $this->pattern = $pattern;
- $this->converterMap = $converterMap;
-
- // Construct the regex pattern
- $this->regex =
- '/' . // Starting regex pattern delimiter
- self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern
- '(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
- '(?P<word>[a-zA-Z]+)' . // The conversion word
- '(?P<option>{[^}]*})?' . // Conversion option in braces (optional)
- '/'; // Ending regex pattern delimiter
- }
-
- /**
- * Parses the conversion pattern string, converts it to a chain of pattern
- * converters and returns the first converter in the chain.
- *
- * @return LoggerPatternConverter
- */
- public function parse() {
-
- // Skip parsing if the pattern is empty
- if (empty($this->pattern)) {
- $this->addLiteral('');
- return $this->head;
- }
-
- // Find all conversion words in the conversion pattern
- $count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
- if ($count === false) {
- $error = error_get_last();
- throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
- }
-
- $prevEnd = 0;
-
- foreach($matches[0] as $key => $item) {
-
- // Locate where the conversion command starts and ends
- $length = strlen($item[0]);
- $start = $item[1];
- $end = $item[1] + $length;
-
- // Find any literal expressions between matched commands
- if ($start > $prevEnd) {
- $literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
- $this->addLiteral($literal);
- }
-
- // Extract the data from the matched command
- $word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
- $modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
- $option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
-
- // Create a converter and add it to the chain
- $this->addConverter($word, $modifiers, $option);
-
- $prevEnd = $end;
- }
-
- // Add any trailing literals
- if ($end < strlen($this->pattern)) {
- $literal = substr($this->pattern, $end);
- $this->addLiteral($literal);
- }
-
- return $this->head;
- }
-
- /**
- * Adds a literal converter to the converter chain.
- * @param string $string The string for the literal converter.
- */
- private function addLiteral($string) {
- $converter = new LoggerPatternConverterLiteral($string);
- $this->addToChain($converter);
- }
-
- /**
- * Adds a non-literal converter to the converter chain.
- *
- * @param string $word The conversion word, used to determine which
- * converter will be used.
- * @param string $modifiers Formatting modifiers.
- * @param string $option Option to pass to the converter.
- */
- private function addConverter($word, $modifiers, $option) {
- $formattingInfo = $this->parseModifiers($modifiers);
- $option = trim($option, "{} ");
-
- if (isset($this->converterMap[$word])) {
- $converter = $this->getConverter($word, $formattingInfo, $option);
- $this->addToChain($converter);
- } else {
- trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
- }
- }
-
- /**
- * Determines which converter to use based on the conversion word. Creates
- * an instance of the converter using the provided formatting info and
- * option and returns it.
- *
- * @param string $word The conversion word.
- * @param LoggerFormattingInfo $info Formatting info.
- * @param string $option Converter option.
- *
- * @throws LoggerException
- *
- * @return LoggerPatternConverter
- */
- private function getConverter($word, $info, $option) {
- if (!isset($this->converterMap[$word])) {
- throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
- }
-
- $converterClass = $this->converterMap[$word];
- if(!class_exists($converterClass)) {
- throw new LoggerException("Class '$converterClass' does not exist.");
- }
-
- $converter = new $converterClass($info, $option);
- if(!($converter instanceof LoggerPatternConverter)) {
- throw new LoggerException("Class '$converterClass' is not an instance of LoggerPatternConverter.");
- }
-
- return $converter;
- }
-
- /** Adds a converter to the chain and updates $head and $tail pointers. */
- private function addToChain(LoggerPatternConverter $converter) {
- if (!isset($this->head)) {
- $this->head = $converter;
- $this->tail = $this->head;
- } else {
- $this->tail->next = $converter;
- $this->tail = $this->tail->next;
- }
- }
-
- /**
- * Parses the formatting modifiers and produces the corresponding
- * LoggerFormattingInfo object.
- *
- * @param string $modifier
- * @return LoggerFormattingInfo
- * @throws LoggerException
- */
- private function parseModifiers($modifiers) {
- $info = new LoggerFormattingInfo();
-
- // If no modifiers are given, return default values
- if (empty($modifiers)) {
- return $info;
- }
-
- // Validate
- $pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
- if (!preg_match($pattern, $modifiers)) {
- trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
- return $info;
- }
-
- $parts = explode('.', $modifiers);
-
- if (!empty($parts[0])) {
- $minPart = (integer) $parts[0];
- $info->min = abs($minPart);
- $info->padLeft = ($minPart > 0);
- }
-
- if (!empty($parts[1])) {
- $maxPart = (integer) $parts[1];
- $info->max = abs($maxPart);
- $info->trimLeft = ($maxPart < 0);
- }
-
- return $info;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/helpers/LoggerUtils.php
----------------------------------------------------------------------
diff --git a/src/main/php/helpers/LoggerUtils.php b/src/main/php/helpers/LoggerUtils.php
deleted file mode 100644
index bc7366e..0000000
--- a/src/main/php/helpers/LoggerUtils.php
+++ /dev/null
@@ -1,123 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Contains various helper methods.
- *
- * @package log4php
- * @subpackage helpers
- * @since 2.3
- */
-class LoggerUtils {
-
- /**
- * Splits a fully qualified class name into fragments delimited by the
- * namespace separator (\).
- *
- * For backward compatibility, a dot (.) can be used as a delimiter as
- * well.
- *
- * @param string $name
- *
- * @return array Class name split into fragments.
- */
- public static function tokenizeClassName($name) {
- $name = str_replace('.', '\\', $name);
- $name = trim($name, ' \\');
- $fragments = explode('\\', $name);
-
- foreach($fragments as $key => $fragment) {
- if (trim($fragment) === '') {
- unset($fragments[$key]);
- }
- }
-
- return $fragments;
- }
-
- /**
- * Attempts to shorten the given class name to the desired length.
- *
- * This is done by separating the class name into fragments (delimited
- * by \ or .) and trimming individual fragments, starting with the left,
- * until desired length has been reached.
- *
- * The final fragment (i.e. class name) will never be shortened so the
- * result may still be longer than given length.
- *
- * @param string $name The (qualified) class name.
- * @param integer $length The length to shorten to. If null or 0 is given,
- * the name will be returned without shortening.
- */
- public static function shortenClassName($name, $length) {
- if ($length === null || $length < 0) {
- return $name;
- }
-
- $name = str_replace('.', '\\', $name);
- $name = trim($name, ' \\');
-
- // Check if any shortening is required
- $currentLength = strlen($name);
- if ($currentLength <= $length) {
- return $name;
- }
-
- // Split name into fragments
- $fragments = explode('\\', $name);
-
- // If zero length is specified, return only last fragment
- if ($length == 0) {
- return array_pop($fragments);
- }
-
- // If the name splits to only one fragment, then it cannot be shortened
- $count = count($fragments);
- if ($count == 1) {
- return $name;
- }
-
- foreach($fragments as $key => &$fragment) {
-
- // Never shorten last fragment
- if ($key == $count - 1) {
- break;
- }
-
- // Check for empty fragments (shouldn't happen but it's possible)
- $fragLen = strlen($fragment);
- if ($fragLen <= 1) {
- continue;
- }
-
- // Shorten fragment to one character and check if total length satisfactory
- $fragment = substr($fragment, 0, 1);
- $currentLength = $currentLength - $fragLen + 1;
-
- if ($currentLength <= $length) {
- break;
- }
- }
- unset($fragment);
-
- return implode('\\', $fragments);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/layouts/LoggerLayoutHtml.php
----------------------------------------------------------------------
diff --git a/src/main/php/layouts/LoggerLayoutHtml.php b/src/main/php/layouts/LoggerLayoutHtml.php
deleted file mode 100644
index ea2769b..0000000
--- a/src/main/php/layouts/LoggerLayoutHtml.php
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This layout outputs events in a HTML table.
- *
- * Configurable parameters for this layout are:
- *
- * - title
- * - locationInfo
- *
- * An example for this layout:
- *
- * {@example ../../examples/php/layout_html.php 19}<br>
- *
- * The corresponding XML file:
- *
- * {@example ../../examples/resources/layout_html.properties 18}
- *
- * The above will print a HTML table that looks, converted back to plain text, like the following:<br>
- * <pre>
- * Log session start time Wed Sep 9 00:11:30 2009
- *
- * Time Thread Level Category Message
- * 0 8318 INFO root Hello World!
- * </pre>
- *
- * @version $Revision$
- * @package log4php
- * @subpackage layouts
- */
-class LoggerLayoutHtml extends LoggerLayout {
- /**
- * The <b>LocationInfo</b> option takes a boolean value. By
- * default, it is set to false which means there will be no location
- * information output by this layout. If the the option is set to
- * true, then the file name and line number of the statement
- * at the origin of the log statement will be output.
- *
- * <p>If you are embedding this layout within a {@link LoggerAppenderMail}
- * or a {@link LoggerAppenderMailEvent} then make sure to set the
- * <b>LocationInfo</b> option of that appender as well.
- * @var boolean
- */
- protected $locationInfo = false;
-
- /**
- * The <b>Title</b> option takes a String value. This option sets the
- * document title of the generated HTML document.
- * Defaults to 'Log4php Log Messages'.
- * @var string
- */
- protected $title = "Log4php Log Messages";
-
- /**
- * The <b>LocationInfo</b> option takes a boolean value. By
- * default, it is set to false which means there will be no location
- * information output by this layout. If the the option is set to
- * true, then the file name and line number of the statement
- * at the origin of the log statement will be output.
- *
- * <p>If you are embedding this layout within a {@link LoggerAppenderMail}
- * or a {@link LoggerAppenderMailEvent} then make sure to set the
- * <b>LocationInfo</b> option of that appender as well.
- */
- public function setLocationInfo($flag) {
- $this->setBoolean('locationInfo', $flag);
- }
-
- /**
- * Returns the current value of the <b>LocationInfo</b> option.
- */
- public function getLocationInfo() {
- return $this->locationInfo;
- }
-
- /**
- * The <b>Title</b> option takes a String value. This option sets the
- * document title of the generated HTML document.
- * Defaults to 'Log4php Log Messages'.
- */
- public function setTitle($title) {
- $this->setString('title', $title);
- }
-
- /**
- * @return string Returns the current value of the <b>Title</b> option.
- */
- public function getTitle() {
- return $this->title;
- }
-
- /**
- * @return string Returns the content type output by this layout, i.e "text/html".
- */
- public function getContentType() {
- return "text/html";
- }
-
- /**
- * @param LoggerLoggingEvent $event
- * @return string
- */
- public function format(LoggerLoggingEvent $event) {
- $sbuf = PHP_EOL . "<tr>" . PHP_EOL;
-
- $sbuf .= "<td>";
- $sbuf .= round(1000 * $event->getRelativeTime());
- $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;
- }
-
- /**
- * @return string Returns appropriate HTML headers.
- */
- public function getHeader() {
- $sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
- $sbuf .= "<html>" . PHP_EOL;
- $sbuf .= "<head>" . PHP_EOL;
- $sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
- $sbuf .= "<style type=\"text/css\">" . PHP_EOL;
- $sbuf .= "<!--" . PHP_EOL;
- $sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
- $sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
- $sbuf .= "-->" . PHP_EOL;
- $sbuf .= "</style>" . PHP_EOL;
- $sbuf .= "</head>" . PHP_EOL;
- $sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
- $sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
- $sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
- $sbuf .= "<br>" . PHP_EOL;
- $sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
- $sbuf .= "<tr>" . PHP_EOL;
- $sbuf .= "<th>Time</th>" . PHP_EOL;
- $sbuf .= "<th>Thread</th>" . PHP_EOL;
- $sbuf .= "<th>Level</th>" . PHP_EOL;
- $sbuf .= "<th>Category</th>" . PHP_EOL;
- if ($this->locationInfo) {
- $sbuf .= "<th>File:Line</th>" . PHP_EOL;
- }
- $sbuf .= "<th>Message</th>" . PHP_EOL;
- $sbuf .= "</tr>" . PHP_EOL;
-
- return $sbuf;
- }
-
- /**
- * @return string Returns the appropriate HTML footers.
- */
- public function getFooter() {
- $sbuf = "</table>" . PHP_EOL;
- $sbuf .= "<br>" . PHP_EOL;
- $sbuf .= "</body></html>";
-
- return $sbuf;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/layouts/LoggerLayoutPattern.php
----------------------------------------------------------------------
diff --git a/src/main/php/layouts/LoggerLayoutPattern.php b/src/main/php/layouts/LoggerLayoutPattern.php
deleted file mode 100644
index 0467d18..0000000
--- a/src/main/php/layouts/LoggerLayoutPattern.php
+++ /dev/null
@@ -1,171 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * A flexible layout configurable with a pattern string.
- *
- * Configurable parameters:
- *
- * * converionPattern - A string which controls the formatting of logging
- * events. See docs for full specification.
- *
- * @package log4php
- * @subpackage layouts
- * @version $Revision$
- */
-class LoggerLayoutPattern extends LoggerLayout {
-
- /** Default conversion pattern */
- const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
-
- /** Default conversion TTCC Pattern */
- const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
-
- /** The conversion pattern. */
- protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
-
- /** Maps conversion keywords to the relevant converter (default implementation). */
- protected static $defaultConverterMap = array(
- 'c' => 'LoggerPatternConverterLogger',
- 'lo' => 'LoggerPatternConverterLogger',
- 'logger' => 'LoggerPatternConverterLogger',
-
- 'C' => 'LoggerPatternConverterClass',
- 'class' => 'LoggerPatternConverterClass',
-
- 'cookie' => 'LoggerPatternConverterCookie',
-
- 'd' => 'LoggerPatternConverterDate',
- 'date' => 'LoggerPatternConverterDate',
-
- 'e' => 'LoggerPatternConverterEnvironment',
- 'env' => 'LoggerPatternConverterEnvironment',
-
- 'ex' => 'LoggerPatternConverterThrowable',
- 'exception' => 'LoggerPatternConverterThrowable',
- 'throwable' => 'LoggerPatternConverterThrowable',
-
- 'F' => 'LoggerPatternConverterFile',
- 'file' => 'LoggerPatternConverterFile',
-
- 'l' => 'LoggerPatternConverterLocation',
- 'location' => 'LoggerPatternConverterLocation',
-
- 'L' => 'LoggerPatternConverterLine',
- 'line' => 'LoggerPatternConverterLine',
-
- 'm' => 'LoggerPatternConverterMessage',
- 'msg' => 'LoggerPatternConverterMessage',
- 'message' => 'LoggerPatternConverterMessage',
-
- 'M' => 'LoggerPatternConverterMethod',
- 'method' => 'LoggerPatternConverterMethod',
-
- 'n' => 'LoggerPatternConverterNewLine',
- 'newline' => 'LoggerPatternConverterNewLine',
-
- 'p' => 'LoggerPatternConverterLevel',
- 'le' => 'LoggerPatternConverterLevel',
- 'level' => 'LoggerPatternConverterLevel',
-
- 'r' => 'LoggerPatternConverterRelative',
- 'relative' => 'LoggerPatternConverterRelative',
-
- 'req' => 'LoggerPatternConverterRequest',
- 'request' => 'LoggerPatternConverterRequest',
-
- 's' => 'LoggerPatternConverterServer',
- 'server' => 'LoggerPatternConverterServer',
-
- 'ses' => 'LoggerPatternConverterSession',
- 'session' => 'LoggerPatternConverterSession',
-
- 'sid' => 'LoggerPatternConverterSessionID',
- 'sessionid' => 'LoggerPatternConverterSessionID',
-
- 't' => 'LoggerPatternConverterProcess',
- 'pid' => 'LoggerPatternConverterProcess',
- 'process' => 'LoggerPatternConverterProcess',
-
- 'x' => 'LoggerPatternConverterNDC',
- 'ndc' => 'LoggerPatternConverterNDC',
-
- 'X' => 'LoggerPatternConverterMDC',
- 'mdc' => 'LoggerPatternConverterMDC',
- );
-
- /** Maps conversion keywords to the relevant converter. */
- protected $converterMap = array();
-
- /**
- * Head of a chain of Converters.
- * @var LoggerPatternConverter
- */
- private $head;
-
- /** Returns the default converter map. */
- public static function getDefaultConverterMap() {
- return self::$defaultConverterMap;
- }
-
- /** Constructor. Initializes the converter map. */
- public function __construct() {
- $this->converterMap = self::$defaultConverterMap;
- }
-
- /**
- * Sets the conversionPattern option. This is the string which
- * controls formatting and consists of a mix of literal content and
- * conversion specifiers.
- * @param array $conversionPattern
- */
- public function setConversionPattern($conversionPattern) {
- $this->pattern = $conversionPattern;
- }
-
- /**
- * 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();
- }
-
- /**
- * Produces a formatted string as specified by the conversion pattern.
- *
- * @param LoggerLoggingEvent $event
- * @return string
- */
- public function format(LoggerLoggingEvent $event) {
- $sbuf = '';
- $converter = $this->head;
- while ($converter !== null) {
- $converter->format($sbuf, $event);
- $converter = $converter->next;
- }
- return $sbuf;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/layouts/LoggerLayoutSerialized.php
----------------------------------------------------------------------
diff --git a/src/main/php/layouts/LoggerLayoutSerialized.php b/src/main/php/layouts/LoggerLayoutSerialized.php
deleted file mode 100644
index bf754b8..0000000
--- a/src/main/php/layouts/LoggerLayoutSerialized.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Layout which formats the events using PHP's serialize() function.
- *
- * Available options:
- * - locationInfo - If set to true, the event's location information will also
- * be serialized (slow, defaults to false).
- *
- * @version $Revision$
- * @package log4php
- * @subpackage layouts
- * @since 2.2
- */
-class LoggerLayoutSerialized extends LoggerLayout {
-
- /** Whether to include the event's location information (slow). */
- protected $locationInfo = false;
-
- /** Sets the location information flag. */
- public function setLocationInfo($value) {
- $this->setBoolean('locationInfo', $value);
- }
-
- /** Returns the location information flag. */
- public function getLocationInfo() {
- return $this->locationInfo;
- }
-
- public function format(LoggerLoggingEvent $event) {
- // If required, initialize the location data
- if($this->locationInfo) {
- $event->getLocationInformation();
- }
- return serialize($event) . PHP_EOL;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/layouts/LoggerLayoutSimple.php
----------------------------------------------------------------------
diff --git a/src/main/php/layouts/LoggerLayoutSimple.php b/src/main/php/layouts/LoggerLayoutSimple.php
deleted file mode 100644
index 26f3d3c..0000000
--- a/src/main/php/layouts/LoggerLayoutSimple.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * A simple layout.
- *
- * Returns the log statement in a format consisting of the
- * <b>level</b>, followed by " - " and then the <b>message</b>.
- *
- * For example the following php and properties files
- *
- * {@example ../../examples/php/layout_simple.php 19}<br>
- *
- * {@example ../../examples/resources/layout_simple.properties 18}<br>
- *
- * would result in:
- *
- * <samp>INFO - Hello World!</samp>
- *
- * @version $Revision$
- * @package log4php
- * @subpackage layouts
- */
-class LoggerLayoutSimple extends LoggerLayout {
- /**
- * Returns the log statement in a format consisting of the
- * <b>level</b>, followed by " - " and then the
- * <b>message</b>. For example,
- * <samp> INFO - "A message" </samp>
- *
- * @param LoggerLoggingEvent $event
- * @return string
- */
- public function format(LoggerLoggingEvent $event) {
- $level = $event->getLevel();
- $message = $event->getRenderedMessage();
- return "$level - $message" . PHP_EOL;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/layouts/LoggerLayoutTTCC.php
----------------------------------------------------------------------
diff --git a/src/main/php/layouts/LoggerLayoutTTCC.php b/src/main/php/layouts/LoggerLayoutTTCC.php
deleted file mode 100644
index e49d844..0000000
--- a/src/main/php/layouts/LoggerLayoutTTCC.php
+++ /dev/null
@@ -1,201 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * TTCC layout format consists of <b>t</b>ime, <b>t</b>hread, <b>c</b>ategory and nested
- * diagnostic <b>c</b>ontext information, hence the name.
- *
- * <p>Each of the four fields can be individually enabled or
- * disabled. The time format depends on the <b>DateFormat</b> used.</p>
- *
- * <p>If no dateFormat is specified it defaults to '%c'.
- * See php {@link PHP_MANUAL#date} function for details.</p>
- *
- * Configurable parameters for this layout are:
- * - {@link $threadPrinting} (true|false) enable/disable pid reporting.
- * - {@link $categoryPrefixing} (true|false) enable/disable logger category reporting.
- * - {@link $contextPrinting} (true|false) enable/disable NDC reporting.
- * - {@link $microSecondsPrinting} (true|false) enable/disable micro seconds reporting in timestamp.
- * - {@link $dateFormat} (string) set date format. See php {@link PHP_MANUAL#date} function for details.
- *
- * An example how to use this layout:
- *
- * {@example ../../examples/php/layout_ttcc.php 19}<br>
- *
- * {@example ../../examples/resources/layout_ttcc.properties 18}<br>
- *
- * The above would print:<br>
- * <samp>02:28 [13714] INFO root - Hello World!</samp>
- *
- * @version $Revision$
- * @package log4php
- * @subpackage layouts
- *
- * @deprecated LoggerLayout TTCC is deprecated and will be removed in a future release. Please use
- * LoggerLayoutPattern instead.
- */
-class LoggerLayoutTTCC extends LoggerLayout {
-
- // Internal representation of options
- protected $threadPrinting = true;
- protected $categoryPrefixing = true;
- protected $contextPrinting = true;
- protected $microSecondsPrinting = true;
-
- /**
- * @var string date format. See {@link PHP_MANUAL#strftime} for details
- */
- protected $dateFormat = '%c';
-
- /**
- * Constructor
- *
- * @param string date format
- * @see dateFormat
- */
- public function __construct($dateFormat = '') {
- $this->warn("LoggerLayout TTCC is deprecated and will be removed in a future release. Please use LoggerLayoutPattern instead.");
- if (!empty($dateFormat)) {
- $this->dateFormat = $dateFormat;
- }
- return;
- }
-
- /**
- * The <b>ThreadPrinting</b> option specifies whether the name of the
- * current thread is part of log output or not. This is true by default.
- */
- public function setThreadPrinting($threadPrinting) {
- $this->setBoolean('threadPrinting', $threadPrinting);
- }
-
- /**
- * @return boolean Returns value of the <b>ThreadPrinting</b> option.
- */
- public function getThreadPrinting() {
- return $this->threadPrinting;
- }
-
- /**
- * The <b>CategoryPrefixing</b> option specifies whether {@link Category}
- * name is part of log output or not. This is true by default.
- */
- public function setCategoryPrefixing($categoryPrefixing) {
- $this->setBoolean('categoryPrefixing', $categoryPrefixing);
- }
-
- /**
- * @return boolean Returns value of the <b>CategoryPrefixing</b> option.
- */
- public function getCategoryPrefixing() {
- return $this->categoryPrefixing;
- }
-
- /**
- * The <b>ContextPrinting</b> option specifies log output will include
- * the nested context information belonging to the current thread.
- * This is true by default.
- */
- public function setContextPrinting($contextPrinting) {
- $this->setBoolean('contextPrinting', $contextPrinting);
- }
-
- /**
- * @return boolean Returns value of the <b>ContextPrinting</b> option.
- */
- public function getContextPrinting() {
- return $this->contextPrinting;
- }
-
- /**
- * The <b>MicroSecondsPrinting</b> option specifies if microseconds infos
- * should be printed at the end of timestamp.
- * This is true by default.
- */
- public function setMicroSecondsPrinting($microSecondsPrinting) {
- $this->setBoolean('microSecondsPrinting', $microSecondsPrinting);
- }
-
- /**
- * @return boolean Returns value of the <b>MicroSecondsPrinting</b> option.
- */
- public function getMicroSecondsPrinting() {
- return $this->microSecondsPrinting;
- }
-
-
- public function setDateFormat($dateFormat) {
- $this->setString('dateFormat', $dateFormat);
- }
-
- /**
- * @return string
- */
- public function getDateFormat() {
- return $this->dateFormat;
- }
-
- /**
- * 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 = (float)$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;
- }
-
- public function ignoresThrowable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/layouts/LoggerLayoutXml.php
----------------------------------------------------------------------
diff --git a/src/main/php/layouts/LoggerLayoutXml.php b/src/main/php/layouts/LoggerLayoutXml.php
deleted file mode 100644
index 2c17def..0000000
--- a/src/main/php/layouts/LoggerLayoutXml.php
+++ /dev/null
@@ -1,210 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The output of the LoggerXmlLayout consists of a series of log4php:event elements.
- *
- * Configurable parameters:
- * - {@link $locationInfo} - If set to true then the file name and line number
- * of the origin of the log statement will be included in output.
- * - {@link $log4jNamespace} - If set to true then log4j namespace will be used
- * instead of log4php namespace. This can be usefull when using log viewers
- * which can only parse the log4j namespace such as Apache Chainsaw.
- *
- * <p>It does not output a complete well-formed XML file.
- * The output is designed to be included as an external entity in a separate file to form
- * a correct XML file.</p>
- *
- * Example:
- *
- * {@example ../../examples/php/layout_xml.php 19}<br>
- *
- * {@example ../../examples/resources/layout_xml.properties 18}<br>
- *
- * The above would print:
- *
- * <pre>
- * <log4php:eventSet xmlns:log4php="http://logging.apache.org/log4php/" version="0.3" includesLocationInfo="true">
- * <log4php:event logger="root" level="INFO" thread="13802" timestamp="1252456226491">
- * <log4php:message><![CDATA[Hello World!]]></log4php:message>
- * <log4php:locationInfo class="main" file="examples/php/layout_xml.php" line="6" method="main" />
- * </log4php:event>
- * </log4php:eventSet>
- * </pre>
- *
- * @version $Revision$
- * @package log4php
- * @subpackage layouts
- */
-class LoggerLayoutXml extends LoggerLayout {
- const LOG4J_NS_PREFIX ='log4j';
- const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
-
- const LOG4PHP_NS_PREFIX = 'log4php';
- const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
-
- const CDATA_START = '<![CDATA[';
- const CDATA_END = ']]>';
- const CDATA_PSEUDO_END = ']]>';
- const CDATA_EMBEDDED_END = ']]>]]><![CDATA[';
-
- /**
- * If set to true then the file name and line number of the origin of the
- * log statement will be output.
- * @var boolean
- */
- protected $locationInfo = true;
-
- /**
- * If set to true, log4j namespace will be used instead of the log4php
- * namespace.
- * @var boolean
- */
- protected $log4jNamespace = false;
-
- /** The namespace in use. */
- protected $namespace = self::LOG4PHP_NS;
-
- /** The namespace prefix in use */
- protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
-
- public function activateOptions() {
- if ($this->getLog4jNamespace()) {
- $this->namespace = self::LOG4J_NS;
- $this->namespacePrefix = self::LOG4J_NS_PREFIX;
- } else {
- $this->namespace = self::LOG4PHP_NS;
- $this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
- }
- }
-
- /**
- * @return string
- */
- public function getHeader() {
- return "<{$this->namespacePrefix}:eventSet ".
- "xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
- "version=\"0.3\" ".
- "includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
- ">" . PHP_EOL;
- }
-
- /**
- * 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((float)($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;
- }
-
- /**
- * @return string
- */
- public function getFooter() {
- return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
- }
-
-
- /**
- * Whether or not file name and line number will be included in the output.
- * @return boolean
- */
- public function getLocationInfo() {
- return $this->locationInfo;
- }
-
- /**
- * The {@link $locationInfo} option takes a boolean value. By default,
- * it is set to false which means there will be no location
- * information output by this layout. If the the option is set to
- * true, then the file name and line number of the statement at the
- * origin of the log statement will be output.
- */
- public function setLocationInfo($flag) {
- $this->setBoolean('locationInfo', $flag);
- }
-
- /**
- * @return boolean
- */
- public function getLog4jNamespace() {
- return $this->log4jNamespace;
- }
-
- /**
- * @param boolean
- */
- public function setLog4jNamespace($flag) {
- $this->setBoolean('log4jNamespace', $flag);
- }
-
- /**
- * Encases a string in CDATA tags, and escapes any existing CDATA end
- * tags already present in the string.
- * @param string $string
- */
- private function encodeCDATA($string) {
- $string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
- return self::CDATA_START . $string . self::CDATA_END;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverter.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverter.php b/src/main/php/pattern/LoggerPatternConverter.php
deleted file mode 100644
index 3e3ee3c..0000000
--- a/src/main/php/pattern/LoggerPatternConverter.php
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * LoggerPatternConverter is an abstract class that provides the formatting
- * functionality that derived classes need.
- *
- * <p>Conversion specifiers in a conversion patterns are parsed to
- * individual PatternConverters. Each of which is responsible for
- * converting a logging event in a converter specific manner.</p>
- *
- * @version $Revision$
- * @package log4php
- * @subpackage helpers
- * @since 0.3
- */
-abstract class LoggerPatternConverter {
-
- /**
- * Next converter in the converter chain.
- * @var LoggerPatternConverter
- */
- public $next = null;
-
- /**
- * Formatting information, parsed from pattern modifiers.
- * @var LoggerFormattingInfo
- */
- protected $formattingInfo;
-
- /**
- * Converter-specific formatting options.
- * @var array
- */
- protected $option;
-
- /**
- * Constructor
- * @param LoggerFormattingInfo $formattingInfo
- * @param array $option
- */
- public function __construct(LoggerFormattingInfo $formattingInfo = null, $option = null) {
- $this->formattingInfo = $formattingInfo;
- $this->option = $option;
- $this->activateOptions();
- }
-
- /**
- * Called in constructor. Converters which need to process the options
- * can override this method.
- */
- public function activateOptions() { }
-
- /**
- * Converts the logging event to the desired format. Derived pattern
- * converters must implement this method.
- *
- * @param LoggerLoggingEvent $event
- */
- abstract public function convert(LoggerLoggingEvent $event);
-
- /**
- * Converts the event and formats it according to setting in the
- * Formatting information object.
- *
- * @param string &$sbuf string buffer to write to
- * @param LoggerLoggingEvent $event Event to be formatted.
- */
- public function format(&$sbuf, $event) {
- $string = $this->convert($event);
-
- if (!isset($this->formattingInfo)) {
- $sbuf .= $string;
- return;
- }
-
- $fi = $this->formattingInfo;
-
- // Empty string
- if($string === '' || is_null($string)) {
- if($fi->min > 0) {
- $sbuf .= str_repeat(' ', $fi->min);
- }
- return;
- }
-
- $len = strlen($string);
-
- // Trim the string if needed
- if($len > $fi->max) {
- if ($fi->trimLeft) {
- $sbuf .= substr($string, $len - $fi->max, $fi->max);
- } else {
- $sbuf .= substr($string , 0, $fi->max);
- }
- }
-
- // Add padding if needed
- else if($len < $fi->min) {
- if($fi->padLeft) {
- $sbuf .= str_repeat(' ', $fi->min - $len);
- $sbuf .= $string;
- } else {
- $sbuf .= $string;
- $sbuf .= str_repeat(' ', $fi->min - $len);
- }
- }
-
- // No action needed
- else {
- $sbuf .= $string;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterClass.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterClass.php b/src/main/php/pattern/LoggerPatternConverterClass.php
deleted file mode 100644
index c2e2991..0000000
--- a/src/main/php/pattern/LoggerPatternConverterClass.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the fully qualified class name of the class from which the logging
- * request was issued.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterClass extends LoggerPatternConverter {
-
- /** Length to which to shorten the class name. */
- private $length;
-
- /** Holds processed class names. */
- private $cache = array();
-
- public function activateOptions() {
- // Parse the option (desired output length)
- if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
- $this->length = (integer) $this->option;
- }
- }
-
- 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);
- }
-
- // If no length is specified return the full class name
- else {
- $this->cache[$name] = $name;
- }
- }
-
- return $this->cache[$name];
- }
-}
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterCookie.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterCookie.php b/src/main/php/pattern/LoggerPatternConverterCookie.php
deleted file mode 100644
index 1b836aa..0000000
--- a/src/main/php/pattern/LoggerPatternConverterCookie.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns a value from the $_COOKIE superglobal array corresponding to the
- * given key. If no key is given, return all values.
- *
- * Options:
- * [0] $_COOKIE key value
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterCookie extends LoggerPatternConverterSuperglobal {
- protected $name = '_COOKIE';
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterDate.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterDate.php b/src/main/php/pattern/LoggerPatternConverterDate.php
deleted file mode 100644
index 2894491..0000000
--- a/src/main/php/pattern/LoggerPatternConverterDate.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the date/time of the logging request.
- *
- * Option: the datetime format, as used by the date() function. If
- * the option is not given, the default format 'c' will be used.
- *
- * There are several "special" values which can be given for this option:
- * 'ISO8601', 'ABSOLUTE' and 'DATE'.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterDate extends LoggerPatternConverter {
-
- const DATE_FORMAT_ISO8601 = 'c';
-
- const DATE_FORMAT_ABSOLUTE = 'H:i:s';
-
- const DATE_FORMAT_DATE = 'd M Y H:i:s.u';
-
- private $format = self::DATE_FORMAT_ISO8601;
-
- private $specials = array(
- 'ISO8601' => self::DATE_FORMAT_ISO8601,
- 'ABSOLUTE' => self::DATE_FORMAT_ABSOLUTE,
- 'DATE' => self::DATE_FORMAT_DATE,
- );
-
- private $useLocalDate = false;
-
- public function activateOptions() {
-
- // Parse the option (date format)
- if (!empty($this->option)) {
- if(isset($this->specials[$this->option])) {
- $this->format = $this->specials[$this->option];
- } else {
- $this->format = $this->option;
- }
- }
-
- // Check whether the pattern contains milliseconds (u)
- if (preg_match('/(?<!\\\\)u/', $this->format)) {
- $this->useLocalDate = true;
- }
- }
-
- public function convert(LoggerLoggingEvent $event) {
- if ($this->useLocalDate) {
- return $this->date($this->format, $event->getTimeStamp());
- }
- return date($this->format, $event->getTimeStamp());
- }
-
- /**
- * Currently, PHP date() function always returns zeros for milliseconds (u)
- * on Windows. This is a replacement function for date() which correctly
- * displays milliseconds on all platforms.
- *
- * It is slower than PHP date() so it should only be used if necessary.
- */
- private function date($format, $utimestamp) {
- $timestamp = floor($utimestamp);
- $ms = floor(($utimestamp - $timestamp) * 1000);
- $ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
-
- return date(preg_replace('`(?<!\\\\)u`', $ms, $format), $timestamp);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterEnvironment.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterEnvironment.php b/src/main/php/pattern/LoggerPatternConverterEnvironment.php
deleted file mode 100644
index 07e83e1..0000000
--- a/src/main/php/pattern/LoggerPatternConverterEnvironment.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns a value from the $_ENV superglobal array corresponding to the
- * given key.
- *
- * Options:
- * [0] $_ENV key value
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterEnvironment extends LoggerPatternConverterSuperglobal {
- protected $name = '_ENV';
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterFile.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterFile.php b/src/main/php/pattern/LoggerPatternConverterFile.php
deleted file mode 100644
index 7898db6..0000000
--- a/src/main/php/pattern/LoggerPatternConverterFile.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the name of the file from which the logging request was issued.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterFile extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return $event->getLocationInformation()->getFileName();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterLevel.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterLevel.php b/src/main/php/pattern/LoggerPatternConverterLevel.php
deleted file mode 100644
index e1e08c6..0000000
--- a/src/main/php/pattern/LoggerPatternConverterLevel.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the event's level.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterLevel extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return $event->getLevel()->toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterLine.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterLine.php b/src/main/php/pattern/LoggerPatternConverterLine.php
deleted file mode 100644
index 4fd6f22..0000000
--- a/src/main/php/pattern/LoggerPatternConverterLine.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the line number within the file from which the logging request was
- * issued.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterLine extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return $event->getLocationInformation()->getLineNumber();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterLiteral.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterLiteral.php b/src/main/php/pattern/LoggerPatternConverterLiteral.php
deleted file mode 100644
index 658b1dc..0000000
--- a/src/main/php/pattern/LoggerPatternConverterLiteral.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the literal value passed in the constructor, without modifications.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterLiteral extends LoggerPatternConverter {
-
- private $literalValue;
-
- public function __construct($literalValue) {
- $this->literalValue = $literalValue;
- }
-
- public function convert(LoggerLoggingEvent $event) {
- return $this->literalValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterLocation.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterLocation.php b/src/main/php/pattern/LoggerPatternConverterLocation.php
deleted file mode 100644
index c6af014..0000000
--- a/src/main/php/pattern/LoggerPatternConverterLocation.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the line number within the file from which the logging request was
- * issued.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterLocation extends LoggerPatternConverter {
-
- public function convert(LoggerLoggingEvent $event) {
- return
- $event->getLocationInformation()->getClassName() . '.' .
- $event->getLocationInformation()->getMethodName() . '(' .
- $event->getLocationInformation()->getFileName() . ':' .
- $event->getLocationInformation()->getLineNumber() . ')';
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/pattern/LoggerPatternConverterLogger.php
----------------------------------------------------------------------
diff --git a/src/main/php/pattern/LoggerPatternConverterLogger.php b/src/main/php/pattern/LoggerPatternConverterLogger.php
deleted file mode 100644
index cf1007c..0000000
--- a/src/main/php/pattern/LoggerPatternConverterLogger.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Returns the name of the logger which created the logging request.
- *
- * Takes one option, which is an integer. If the option is given, the logger
- * name will be shortened to the given length, if possible.
- *
- * @package log4php
- * @subpackage pattern
- * @version $Revision$
- * @since 2.3
- */
-class LoggerPatternConverterLogger extends LoggerPatternConverter {
-
- /** Length to which to shorten the name. */
- private $length;
-
- /** Holds processed logger names. */
- private $cache = array();
-
- public function activateOptions() {
- // Parse the option (desired output length)
- if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
- $this->length = (integer) $this->option;
- }
- }
-
- 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);
- }
-
- // If no length is specified return full logger name
- else {
- $this->cache[$name] = $name;
- }
- }
-
- return $this->cache[$name];
- }
-}
[20/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderMongoDB.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderMongoDB.php b/src/main/php/appenders/LoggerAppenderMongoDB.php
deleted file mode 100644
index c0f2c2d..0000000
--- a/src/main/php/appenders/LoggerAppenderMongoDB.php
+++ /dev/null
@@ -1,360 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Appender for writing to MongoDB.
- *
- * This class was originally contributed by Vladimir Gorej.
- *
- * ## Configurable parameters: ##
- *
- * - **host** - Server on which mongodb instance is located.
- * - **port** - Port on which the instance is bound.
- * - **databaseName** - Name of the database to which to log.
- * - **collectionName** - Name of the target collection within the given database.
- * - **username** - Username used to connect to the database.
- * - **password** - Password used to connect to the database.
- * - **timeout** - For how long the driver should try to connect to the database (in milliseconds).
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @since 2.1
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/mongodb.html Appender documentation
- * @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
- * @link http://www.mongodb.org/ MongoDB website.
- */
-class LoggerAppenderMongoDB extends LoggerAppender {
-
- // ******************************************
- // ** Constants **
- // ******************************************
-
- /** Default prefix for the {@link $host}. */
- const DEFAULT_MONGO_URL_PREFIX = 'mongodb://';
-
- /** Default value for {@link $host}, without a prefix. */
- const DEFAULT_MONGO_HOST = 'localhost';
-
- /** Default value for {@link $port} */
- const DEFAULT_MONGO_PORT = 27017;
-
- /** Default value for {@link $databaseName} */
- const DEFAULT_DB_NAME = 'log4php_mongodb';
-
- /** Default value for {@link $collectionName} */
- const DEFAULT_COLLECTION_NAME = 'logs';
-
- /** Default value for {@link $timeout} */
- const DEFAULT_TIMEOUT_VALUE = 3000;
-
- // ******************************************
- // ** Configurable parameters **
- // ******************************************
-
- /** Server on which mongodb instance is located. */
- protected $host;
-
- /** Port on which the instance is bound. */
- protected $port;
-
- /** Name of the database to which to log. */
- protected $databaseName;
-
- /** Name of the collection within the given database. */
- protected $collectionName;
-
- /** Username used to connect to the database. */
- protected $userName;
-
- /** Password used to connect to the database. */
- protected $password;
-
- /** Timeout value used when connecting to the database (in milliseconds). */
- protected $timeout;
-
- // ******************************************
- // ** Member variables **
- // ******************************************
-
- /**
- * Connection to the MongoDB instance.
- * @var Mongo
- */
- protected $connection;
-
- /**
- * The collection to which log is written.
- * @var MongoCollection
- */
- protected $collection;
-
- public function __construct($name = '') {
- parent::__construct($name);
- $this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
- $this->port = self::DEFAULT_MONGO_PORT;
- $this->databaseName = self::DEFAULT_DB_NAME;
- $this->collectionName = self::DEFAULT_COLLECTION_NAME;
- $this->timeout = self::DEFAULT_TIMEOUT_VALUE;
- $this->requiresLayout = false;
- }
-
- /**
- * Setup db connection.
- * Based on defined options, this method connects to the database and
- * creates a {@link $collection}.
- */
- public function activateOptions() {
- try {
- $this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
- $db = $this->connection->selectDB($this->databaseName);
- if ($this->userName !== null && $this->password !== null) {
- $authResult = $db->authenticate($this->userName, $this->password);
- if ($authResult['ok'] == floatval(0)) {
- throw new Exception($authResult['errmsg'], $authResult['ok']);
- }
- }
- $this->collection = $db->selectCollection($this->collectionName);
- } catch (MongoConnectionException $ex) {
- $this->closed = true;
- $this->warn(sprintf('Failed to connect to mongo deamon: %s', $ex->getMessage()));
- } catch (InvalidArgumentException $ex) {
- $this->closed = true;
- $this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
- } catch (Exception $ex) {
- $this->closed = true;
- $this->warn('Invalid credentials for mongo database authentication');
- }
- }
-
- /**
- * Appends a new event to the mongo database.
- *
- * @param LoggerLoggingEvent $event
- */
- public function append(LoggerLoggingEvent $event) {
- try {
- if ($this->collection != null) {
- $this->collection->insert($this->format($event));
- }
- } catch (MongoCursorException $ex) {
- $this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
- }
- }
-
- /**
- * 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;
- }
-
- /**
- * Converts an Exception into an array which can be logged to mongodb.
- *
- * Supports innner exceptions (PHP >= 5.3)
- *
- * @param Exception $ex
- * @return array
- */
- protected function formatThrowable(Exception $ex) {
- $array = array(
- 'message' => $ex->getMessage(),
- 'code' => $ex->getCode(),
- 'stackTrace' => $ex->getTraceAsString(),
- );
-
- if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
- $array['innerException'] = $this->formatThrowable($ex->getPrevious());
- }
-
- return $array;
- }
-
- /**
- * Closes the connection to the logging database
- */
- public function close() {
- if($this->closed != true) {
- $this->collection = null;
- if ($this->connection !== null) {
- $this->connection->close();
- $this->connection = null;
- }
- $this->closed = true;
- }
- }
-
- /**
- * Sets the value of {@link $host} parameter.
- * @param string $host
- */
- public function setHost($host) {
- if (!preg_match('/^mongodb\:\/\//', $host)) {
- $host = self::DEFAULT_MONGO_URL_PREFIX . $host;
- }
- $this->host = $host;
- }
-
- /**
- * Returns the value of {@link $host} parameter.
- * @return string
- */
- public function getHost() {
- return $this->host;
- }
-
- /**
- * Sets the value of {@link $port} parameter.
- * @param int $port
- */
- public function setPort($port) {
- $this->setPositiveInteger('port', $port);
- }
-
- /**
- * Returns the value of {@link $port} parameter.
- * @return int
- */
- public function getPort() {
- return $this->port;
- }
-
- /**
- * Sets the value of {@link $databaseName} parameter.
- * @param string $databaseName
- */
- public function setDatabaseName($databaseName) {
- $this->setString('databaseName', $databaseName);
- }
-
- /**
- * Returns the value of {@link $databaseName} parameter.
- * @return string
- */
- public function getDatabaseName() {
- return $this->databaseName;
- }
-
- /**
- * Sets the value of {@link $collectionName} parameter.
- * @param string $collectionName
- */
- public function setCollectionName($collectionName) {
- $this->setString('collectionName', $collectionName);
- }
-
- /**
- * Returns the value of {@link $collectionName} parameter.
- * @return string
- */
- public function getCollectionName() {
- return $this->collectionName;
- }
-
- /**
- * Sets the value of {@link $userName} parameter.
- * @param string $userName
- */
- public function setUserName($userName) {
- $this->setString('userName', $userName, true);
- }
-
- /**
- * Returns the value of {@link $userName} parameter.
- * @return string
- */
- public function getUserName() {
- return $this->userName;
- }
-
- /**
- * Sets the value of {@link $password} parameter.
- * @param string $password
- */
- public function setPassword($password) {
- $this->setString('password', $password, true);
- }
-
- /**
- * Returns the value of {@link $password} parameter.
- * @return string
- */
- public function getPassword() {
- return $this->password;
- }
-
- /**
- * Sets the value of {@link $timeout} parameter.
- * @param int $timeout
- */
- public function setTimeout($timeout) {
- $this->setPositiveInteger('timeout', $timeout);
- }
-
- /**
- * Returns the value of {@link $timeout} parameter.
- * @return int
- */
- public function getTimeout() {
- return $this->timeout;
- }
- /**
- * Returns the mongodb connection.
- * @return Mongo
- */
- public function getConnection() {
- return $this->connection;
- }
-
- /**
- * Returns the active mongodb collection.
- * @return MongoCollection
- */
- public function getCollection() {
- return $this->collection;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderNull.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderNull.php b/src/main/php/appenders/LoggerAppenderNull.php
deleted file mode 100644
index c1c914d..0000000
--- a/src/main/php/appenders/LoggerAppenderNull.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * A NullAppender merely exists, it never outputs a message to any device.
- *
- * This appender has no configurable parameters.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/null.html Appender documentation
- */
-class LoggerAppenderNull extends LoggerAppender {
-
- /**
- * This appender does not require a layout.
- */
- protected $requiresLayout = false;
-
- /**
- * Do nothing.
- *
- * @param LoggerLoggingEvent $event
- */
- public function append(LoggerLoggingEvent $event) {
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderPDO.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderPDO.php b/src/main/php/appenders/LoggerAppenderPDO.php
deleted file mode 100644
index 6443aad..0000000
--- a/src/main/php/appenders/LoggerAppenderPDO.php
+++ /dev/null
@@ -1,282 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderPDO appender logs to a database using the PHP's PDO extension.
- *
- * ## Configurable parameters: ##
- *
- * - dsn - The Data Source Name (DSN) used to connect to the database.
- * - user - Username used to connect to the database.
- * - password - Password used to connect to the database.
- * - table - Name of the table to which log entries are be inserted.
- * - insertSQL - Sets the insert statement for a logging event. Defaults
- * to the correct one - change only if you are sure what you are doing.
- * - insertPattern - The conversion pattern to use in conjuction with insert
- * SQL. Must contain the same number of comma separated
- * conversion patterns as there are question marks in the
- * insertSQL.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @since 2.0
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/pdo.html Appender documentation
- */
-class LoggerAppenderPDO extends LoggerAppender {
-
- // ******************************************
- // *** Configurable parameters ***
- // ******************************************
-
- /**
- * DSN string used to connect to the database.
- * @see http://www.php.net/manual/en/pdo.construct.php
- */
- protected $dsn;
-
- /** Database user name. */
- protected $user;
-
- /** Database password. */
- protected $password;
-
- /**
- * The insert query.
- *
- * The __TABLE__ placeholder will be replaced by the table name from
- * {@link $table}.
- *
- * The questionmarks are part of the prepared statement, and they must
- * match the number of conversion specifiers in {@link insertPattern}.
- */
- protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
-
- /**
- * A comma separated list of {@link LoggerPatternLayout} format strings
- * which replace the "?" in {@link $insertSQL}.
- *
- * Must contain the same number of comma separated conversion patterns as
- * there are question marks in {@link insertSQL}.
- *
- * @see LoggerPatternLayout For conversion patterns.
- */
- protected $insertPattern = "%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line";
-
- /** Name of the table to which to append log events. */
- protected $table = 'log4php_log';
-
- /** The number of recconect attempts to make on failed append. */
- protected $reconnectAttempts = 3;
-
-
- // ******************************************
- // *** Private memebers ***
- // ******************************************
-
- /**
- * The PDO instance.
- * @var PDO
- */
- protected $db;
-
- /**
- * Prepared statement for the insert query.
- * @var PDOStatement
- */
- protected $preparedInsert;
-
- /** This appender does not require a layout. */
- protected $requiresLayout = false;
-
-
- // ******************************************
- // *** Appender methods ***
- // ******************************************
-
- /**
- * 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;
- }
-
- /**
- * Connects to the database, and prepares the insert query.
- * @throws PDOException If connect or prepare fails.
- */
- protected function establishConnection() {
- // Acquire database connection
- $this->db = new PDO($this->dsn, $this->user, $this->password);
- $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- // Prepare the insert statement
- $insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
- $this->preparedInsert = $this->db->prepare($insertSQL);
- }
-
- /**
- * Appends a new event to the database.
- *
- * If writing to database fails, it will retry by re-establishing the
- * connection up to $reconnectAttempts times. If writing still fails,
- * the appender will close.
- */
- public function append(LoggerLoggingEvent $event) {
-
- for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
- try {
- // Attempt to write to database
- $this->preparedInsert->execute($this->format($event));
- $this->preparedInsert->closeCursor();
- break;
- } catch (PDOException $e) {
- $this->warn("Failed writing to database: ". $e->getMessage());
-
- // Close the appender if it's the last attempt
- if ($attempt > $this->reconnectAttempts) {
- $this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
- $this->close();
- // Otherwise reconnect and try to write again
- } else {
- $this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
- $this->establishConnection();
- }
- }
- }
- }
-
- /**
- * Converts the logging event to a series of database parameters by using
- * the converter chain which was set up on activation.
- */
- protected function format(LoggerLoggingEvent $event) {
- $params = array();
- foreach($this->converters as $converter) {
- $buffer = '';
- while ($converter !== null) {
- $converter->format($buffer, $event);
- $converter = $converter->next;
- }
- $params[] = $buffer;
- }
- return $params;
- }
-
- /**
- * Closes the connection to the logging database
- */
- public function close() {
- // Close the connection (if any)
- $this->db = null;
-
- // Close the appender
- $this->closed = true;
- }
-
- // ******************************************
- // *** Accessor methods ***
- // ******************************************
-
- /**
- * Returns the active database handle or null if not established.
- * @return PDO
- */
- public function getDatabaseHandle() {
- return $this->db;
- }
-
- /** Sets the username. */
- public function setUser($user) {
- $this->setString('user', $user);
- }
-
- /** Returns the username. */
- public function getUser($user) {
- return $this->user;
- }
-
- /** Sets the password. */
- public function setPassword($password) {
- $this->setString('password', $password);
- }
-
- /** Returns the password. */
- public function getPassword($password) {
- return $this->password;
- }
-
- /** Sets the insert SQL. */
- public function setInsertSQL($sql) {
- $this->setString('insertSQL', $sql);
- }
-
- /** Returns the insert SQL. */
- public function getInsertSQL($sql) {
- return $this->insertSQL;
- }
-
- /** Sets the insert pattern. */
- public function setInsertPattern($pattern) {
- $this->setString('insertPattern', $pattern);
- }
-
- /** Returns the insert pattern. */
- public function getInsertPattern($pattern) {
- return $this->insertPattern;
- }
-
- /** Sets the table name. */
- public function setTable($table) {
- $this->setString('table', $table);
- }
-
- /** Returns the table name. */
- public function getTable($table) {
- return $this->table;
- }
-
- /** Sets the DSN string. */
- public function setDSN($dsn) {
- $this->setString('dsn', $dsn);
- }
-
- /** Returns the DSN string. */
- public function getDSN($dsn) {
- return $this->setString('dsn', $dsn);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderPhp.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderPhp.php b/src/main/php/appenders/LoggerAppenderPhp.php
deleted file mode 100644
index 7758405..0000000
--- a/src/main/php/appenders/LoggerAppenderPhp.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderPhp logs events by creating a PHP user-level message using
- * the PHP's trigger_error()function.
- *
- * This appender has no configurable parameters.
- *
- * Levels are mapped as follows:
- *
- * - <b>level < WARN</b> mapped to E_USER_NOTICE
- * - <b>WARN <= level < ERROR</b> mapped to E_USER_WARNING
- * - <b>level >= ERROR</b> mapped to E_USER_ERROR
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation
- */
-class LoggerAppenderPhp extends LoggerAppender {
-
- 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);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderRollingFile.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderRollingFile.php b/src/main/php/appenders/LoggerAppenderRollingFile.php
deleted file mode 100644
index 80b6462..0000000
--- a/src/main/php/appenders/LoggerAppenderRollingFile.php
+++ /dev/null
@@ -1,305 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * LoggerAppenderRollingFile writes logging events to a specified file. The
- * file is rolled over after a specified size has been reached.
- *
- * This appender uses a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **file** - Path to the target file.
- * - **append** - If set to true, the appender will append to the file,
- * otherwise the file contents will be overwritten.
- * - **maxBackupIndex** - Maximum number of backup files to keep. Default is 1.
- * - **maxFileSize** - Maximum allowed file size (in bytes) before rolling
- * over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.
- * Default is 10M.
- * - **compress** - If set to true, rolled-over files will be compressed.
- * Requires the zlib extension.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/rolling-file.html Appender documentation
- */
-class LoggerAppenderRollingFile extends LoggerAppenderFile {
-
- /** Compressing backup files is done in chunks, this determines how large. */
- const COMPRESS_CHUNK_SIZE = 102400; // 100KB
-
- /**
- * The maximum size (in bytes) that the output file is allowed to reach
- * before being rolled over to backup files.
- *
- * The default maximum file size is 10MB (10485760 bytes). Maximum value
- * for this option may depend on the file system.
- *
- * @var integer
- */
- protected $maxFileSize = 10485760;
-
- /**
- * Set the maximum number of backup files to keep around.
- *
- * Determines how many backup files are kept before the oldest is erased.
- * This option takes a positive integer value. If set to zero, then there
- * will be no backup files and the log file will be truncated when it
- * reaches <var>maxFileSize</var>.
- *
- * There is one backup file by default.
- *
- * @var integer
- */
- protected $maxBackupIndex = 1;
-
- /**
- * The <var>compress</var> parameter determindes the compression with zlib.
- * If set to true, the rollover files are compressed and saved with the .gz extension.
- * @var boolean
- */
- protected $compress = false;
-
- /**
- * Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
- * supports conditional clearing of statistics.
- * @var boolean
- * @see http://php.net/manual/en/function.clearstatcache.php
- */
- private $clearConditional = false;
-
- /**
- * Get the maximum size that the output file is allowed to reach
- * before being rolled over to backup files.
- * @return integer
- */
- public function getMaximumFileSize() {
- return $this->maxFileSize;
- }
-
- public function __construct($name = '') {
- parent::__construct($name);
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
- $this->clearConditional = true;
- }
- }
-
- /**
- * Implements the usual roll over behaviour.
- *
- * If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
- * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
- *
- * If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
- *
- * Rollover must be called while the file is locked so that it is safe for concurrent access.
- *
- * @throws LoggerException If any part of the rollover procedure fails.
- */
- private function rollOver() {
- // If maxBackups <= 0, then there is no file renaming to be done.
- if($this->maxBackupIndex > 0) {
- // Delete the oldest file, to keep Windows happy.
- $file = $this->file . '.' . $this->maxBackupIndex;
-
- if (file_exists($file) && !unlink($file)) {
- throw new LoggerException("Unable to delete oldest backup file from [$file].");
- }
-
- // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- $this->renameArchievedLogs($this->file);
-
- // Backup the active file
- $this->moveToBackup($this->file);
- }
-
- // Truncate the active file
- ftruncate($this->fp, 0);
- rewind($this->fp);
- }
-
- private function moveToBackup($source) {
- if ($this->compress) {
- $target = $source . '.1.gz';
- $this->compressFile($source, $target);
- } else {
- $target = $source . '.1';
- copy($source, $target);
- }
- }
-
- private function compressFile($source, $target) {
- $target = 'compress.zlib://' . $target;
-
- $fin = fopen($source, 'rb');
- if ($fin === false) {
- throw new LoggerException("Unable to open file for reading: [$source].");
- }
-
- $fout = fopen($target, 'wb');
- if ($fout === false) {
- throw new LoggerException("Unable to open file for writing: [$target].");
- }
-
- while (!feof($fin)) {
- $chunk = fread($fin, self::COMPRESS_CHUNK_SIZE);
- if (false === fwrite($fout, $chunk)) {
- throw new LoggerException("Failed writing to compressed file.");
- }
- }
-
- fclose($fin);
- fclose($fout);
- }
-
- private function renameArchievedLogs($fileName) {
- for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
-
- $source = $fileName . "." . $i;
- if ($this->compress) {
- $source .= '.gz';
- }
-
- if(file_exists($source)) {
- $target = $fileName . '.' . ($i + 1);
- if ($this->compress) {
- $target .= '.gz';
- }
-
- rename($source, $target);
- }
- }
- }
-
- /**
- * Writes a string to the target file. Opens file if not already open.
- * @param string $string Data to write.
- */
- protected function write($string) {
- // Lazy file open
- if(!isset($this->fp)) {
- if ($this->openFile() === false) {
- return; // Do not write if file open failed.
- }
- }
-
- // Lock the file while writing and possible rolling over
- if(flock($this->fp, LOCK_EX)) {
-
- // Write to locked file
- if(fwrite($this->fp, $string) === false) {
- $this->warn("Failed writing to file. Closing appender.");
- $this->closed = true;
- }
-
- // Stats cache must be cleared, otherwise filesize() returns cached results
- // If supported (PHP 5.3+), clear only the state cache for the target file
- if ($this->clearConditional) {
- clearstatcache(true, $this->file);
- } else {
- clearstatcache();
- }
-
- // Rollover if needed
- if (filesize($this->file) > $this->maxFileSize) {
- try {
- $this->rollOver();
- } catch (LoggerException $ex) {
- $this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
- $this->closed = true;
- }
- }
-
- flock($this->fp, LOCK_UN);
- } else {
- $this->warn("Failed locking file for writing. Closing appender.");
- $this->closed = true;
- }
- }
-
- public function activateOptions() {
- parent::activateOptions();
-
- if ($this->compress && !extension_loaded('zlib')) {
- $this->warn("The 'zlib' extension is required for file compression. Disabling compression.");
- $this->compression = false;
- }
- }
-
- /**
- * Set the 'maxBackupIndex' parameter.
- * @param integer $maxBackupIndex
- */
- public function setMaxBackupIndex($maxBackupIndex) {
- $this->setPositiveInteger('maxBackupIndex', $maxBackupIndex);
- }
-
- /**
- * Returns the 'maxBackupIndex' parameter.
- * @return integer
- */
- public function getMaxBackupIndex() {
- return $this->maxBackupIndex;
- }
-
- /**
- * Set the 'maxFileSize' parameter.
- * @param mixed $maxFileSize
- */
- public function setMaxFileSize($maxFileSize) {
- $this->setFileSize('maxFileSize', $maxFileSize);
- }
-
- /**
- * Returns the 'maxFileSize' parameter.
- * @return integer
- */
- public function getMaxFileSize() {
- return $this->maxFileSize;
- }
-
- /**
- * Set the 'maxFileSize' parameter (kept for backward compatibility).
- * @param mixed $maxFileSize
- * @deprecated Use setMaxFileSize() instead.
- */
- public function setMaximumFileSize($maxFileSize) {
- $this->warn("The 'maximumFileSize' parameter is deprecated. Use 'maxFileSize' instead.");
- return $this->setMaxFileSize($maxFileSize);
- }
-
- /**
- * Sets the 'compress' parameter.
- * @param boolean $compress
- */
- public function setCompress($compress) {
- $this->setBoolean('compress', $compress);
- }
-
- /**
- * Returns the 'compress' parameter.
- * @param boolean
- */
- public function getCompress() {
- return $this->compress;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderSocket.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderSocket.php b/src/main/php/appenders/LoggerAppenderSocket.php
deleted file mode 100644
index f4d7241..0000000
--- a/src/main/php/appenders/LoggerAppenderSocket.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * LoggerAppenderSocket appends to a network socket.
- *
- * ## Configurable parameters: ##
- *
- * - **remoteHost** - Target remote host.
- * - **port** - Target port (optional, defaults to 4446).
- * - **timeout** - Connection timeout in seconds (optional, defaults to
- * 'default_socket_timeout' from php.ini)
- *
- * The socket will by default be opened in blocking mode.
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/socket.html Appender documentation
- */
-class LoggerAppenderSocket extends LoggerAppender {
-
- /**
- * Target host.
- * @see http://php.net/manual/en/function.fsockopen.php
- */
- protected $remoteHost;
-
- /** Target port */
- protected $port = 4446;
-
- /** Connection timeout in ms. */
- protected $timeout;
-
- // ******************************************
- // *** Appender methods ***
- // ******************************************
-
- /** Override the default layout to use serialized. */
- public function getDefaultLayout() {
- return new LoggerLayoutSerialized();
- }
-
- public function activateOptions() {
- if (empty($this->remoteHost)) {
- $this->warn("Required parameter [remoteHost] not set. Closing appender.");
- $this->closed = true;
- return;
- }
-
- if (empty($this->timeout)) {
- $this->timeout = ini_get("default_socket_timeout");
- }
-
- $this->closed = false;
- }
-
- public function append(LoggerLoggingEvent $event) {
- $socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
- if ($socket === false) {
- $this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
- $this->closed = true;
- return;
- }
-
- if (false === fwrite($socket, $this->layout->format($event))) {
- $this->warn("Error writing to socket. Closing appender.");
- $this->closed = true;
- }
- fclose($socket);
- }
-
- // ******************************************
- // *** Accessor methods ***
- // ******************************************
-
- /** Sets the target host. */
- public function setRemoteHost($hostname) {
- $this->setString('remoteHost', $hostname);
- }
-
- /** Sets the target port */
- public function setPort($port) {
- $this->setPositiveInteger('port', $port);
- }
-
- /** Sets the timeout. */
- public function setTimeout($timeout) {
- $this->setPositiveInteger('timeout', $timeout);
- }
-
- /** Returns the target host. */
- public function getRemoteHost() {
- return $this->getRemoteHost();
- }
-
- /** Returns the target port. */
- public function getPort() {
- return $this->port;
- }
-
- /** Returns the timeout */
- public function getTimeout() {
- return $this->timeout;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/appenders/LoggerAppenderSyslog.php
----------------------------------------------------------------------
diff --git a/src/main/php/appenders/LoggerAppenderSyslog.php b/src/main/php/appenders/LoggerAppenderSyslog.php
deleted file mode 100644
index 38d98f2..0000000
--- a/src/main/php/appenders/LoggerAppenderSyslog.php
+++ /dev/null
@@ -1,303 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Log events to a system log using the PHP syslog() function.
- *
- * This appenders requires a layout.
- *
- * ## Configurable parameters: ##
- *
- * - **ident** - The ident of the syslog message.
- * - **priority** - The priority for the syslog message (used when overriding
- * priority).
- * - **facility** - The facility for the syslog message
- * - **overridePriority** - If set to true, the message priority will always
- * use the value defined in {@link $priority}, otherwise the priority will
- * be determined by the message's log level.
- * - **option** - The option value for the syslog message.
- *
- * Recognised syslog options are:
- *
- * - CONS - if there is an error while sending data to the system logger, write directly to the system console
- * - NDELAY - open the connection to the logger immediately
- * - ODELAY - delay opening the connection until the first message is logged (default)
- * - PERROR - print log message also to standard error
- * - PID - include PID with each message
- *
- * Multiple options can be set by delimiting them with a pipe character,
- * e.g.: "CONS|PID|PERROR".
- *
- * Recognised syslog priorities are:
- *
- * - EMERG
- * - ALERT
- * - CRIT
- * - ERR
- * - WARNING
- * - NOTICE
- * - INFO
- * - DEBUG
- *
- * Levels are mapped as follows:
- *
- * - <b>FATAL</b> to LOG_ALERT
- * - <b>ERROR</b> to LOG_ERR
- * - <b>WARN</b> to LOG_WARNING
- * - <b>INFO</b> to LOG_INFO
- * - <b>DEBUG</b> to LOG_DEBUG
- * - <b>TRACE</b> to LOG_DEBUG
- *
- * @version $Revision$
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @link http://logging.apache.org/log4php/docs/appenders/syslog.html Appender documentation
- */
-class LoggerAppenderSyslog extends LoggerAppender {
-
- /**
- * The ident string is added to each message. Typically the name of your application.
- *
- * @var string
- */
- protected $ident = "Apache log4php";
-
- /**
- * The syslog priority to use when overriding priority. This setting is
- * required if {@link overridePriority} is set to true.
- *
- * @var string
- */
- protected $priority;
-
- /**
- * The option used when opening the syslog connection.
- *
- * @var string
- */
- protected $option = 'PID|CONS';
-
- /**
- * The facility value indicates the source of the message.
- *
- * @var string
- */
- protected $facility = 'USER';
-
- /**
- * If set to true, the message priority will always use the value defined
- * in {@link $priority}, otherwise the priority will be determined by the
- * message's log level.
- *
- * @var string
- */
- protected $overridePriority = false;
-
- /**
- * Holds the int value of the {@link $priority}.
- * @var int
- */
- private $intPriority;
-
- /**
- * Holds the int value of the {@link $facility}.
- * @var int
- */
- private $intFacility;
-
- /**
- * Holds the int value of the {@link $option}.
- * @var int
- */
- private $intOption;
-
- /**
- * Sets the {@link $ident}.
- *
- * @param string $ident
- */
- public function setIdent($ident) {
- $this->ident = $ident;
- }
-
- /**
- * Sets the {@link $priority}.
- *
- * @param string $priority
- */
- public function setPriority($priority) {
- $this->priority = $priority;
- }
-
- /**
- * Sets the {@link $facility}.
- *
- * @param string $facility
- */
- public function setFacility($facility) {
- $this->facility = $facility;
- }
-
- /**
- * Sets the {@link $overridePriority}.
- *
- * @param string $overridePriority
- */
- public function setOverridePriority($overridePriority) {
- $this->overridePriority = $overridePriority;
- }
-
- /**
- * Sets the 'option' parameter.
- *
- * @param string $option
- */
- public function setOption($option) {
- $this->option = $option;
- }
-
- /**
- * Returns the 'ident' parameter.
- *
- * @return string $ident
- */
- public function getIdent() {
- return $this->ident;
- }
-
- /**
- * Returns the 'priority' parameter.
- *
- * @return string
- */
- public function getPriority() {
- return $this->priority;
- }
-
- /**
- * Returns the 'facility' parameter.
- *
- * @return string
- */
- public function getFacility() {
- return $this->facility;
- }
-
- /**
- * Returns the 'overridePriority' parameter.
- *
- * @return string
- */
- public function getOverridePriority() {
- return $this->overridePriority;
- }
-
- /**
- * Returns the 'option' parameter.
- *
- * @return string
- */
- public function getOption() {
- return $this->option;
- }
-
-
- public function activateOptions() {
- $this->intPriority = $this->parsePriority();
- $this->intOption = $this->parseOption();
- $this->intFacility = $this->parseFacility();
-
- $this->closed = false;
- }
-
- public function close() {
- if($this->closed != true) {
- closelog();
- $this->closed = true;
- }
- }
-
- /**
- * Appends the event to syslog.
- *
- * Log is opened and closed each time because if it is not closed, it
- * can cause the Apache httpd server to log to whatever ident/facility
- * was used in openlog().
- *
- * @see http://www.php.net/manual/en/function.syslog.php#97843
- */
- public function append(LoggerLoggingEvent $event) {
- $priority = $this->getSyslogPriority($event->getLevel());
- $message = $this->layout->format($event);
-
- openlog($this->ident, $this->intOption, $this->intFacility);
- syslog($priority, $message);
- closelog();
- }
-
- /** Determines which syslog priority to use based on the given level. */
- private function getSyslogPriority(LoggerLevel $level) {
- if($this->overridePriority) {
- return $this->intPriority;
- }
- return $level->getSyslogEquivalent();
- }
-
- /** Parses a syslog option string and returns the correspodning int value. */
- private function parseOption() {
- $value = 0;
- $options = explode('|', $this->option);
-
- foreach($options as $option) {
- if (!empty($option)) {
- $constant = "LOG_" . trim($option);
- if (defined($constant)) {
- $value |= constant($constant);
- } else {
- trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING);
- }
- }
- }
- return $value;
- }
-
- /** Parses the facility string and returns the corresponding int value. */
- private function parseFacility() {
- if (!empty($this->facility)) {
- $constant = "LOG_" . trim($this->facility);
- if (defined($constant)) {
- return constant($constant);
- } else {
- trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING);
- }
- }
- }
-
- /** Parses the priority string and returns the corresponding int value. */
- private function parsePriority() {
- if (!empty($this->priority)) {
- $constant = "LOG_" . trim($this->priority);
- if (defined($constant)) {
- return constant($constant);
- } else {
- trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/configurators/LoggerConfigurationAdapter.php
----------------------------------------------------------------------
diff --git a/src/main/php/configurators/LoggerConfigurationAdapter.php b/src/main/php/configurators/LoggerConfigurationAdapter.php
deleted file mode 100644
index ab87923..0000000
--- a/src/main/php/configurators/LoggerConfigurationAdapter.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * The interface for configurator adapters.
- *
- * Adapters convert configuration in several formats such as XML, ini and PHP
- * file to a PHP array.
- *
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @since 2.2
- */
-interface LoggerConfigurationAdapter
-{
- /** Converts the configuration file to PHP format usable by the configurator. */
- public function convert($input);
-
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/configurators/LoggerConfigurationAdapterINI.php
----------------------------------------------------------------------
diff --git a/src/main/php/configurators/LoggerConfigurationAdapterINI.php b/src/main/php/configurators/LoggerConfigurationAdapterINI.php
deleted file mode 100644
index aaeadf8..0000000
--- a/src/main/php/configurators/LoggerConfigurationAdapterINI.php
+++ /dev/null
@@ -1,299 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Converts ini configuration files to a PHP array.
- *
- * These used to be called "properties" files (inherited from log4j), and that
- * file extension is still supported.
- *
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @since 2.2
- */
-class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
-
- /** Name to assign to the root logger. */
- const ROOT_LOGGER_NAME = "root";
-
- /** Prefix used for defining logger additivity. */
- const ADDITIVITY_PREFIX = "log4php.additivity.";
-
- /** Prefix used for defining logger threshold. */
- const THRESHOLD_PREFIX = "log4php.threshold";
-
- /** Prefix used for defining the root logger. */
- const ROOT_LOGGER_PREFIX = "log4php.rootLogger";
-
- /** Prefix used for defining a logger. */
- const LOGGER_PREFIX = "log4php.logger.";
-
- /** Prefix used for defining an appender. */
- const APPENDER_PREFIX = "log4php.appender.";
-
- /** Prefix used for defining a renderer. */
- const RENDERER_PREFIX = "log4php.renderer.";
-
- /** Holds the configuration. */
- private $config = array();
-
- /**
- * Loads and parses the INI configuration file.
- *
- * @param string $url Path to the config file.
- * @throws LoggerException
- */
- private function load($url) {
- if (!file_exists($url)) {
- throw new LoggerException("File [$url] does not exist.");
- }
-
- $properties = @parse_ini_file($url, true);
- if ($properties === false) {
- $error = error_get_last();
- throw new LoggerException("Error parsing configuration file: {$error['message']}");
- }
-
- return $properties;
- }
-
- /**
- * Converts the provided INI configuration file to a PHP array config.
- *
- * @param string $path Path to the config file.
- * @throws LoggerException If the file cannot be loaded or parsed.
- */
- public function convert($path) {
- // Load the configuration
- $properties = $this->load($path);
-
- // Parse threshold
- if (isset($properties[self::THRESHOLD_PREFIX])) {
- $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX];
- }
-
- // Parse root logger
- if (isset($properties[self::ROOT_LOGGER_PREFIX])) {
- $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME);
- }
-
- $appenders = array();
-
- foreach($properties as $key => $value) {
- // Parse loggers
- if ($this->beginsWith($key, self::LOGGER_PREFIX)) {
- $name = substr($key, strlen(self::LOGGER_PREFIX));
- $this->parseLogger($value, $name);
- }
-
- // Parse additivity
- if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) {
- $name = substr($key, strlen(self::ADDITIVITY_PREFIX));
- $this->config['loggers'][$name]['additivity'] = $value;
- }
-
- // Parse appenders
- else if ($this->beginsWith($key, self::APPENDER_PREFIX)) {
- $this->parseAppender($key, $value);
- }
-
- // Parse renderers
- else if ($this->beginsWith($key, self::RENDERER_PREFIX)) {
- $this->parseRenderer($key, $value);
- }
- }
-
- return $this->config;
- }
-
-
- /**
- * Parses a logger definition.
- *
- * Loggers are defined in the following manner:
- * <pre>
- * log4php.logger.<name> = [<level>], [<appender-ref>, <appender-ref>, ...]
- * </pre>
- *
- * @param string $value The configuration value (level and appender-refs).
- * @param string $name Logger name.
- */
- private function parseLogger($value, $name) {
- // Value is divided by commas
- $parts = explode(',', $value);
- if (empty($value) || empty($parts)) {
- return;
- }
-
- // The first value is the logger level
- $level = array_shift($parts);
-
- // The remaining values are appender references
- $appenders = array();
- while($appender = array_shift($parts)) {
- $appender = trim($appender);
- if (!empty($appender)) {
- $appenders[] = trim($appender);
- }
- }
-
- // Find the target configuration
- if ($name == self::ROOT_LOGGER_NAME) {
- $this->config['rootLogger']['level'] = trim($level);
- $this->config['rootLogger']['appenders'] = $appenders;
- } else {
- $this->config['loggers'][$name]['level'] = trim($level);
- $this->config['loggers'][$name]['appenders'] = $appenders;
- }
- }
-
- /**
- * Parses an configuration line pertaining to an appender.
- *
- * Parses the following patterns:
- *
- * Appender class:
- * <pre>
- * log4php.appender.<name> = <class>
- * </pre>
- *
- * Appender parameter:
- * <pre>
- * log4php.appender.<name>.<param> = <value>
- * </pre>
- *
- * Appender threshold:
- * <pre>
- * log4php.appender.<name>.threshold = <level>
- * </pre>
- *
- * Appender layout:
- * <pre>
- * log4php.appender.<name>.layout = <layoutClass>
- * </pre>
- *
- * Layout parameter:
- * <pre>
- * log4php.appender.<name>.layout.<param> = <value>
- * </pre>
- *
- * For example, a full appender config might look like:
- * <pre>
- * log4php.appender.myAppender = LoggerAppenderConsole
- * log4php.appender.myAppender.threshold = info
- * log4php.appender.myAppender.target = stdout
- * log4php.appender.myAppender.layout = LoggerLayoutPattern
- * log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n"
- * </pre>
- *
- * After parsing all these options, the following configuration can be
- * found under $this->config['appenders']['myAppender']:
- * <pre>
- * array(
- * 'class' => LoggerAppenderConsole,
- * 'threshold' => info,
- * 'params' => array(
- * 'target' => 'stdout'
- * ),
- * 'layout' => array(
- * 'class' => 'LoggerAppenderConsole',
- * 'params' => array(
- * 'conversionPattern' => '%d %c: %m%n'
- * )
- * )
- * )
- * </pre>
- *
- * @param string $key
- * @param string $value
- */
- private function parseAppender($key, $value) {
-
- // Remove the appender prefix from key
- $subKey = substr($key, strlen(self::APPENDER_PREFIX));
-
- // Divide the string by dots
- $parts = explode('.', $subKey);
- $count = count($parts);
-
- // The first part is always the appender name
- $name = trim($parts[0]);
-
- // Only one part - this line defines the appender class
- if ($count == 1) {
- $this->config['appenders'][$name]['class'] = $value;
- return;
- }
-
- // Two parts - either a parameter, a threshold or layout class
- else if ($count == 2) {
-
- if ($parts[1] == 'layout') {
- $this->config['appenders'][$name]['layout']['class'] = $value;
- return;
- } else if ($parts[1] == 'threshold') {
- $this->config['appenders'][$name]['threshold'] = $value;
- return;
- } else {
- $this->config['appenders'][$name]['params'][$parts[1]] = $value;
- return;
- }
- }
-
- // Three parts - this can only be a layout parameter
- else if ($count == 3) {
- if ($parts[1] == 'layout') {
- $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
- return;
- }
- }
-
- trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
- }
-
- /**
- * Parses a renderer definition.
- *
- * Renderers are defined as:
- * <pre>
- * log4php.renderer.<renderedClass> = <renderingClass>
- * </pre>
- *
- * @param string $key log4php.renderer.<renderedClass>
- * @param string $value <renderingClass>
- */
- private function parseRenderer($key, $value) {
- // Remove the appender prefix from key
- $renderedClass = substr($key, strlen(self::APPENDER_PREFIX));
- $renderingClass = $value;
-
- $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
- }
-
- /** Helper method. Returns true if $str begins with $sub. */
- private function beginsWith($str, $sub) {
- return (strncmp($str, $sub, strlen($sub)) == 0);
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/configurators/LoggerConfigurationAdapterPHP.php
----------------------------------------------------------------------
diff --git a/src/main/php/configurators/LoggerConfigurationAdapterPHP.php b/src/main/php/configurators/LoggerConfigurationAdapterPHP.php
deleted file mode 100644
index 3320409..0000000
--- a/src/main/php/configurators/LoggerConfigurationAdapterPHP.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Converts PHP configuration files to a PHP array.
- *
- * The file should only hold the PHP config array preceded by "return".
- *
- * Example PHP config file:
- * <code>
- * <?php
- * return array(
- * 'rootLogger' => array(
- * 'level' => 'info',
- * 'appenders' => array('default')
- * ),
- * 'appenders' => array(
- * 'default' => array(
- * 'class' => 'LoggerAppenderEcho',
- * 'layout' => array(
- * 'class' => 'LoggerLayoutSimple'
- * )
- * )
- * )
- * )
- * ?>
- * </code>
- *
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @since 2.2
- */
-class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
-{
- public function convert($url) {
- if (!file_exists($url)) {
- throw new LoggerException("File [$url] does not exist.");
- }
-
- // Load the config file
- $data = @file_get_contents($url);
- if ($data === false) {
- $error = error_get_last();
- throw new LoggerException("Error loading config file: {$error['message']}");
- }
-
- $config = @eval('?>' . $data);
-
- if ($config === false) {
- $error = error_get_last();
- throw new LoggerException("Error parsing configuration: " . $error['message']);
- }
-
- if (empty($config)) {
- throw new LoggerException("Invalid configuration: empty configuration array.");
- }
-
- if (!is_array($config)) {
- throw new LoggerException("Invalid configuration: not an array.");
- }
-
- return $config;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/configurators/LoggerConfigurationAdapterXML.php
----------------------------------------------------------------------
diff --git a/src/main/php/configurators/LoggerConfigurationAdapterXML.php b/src/main/php/configurators/LoggerConfigurationAdapterXML.php
deleted file mode 100644
index 7032da6..0000000
--- a/src/main/php/configurators/LoggerConfigurationAdapterXML.php
+++ /dev/null
@@ -1,278 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Converts XML configuration files to a PHP array.
- *
- * @package log4php
- * @subpackage configurators
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @since 2.2
- */
-class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
-{
- /** Path to the XML schema used for validation. */
- const SCHEMA_PATH = '/../xml/log4php.xsd';
-
- private $config = array(
- 'appenders' => array(),
- 'loggers' => array(),
- 'renderers' => array(),
- );
-
- public function convert($url) {
- $xml = $this->loadXML($url);
-
- $this->parseConfiguration($xml);
-
- // Parse the <root> node
- if (isset($xml->root)) {
- $this->parseRootLogger($xml->root);
- }
-
- // Process <logger> nodes
- foreach($xml->logger as $logger) {
- $this->parseLogger($logger);
- }
-
- // Process <appender> nodes
- foreach($xml->appender as $appender) {
- $this->parseAppender($appender);
- }
-
- // Process <renderer> nodes
- foreach($xml->renderer as $rendererNode) {
- $this->parseRenderer($rendererNode);
- }
-
- // Process <defaultRenderer> node
- foreach($xml->defaultRenderer as $rendererNode) {
- $this->parseDefaultRenderer($rendererNode);
- }
-
- return $this->config;
- }
-
- /**
- * Loads and validates the XML.
- * @param string $url Input XML.
- */
- private function loadXML($url) {
- if (!file_exists($url)) {
- throw new LoggerException("File [$url] does not exist.");
- }
-
- libxml_clear_errors();
- $oldValue = libxml_use_internal_errors(true);
-
- // Load XML
- $xml = @simplexml_load_file($url);
- if ($xml === false) {
-
- $errorStr = "";
- foreach(libxml_get_errors() as $error) {
- $errorStr .= $error->message;
- }
-
- throw new LoggerException("Error loading configuration file: " . trim($errorStr));
- }
-
- libxml_clear_errors();
- libxml_use_internal_errors($oldValue);
-
- return $xml;
- }
-
- /**
- * Parses the <configuration> node.
- */
- private function parseConfiguration(SimpleXMLElement $xml) {
- $attributes = $xml->attributes();
- if (isset($attributes['threshold'])) {
- $this->config['threshold'] = (string) $attributes['threshold'];
- }
- }
-
- /** Parses an <appender> node. */
- private function parseAppender(SimpleXMLElement $node) {
- $name = $this->getAttributeValue($node, 'name');
- if (empty($name)) {
- $this->warn("An <appender> node is missing the required 'name' attribute. Skipping appender definition.");
- return;
- }
-
- $appender = array();
- $appender['class'] = $this->getAttributeValue($node, 'class');
-
- if (isset($node['threshold'])) {
- $appender['threshold'] = $this->getAttributeValue($node, 'threshold');
- }
-
- if (isset($node->layout)) {
- $appender['layout']= $this->parseLayout($node->layout, $name);
- }
-
- if (count($node->param) > 0) {
- $appender['params'] = $this->parseParameters($node);
- }
-
- foreach($node->filter as $filterNode) {
- $appender['filters'][] = $this->parseFilter($filterNode);
- }
-
- $this->config['appenders'][$name] = $appender;
- }
-
- /** Parses a <layout> node. */
- private function parseLayout(SimpleXMLElement $node, $appenderName) {
- $layout = array();
- $layout['class'] = $this->getAttributeValue($node, 'class');
-
- if (count($node->param) > 0) {
- $layout['params'] = $this->parseParameters($node);
- }
-
- return $layout;
- }
- /** Parses any <param> child nodes returning them in an array. */
- private function parseParameters($paramsNode) {
- $params = array();
-
- foreach($paramsNode->param as $paramNode) {
- if (empty($paramNode['name'])) {
- $this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
- continue;
- }
-
- $name = $this->getAttributeValue($paramNode, 'name');
- $value = $this->getAttributeValue($paramNode, 'value');
-
- $params[$name] = $value;
- }
-
- return $params;
- }
-
- /** Parses a <root> node. */
- private function parseRootLogger(SimpleXMLElement $node) {
- $logger = array();
-
- if (isset($node->level)) {
- $logger['level'] = $this->getAttributeValue($node->level, 'value');
- }
-
- $logger['appenders'] = $this->parseAppenderReferences($node);
-
- $this->config['rootLogger'] = $logger;
- }
-
- /** Parses a <logger> node. */
- private function parseLogger(SimpleXMLElement $node) {
- $logger = array();
-
- $name = $this->getAttributeValue($node, 'name');
- if (empty($name)) {
- $this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
- return;
- }
-
- if (isset($node->level)) {
- $logger['level'] = $this->getAttributeValue($node->level, 'value');
- }
-
- if (isset($node['additivity'])) {
- $logger['additivity'] = $this->getAttributeValue($node, 'additivity');
- }
-
- $logger['appenders'] = $this->parseAppenderReferences($node);
-
- // Check for duplicate loggers
- if (isset($this->config['loggers'][$name])) {
- $this->warn("Duplicate logger definition [$name]. Overwriting.");
- }
-
- $this->config['loggers'][$name] = $logger;
- }
-
- /**
- * Parses a <logger> node for appender references and returns them in an array.
- *
- * Previous versions supported appender-ref, as well as appender_ref so both
- * are parsed for backward compatibility.
- */
- private function parseAppenderReferences(SimpleXMLElement $node) {
- $refs = array();
- foreach($node->appender_ref as $ref) {
- $refs[] = $this->getAttributeValue($ref, 'ref');
- }
-
- foreach($node->{'appender-ref'} as $ref) {
- $refs[] = $this->getAttributeValue($ref, 'ref');
- }
-
- return $refs;
- }
-
- /** Parses a <filter> node. */
- private function parseFilter($filterNode) {
- $filter = array();
- $filter['class'] = $this->getAttributeValue($filterNode, 'class');
-
- if (count($filterNode->param) > 0) {
- $filter['params'] = $this->parseParameters($filterNode);
- }
-
- return $filter;
- }
-
- /** Parses a <renderer> node. */
- private function parseRenderer(SimpleXMLElement $node) {
- $renderedClass = $this->getAttributeValue($node, 'renderedClass');
- $renderingClass = $this->getAttributeValue($node, 'renderingClass');
-
- $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
- }
-
- /** Parses a <defaultRenderer> node. */
- private function parseDefaultRenderer(SimpleXMLElement $node) {
- $renderingClass = $this->getAttributeValue($node, 'renderingClass');
-
- // Warn on duplicates
- if(isset($this->config['defaultRenderer'])) {
- $this->warn("Duplicate <defaultRenderer> node. Overwriting.");
- }
-
- $this->config['defaultRenderer'] = $renderingClass;
- }
-
- // ******************************************
- // ** Helper methods **
- // ******************************************
-
- private function getAttributeValue(SimpleXMLElement $node, $name) {
- return isset($node[$name]) ? (string) $node[$name] : null;
- }
-
- private function warn($message) {
- trigger_error("log4php: " . $message, E_USER_WARNING);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/configurators/LoggerConfiguratorDefault.php
----------------------------------------------------------------------
diff --git a/src/main/php/configurators/LoggerConfiguratorDefault.php b/src/main/php/configurators/LoggerConfiguratorDefault.php
deleted file mode 100644
index f78b797..0000000
--- a/src/main/php/configurators/LoggerConfiguratorDefault.php
+++ /dev/null
@@ -1,477 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Default implementation of the logger configurator.
- *
- * Configures log4php based on a provided configuration file or array.
- *
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @since 2.2
- */
-class LoggerConfiguratorDefault implements LoggerConfigurator
-{
- /** XML configuration file format. */
- const FORMAT_XML = 'xml';
-
- /** PHP configuration file format. */
- const FORMAT_PHP = 'php';
-
- /** INI (properties) configuration file format. */
- const FORMAT_INI = 'ini';
-
- /** Defines which adapter should be used for parsing which format. */
- private $adapters = array(
- self::FORMAT_XML => 'LoggerConfigurationAdapterXML',
- self::FORMAT_INI => 'LoggerConfigurationAdapterINI',
- self::FORMAT_PHP => 'LoggerConfigurationAdapterPHP',
- );
-
- /** Default configuration; used if no configuration file is provided. */
- private static $defaultConfiguration = array(
- 'threshold' => 'ALL',
- 'rootLogger' => array(
- 'level' => 'DEBUG',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho'
- ),
- ),
- );
-
- /** Holds the appenders before they are linked to loggers. */
- private $appenders = array();
-
- /**
- * Configures log4php based on the given configuration. The input can
- * either be a path to the config file, or a PHP array holding the
- * configuration.
- *
- * If no configuration is given, or if the given configuration cannot be
- * parsed for whatever reason, a warning will be issued, and log4php
- * will use the default configuration contained in
- * {@link $defaultConfiguration}.
- *
- * @param LoggerHierarchy $hierarchy The hierarchy on which to perform
- * the configuration.
- * @param string|array $input Either path to the config file or the
- * configuration as an array. If not set, default configuration
- * will be used.
- */
- public function configure(LoggerHierarchy $hierarchy, $input = null) {
- $config = $this->parse($input);
- $this->doConfigure($hierarchy, $config);
- }
-
- /**
- * Parses the given configuration and returns the parsed configuration
- * as a PHP array. Does not perform any configuration.
- *
- * If no configuration is given, or if the given configuration cannot be
- * parsed for whatever reason, a warning will be issued, and the default
- * configuration will be returned ({@link $defaultConfiguration}).
- *
- * @param string|array $input Either path to the config file or the
- * configuration as an array. If not set, default configuration
- * will be used.
- * @return array The parsed configuration.
- */
- public function parse($input) {
- // No input - use default configuration
- if (!isset($input)) {
- $config = self::$defaultConfiguration;
- }
-
- // Array input - contains configuration within the array
- else if (is_array($input)) {
- $config = $input;
- }
-
- // String input - contains path to configuration file
- else if (is_string($input)) {
- try {
- $config = $this->parseFile($input);
- } catch (LoggerException $e) {
- $this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
- $config = self::$defaultConfiguration;
- }
- }
-
- // Anything else is an error
- else {
- $this->warn("Invalid configuration param given. Reverting to default configuration.");
- $config = self::$defaultConfiguration;
- }
-
- return $config;
- }
-
- /**
- * Returns the default log4php configuration.
- * @return array
- */
- public static function getDefaultConfiguration() {
- return self::$defaultConfiguration;
- }
-
- /**
- * Loads the configuration file from the given URL, determines which
- * adapter to use, converts the configuration to a PHP array and
- * returns it.
- *
- * @param string $url Path to the config file.
- * @return The configuration from the config file, as a PHP array.
- * @throws LoggerException If the configuration file cannot be loaded, or
- * if the parsing fails.
- */
- private function parseFile($url) {
-
- if (!file_exists($url)) {
- throw new LoggerException("File not found at [$url].");
- }
-
- $type = $this->getConfigType($url);
- $adapterClass = $this->adapters[$type];
-
- $adapter = new $adapterClass();
- return $adapter->convert($url);
- }
-
- /** Determines configuration file type based on the file extension. */
- private function getConfigType($url) {
- $info = pathinfo($url);
- $ext = strtolower($info['extension']);
-
- switch($ext) {
- case 'xml':
- return self::FORMAT_XML;
-
- case 'ini':
- case 'properties':
- return self::FORMAT_INI;
-
- case 'php':
- return self::FORMAT_PHP;
-
- default:
- throw new LoggerException("Unsupported configuration file extension: $ext");
- }
- }
-
- /**
- * Constructs the logger hierarchy based on configuration.
- *
- * @param LoggerHierarchy $hierarchy
- * @param array $config
- */
- private function doConfigure(LoggerHierarchy $hierarchy, $config) {
- if (isset($config['threshold'])) {
- $threshold = LoggerLevel::toLevel($config['threshold']);
- if (isset($threshold)) {
- $hierarchy->setThreshold($threshold);
- } else {
- $this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
- }
- }
-
- // Configure appenders and add them to the appender pool
- if (isset($config['appenders']) && is_array($config['appenders'])) {
- foreach($config['appenders'] as $name => $appenderConfig) {
- $this->configureAppender($name, $appenderConfig);
- }
- }
-
- // Configure root logger
- if (isset($config['rootLogger'])) {
- $this->configureRootLogger($hierarchy, $config['rootLogger']);
- }
-
- // Configure loggers
- if (isset($config['loggers']) && is_array($config['loggers'])) {
- foreach($config['loggers'] as $loggerName => $loggerConfig) {
- $this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
- }
- }
-
- // Configure renderers
- if (isset($config['renderers']) && is_array($config['renderers'])) {
- foreach($config['renderers'] as $rendererConfig) {
- $this->configureRenderer($hierarchy, $rendererConfig);
- }
- }
-
- if (isset($config['defaultRenderer'])) {
- $this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
- }
- }
-
- private function configureRenderer(LoggerHierarchy $hierarchy, $config) {
- if (empty($config['renderingClass'])) {
- $this->warn("Rendering class not specified. Skipping renderer definition.");
- return;
- }
-
- if (empty($config['renderedClass'])) {
- $this->warn("Rendered class not specified. Skipping renderer definition.");
- return;
- }
-
- // Error handling performed by RendererMap
- $hierarchy->getRendererMap()->addRenderer($config['renderedClass'], $config['renderingClass']);
- }
-
- private function configureDefaultRenderer(LoggerHierarchy $hierarchy, $class) {
- if (empty($class)) {
- $this->warn("Rendering class not specified. Skipping default renderer definition.");
- return;
- }
-
- // Error handling performed by RendererMap
- $hierarchy->getRendererMap()->setDefaultRenderer($class);
- }
-
- /**
- * Configures an appender based on given config and saves it to
- * {@link $appenders} array so it can be later linked to loggers.
- * @param string $name Appender name.
- * @param array $config Appender configuration options.
- */
- private function configureAppender($name, $config) {
-
- // TODO: add this check to other places where it might be useful
- if (!is_array($config)) {
- $type = gettype($config);
- $this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
- return;
- }
-
- // Parse appender class
- $class = $config['class'];
- if (empty($class)) {
- $this->warn("No class given for appender [$name]. Skipping appender definition.");
- return;
- }
- if (!class_exists($class)) {
- $this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
- return;
- }
-
- // Instantiate the appender
- $appender = new $class($name);
- if (!($appender instanceof LoggerAppender)) {
- $this->warn("Invalid class [$class] given for appender [$name]. Not a valid LoggerAppender class. Skipping appender definition.");
- return;
- }
-
- // Parse the appender threshold
- if (isset($config['threshold'])) {
- $threshold = LoggerLevel::toLevel($config['threshold']);
- if ($threshold instanceof LoggerLevel) {
- $appender->setThreshold($threshold);
- } else {
- $this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
- }
- }
-
- // Parse the appender layout
- if ($appender->requiresLayout() && isset($config['layout'])) {
- $this->createAppenderLayout($appender, $config['layout']);
- }
-
- // Parse filters
- if (isset($config['filters']) && is_array($config['filters'])) {
- foreach($config['filters'] as $filterConfig) {
- $this->createAppenderFilter($appender, $filterConfig);
- }
- }
-
- // Set options if any
- if (isset($config['params'])) {
- $this->setOptions($appender, $config['params']);
- }
-
- // Activate and save for later linking to loggers
- $appender->activateOptions();
- $this->appenders[$name] = $appender;
- }
-
- /**
- * Parses layout config, creates the layout and links it to the appender.
- * @param LoggerAppender $appender
- * @param array $config Layout configuration.
- */
- private function createAppenderLayout(LoggerAppender $appender, $config) {
- $name = $appender->getName();
- $class = $config['class'];
- if (empty($class)) {
- $this->warn("Layout class not specified for appender [$name]. Reverting to default layout.");
- return;
- }
- if (!class_exists($class)) {
- $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
- return;
- }
-
- $layout = new $class();
- if (!($layout instanceof LoggerLayout)) {
- $this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout.");
- return;
- }
-
- if (isset($config['params'])) {
- $this->setOptions($layout, $config['params']);
- }
-
- $layout->activateOptions();
- $appender->setLayout($layout);
- }
-
- /**
- * Parses filter config, creates the filter and adds it to the appender's
- * filter chain.
- * @param LoggerAppender $appender
- * @param array $config Filter configuration.
- */
- private function createAppenderFilter(LoggerAppender $appender, $config) {
- $name = $appender->getName();
- $class = $config['class'];
- if (!class_exists($class)) {
- $this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
- return;
- }
-
- $filter = new $class();
- if (!($filter instanceof LoggerFilter)) {
- $this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
- return;
- }
-
- if (isset($config['params'])) {
- $this->setOptions($filter, $config['params']);
- }
-
- $filter->activateOptions();
- $appender->addFilter($filter);
- }
-
- /**
- * Configures the root logger
- * @see configureLogger()
- */
- private function configureRootLogger(LoggerHierarchy $hierarchy, $config) {
- $logger = $hierarchy->getRootLogger();
- $this->configureLogger($logger, $config);
- }
-
- /**
- * Configures a logger which is not root.
- * @see configureLogger()
- */
- private function configureOtherLogger(LoggerHierarchy $hierarchy, $name, $config) {
- // Get logger from hierarchy (this creates it if it doesn't already exist)
- $logger = $hierarchy->getLogger($name);
- $this->configureLogger($logger, $config);
- }
-
- /**
- * Configures a logger.
- *
- * @param Logger $logger The logger to configure
- * @param array $config Logger configuration options.
- */
- private function configureLogger(Logger $logger, $config) {
- $loggerName = $logger->getName();
-
- // Set logger level
- if (isset($config['level'])) {
- $level = LoggerLevel::toLevel($config['level']);
- if (isset($level)) {
- $logger->setLevel($level);
- } else {
- $this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
- }
- }
-
- // Link appenders to logger
- if (isset($config['appenders'])) {
- foreach($config['appenders'] as $appenderName) {
- if (isset($this->appenders[$appenderName])) {
- $logger->addAppender($this->appenders[$appenderName]);
- } else {
- $this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
- }
- }
- }
-
- // Set logger additivity
- if (isset($config['additivity'])) {
- try {
- $additivity = LoggerOptionConverter::toBooleanEx($config['additivity'], null);
- $logger->setAdditivity($additivity);
- } catch (Exception $ex) {
- $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
- }
- }
- }
-
- /**
- * Helper method which applies given options to an object which has setters
- * for these options (such as appenders, layouts, etc.).
- *
- * For example, if options are:
- * <code>
- * array(
- * 'file' => '/tmp/myfile.log',
- * 'append' => true
- * )
- * </code>
- *
- * This method will call:
- * <code>
- * $object->setFile('/tmp/myfile.log')
- * $object->setAppend(true)
- * </code>
- *
- * If required setters do not exist, it will produce a warning.
- *
- * @param mixed $object The object to configure.
- * @param unknown_type $options
- */
- private function setOptions($object, $options) {
- foreach($options as $name => $value) {
- $setter = "set$name";
- if (method_exists($object, $setter)) {
- $object->$setter($value);
- } else {
- $class = get_class($object);
- $this->warn("Nonexistant option [$name] specified on [$class]. Skipping.");
- }
- }
- }
-
- /** Helper method to simplify error reporting. */
- private function warn($message) {
- trigger_error("log4php: $message", E_USER_WARNING);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/filters/LoggerFilterDenyAll.php
----------------------------------------------------------------------
diff --git a/src/main/php/filters/LoggerFilterDenyAll.php b/src/main/php/filters/LoggerFilterDenyAll.php
deleted file mode 100644
index c8c73fa..0000000
--- a/src/main/php/filters/LoggerFilterDenyAll.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * This filter drops all logging events.
- *
- * You can add this filter to the end of a filter chain to
- * switch from the default "accept all unless instructed otherwise"
- * filtering behaviour to a "deny all unless instructed otherwise"
- * behaviour.
- *
- * <p>
- * An example for this filter:
- *
- * {@example ../../examples/php/filter_denyall.php 19}
- *
- * <p>
- * The corresponding XML file:
- *
- * {@example ../../examples/resources/filter_denyall.xml 18}
- *
- * @version $Revision$
- * @package log4php
- * @subpackage filters
- * @since 0.3
- */
-class LoggerFilterDenyAll extends LoggerFilter {
-
- /**
- * Always returns the integer constant {@link LoggerFilter::DENY}
- * regardless of the {@link LoggerLoggingEvent} parameter.
- *
- * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter.
- * @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY}
- */
- public function decide(LoggerLoggingEvent $event) {
- return LoggerFilter::DENY;
- }
-}
[36/43] Fixed code formatting to conform to PSR-2
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configuration/DefaultConfigurator.php
----------------------------------------------------------------------
diff --git a/src/Configuration/DefaultConfigurator.php b/src/Configuration/DefaultConfigurator.php
index 9e4e6bd..7ef223b 100644
--- a/src/Configuration/DefaultConfigurator.php
+++ b/src/Configuration/DefaultConfigurator.php
@@ -36,24 +36,24 @@ use Apache\Log4php\LoggerException;
*/
class DefaultConfigurator implements ConfiguratorInterface
{
- /** XML configuration file format. */
- const FORMAT_XML = 'xml';
+ /** XML configuration file format. */
+ const FORMAT_XML = 'xml';
- /** PHP configuration file format. */
- const FORMAT_PHP = 'php';
+ /** PHP configuration file format. */
+ const FORMAT_PHP = 'php';
- /** INI (properties) configuration file format. */
- const FORMAT_INI = 'ini';
+ /** INI (properties) configuration file format. */
+ const FORMAT_INI = 'ini';
- /** Defines which adapter should be used for parsing which format. */
- private $adapters = array(
- self::FORMAT_XML => 'XmlAdapter',
- self::FORMAT_INI => 'IniAdapter',
- self::FORMAT_PHP => 'PhpAdapter',
- );
+ /** Defines which adapter should be used for parsing which format. */
+ private $adapters = array(
+ self::FORMAT_XML => 'XmlAdapter',
+ self::FORMAT_INI => 'IniAdapter',
+ self::FORMAT_PHP => 'PhpAdapter',
+ );
- /** Default configuration; used if no configuration file is provided. */
- private static $defaultConfiguration = array(
+ /** Default configuration; used if no configuration file is provided. */
+ private static $defaultConfiguration = array(
'threshold' => 'ALL',
'rootLogger' => array(
'level' => 'DEBUG',
@@ -64,449 +64,475 @@ class DefaultConfigurator implements ConfiguratorInterface
'class' => '\\Apache\\Log4php\\Appenders\\EchoAppender'
),
),
- );
-
- /** Holds the appenders before they are linked to loggers. */
- private $appenders = array();
-
- /**
- * Configures log4php based on the given configuration. The input can
- * either be a path to the config file, or a PHP array holding the
- * configuration.
- *
- * If no configuration is given, or if the given configuration cannot be
- * parsed for whatever reason, a warning will be issued, and log4php
- * will use the default configuration contained in
- * {@link $defaultConfiguration}.
- *
- * @param Hierarchy $hierarchy The hierarchy on which to perform
- * the configuration.
- * @param string|array $input Either path to the config file or the
- * configuration as an array. If not set, default configuration
- * will be used.
- */
- public function configure(Hierarchy $hierarchy, $input = null) {
- $config = $this->parse($input);
- $this->doConfigure($hierarchy, $config);
- }
-
- /**
- * Parses the given configuration and returns the parsed configuration
- * as a PHP array. Does not perform any configuration.
- *
- * If no configuration is given, or if the given configuration cannot be
- * parsed for whatever reason, a warning will be issued, and the default
- * configuration will be returned ({@link $defaultConfiguration}).
- *
- * @param string|array $input Either path to the config file or the
- * configuration as an array. If not set, default configuration
- * will be used.
- * @return array The parsed configuration.
- */
- public function parse($input) {
- // No input - use default configuration
- if (!isset($input)) {
- $config = self::$defaultConfiguration;
- }
-
- // Array input - contains configuration within the array
- else if (is_array($input)) {
- $config = $input;
- }
-
- // String input - contains path to configuration file
- else if (is_string($input)) {
- try {
- $config = $this->parseFile($input);
- } catch (LoggerException $e) {
- $this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
- $config = self::$defaultConfiguration;
- }
- }
-
- // Anything else is an error
- else {
- $this->warn("Invalid configuration param given. Reverting to default configuration.");
- $config = self::$defaultConfiguration;
- }
-
- return $config;
- }
-
- /**
- * Returns the default log4php configuration.
- * @return array
- */
- public static function getDefaultConfiguration() {
- return self::$defaultConfiguration;
- }
-
- /**
- * Loads the configuration file from the given URL, determines which
- * adapter to use, converts the configuration to a PHP array and
- * returns it.
- *
- * @param string $url Path to the config file.
- * @return The configuration from the config file, as a PHP array.
- * @throws LoggerException If the configuration file cannot be loaded, or
- * if the parsing fails.
- */
- private function parseFile($url) {
-
- if (!file_exists($url)) {
- throw new LoggerException("File not found at [$url].");
- }
-
- $type = $this->getConfigType($url);
- $adapterClass = "Apache\\Log4php\\Configuration\\Adapters\\" . $this->adapters[$type];
-
- $adapter = new $adapterClass();
- return $adapter->convert($url);
- }
-
- /** Determines configuration file type based on the file extension. */
- private function getConfigType($url) {
- $info = pathinfo($url);
- $ext = strtolower($info['extension']);
-
- switch($ext) {
- case 'xml':
- return self::FORMAT_XML;
-
- case 'ini':
- case 'properties':
- return self::FORMAT_INI;
-
- case 'php':
- return self::FORMAT_PHP;
-
- default:
- throw new LoggerException("Unsupported configuration file extension: $ext");
- }
- }
-
- /**
- * Constructs the logger hierarchy based on configuration.
- *
- * @param Hierarchy $hierarchy
- * @param array $config
- */
- private function doConfigure(Hierarchy $hierarchy, $config) {
- if (isset($config['threshold'])) {
- $threshold = Level::toLevel($config['threshold']);
- if (isset($threshold)) {
- $hierarchy->setThreshold($threshold);
- } else {
- $this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
- }
- }
-
- // Configure appenders and add them to the appender pool
- if (isset($config['appenders']) && is_array($config['appenders'])) {
- foreach($config['appenders'] as $name => $appenderConfig) {
- $this->configureAppender($name, $appenderConfig);
- }
- }
-
- // Configure root logger
- if (isset($config['rootLogger'])) {
- $this->configureRootLogger($hierarchy, $config['rootLogger']);
- }
-
- // Configure loggers
- if (isset($config['loggers']) && is_array($config['loggers'])) {
- foreach($config['loggers'] as $loggerName => $loggerConfig) {
- $this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
- }
- }
-
- // Configure renderers
- if (isset($config['renderers']) && is_array($config['renderers'])) {
- foreach($config['renderers'] as $rendererConfig) {
- $this->configureRenderer($hierarchy, $rendererConfig);
- }
- }
-
- if (isset($config['defaultRenderer'])) {
- $this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
- }
- }
-
- private function configureRenderer(Hierarchy $hierarchy, $config) {
- if (empty($config['renderingClass'])) {
- $this->warn("Rendering class not specified. Skipping renderer definition.");
- return;
- }
-
- if (empty($config['renderedClass'])) {
- $this->warn("Rendered class not specified. Skipping renderer definition.");
- return;
- }
-
- // Error handling performed by RendererMap
- $hierarchy->getRendererMap()->addRenderer($config['renderedClass'], $config['renderingClass']);
- }
-
- private function configureDefaultRenderer(Hierarchy $hierarchy, $class) {
- if (empty($class)) {
- $this->warn("Rendering class not specified. Skipping default renderer definition.");
- return;
- }
-
- // Error handling performed by RendererMap
- $hierarchy->getRendererMap()->setDefaultRenderer($class);
- }
-
- /**
- * Configures an appender based on given config and saves it to
- * {@link $appenders} array so it can be later linked to loggers.
- * @param string $name Appender name.
- * @param array $config Appender configuration options.
- */
- private function configureAppender($name, $config) {
-
- // TODO: add this check to other places where it might be useful
- if (!is_array($config)) {
- $type = gettype($config);
- $this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
- return;
- }
-
- // Parse appender class
- $class = $config['class'];
- if (empty($class)) {
- $this->warn("No class given for appender [$name]. Skipping appender definition.");
- return;
- }
-
- // Instantiate the appender
- if (class_exists($class)) {
- $appender = new $class($name);
- } else {
- // Try the default namespace
- $nsClass = "\\Apache\\Log4php\\Appenders\\$class";
- if (class_exists($nsClass)) {
- $appender = new $nsClass($name);
- }
- }
-
- if (!isset($appender)) {
- $this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
- return;
- }
-
- if (!($appender instanceof AbstractAppender)) {
- $this->warn("Invalid class [$class] given for appender [$name]. Not a valid Appender class. Skipping appender definition.");
- return;
- }
-
- // Parse the appender threshold
- if (isset($config['threshold'])) {
- $threshold = Level::toLevel($config['threshold']);
- if ($threshold instanceof Level) {
- $appender->setThreshold($threshold);
- } else {
- $this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
- }
- }
-
- // Parse the appender layout
- if ($appender->requiresLayout() && isset($config['layout'])) {
- $this->createAppenderLayout($appender, $config['layout']);
- }
-
- // Parse filters
- if (isset($config['filters']) && is_array($config['filters'])) {
- foreach($config['filters'] as $filterConfig) {
- $this->createAppenderFilter($appender, $filterConfig);
- }
- }
-
- // Set options if any
- if (isset($config['params'])) {
- $this->setOptions($appender, $config['params']);
- }
-
- // Activate and save for later linking to loggers
- $appender->activateOptions();
- $this->appenders[$name] = $appender;
- }
-
- /**
- * Parses layout config, creates the layout and links it to the appender.
- * @param AbstractAppender $appender
- * @param array $config Layout configuration.
- */
- private function createAppenderLayout(AbstractAppender $appender, $config) {
- $name = $appender->getName();
- $class = $config['class'];
- if (empty($class)) {
- $this->warn("Layout class not specified for appender [$name]. Reverting to default layout.");
- return;
- }
-
- if (class_exists($class)) {
- $layout = new $class();
- } else {
- $nsClass = "Apache\\Log4php\\Layouts\\$class";
- if (class_exists($nsClass)) {
- $layout = new $nsClass();
- }
- }
-
- if (!isset($layout)) {
- $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
- return;
- }
-
-
- if (!($layout instanceof AbstractLayout)) {
- $this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout.");
- return;
- }
-
- if (isset($config['params'])) {
- $this->setOptions($layout, $config['params']);
- }
-
- $layout->activateOptions();
- $appender->setLayout($layout);
- }
-
- /**
- * Parses filter config, creates the filter and adds it to the appender's
- * filter chain.
- * @param Appender $appender
- * @param array $config Filter configuration.
- */
- private function createAppenderFilter(AbstractAppender $appender, $config) {
- $name = $appender->getName();
- $class = $config['class'];
-
- if (class_exists($class)) {
- $filter = new $class();
- } else {
- $nsClass = "Apache\\Log4php\\Filters\\$class";
- if (class_exists($nsClass)) {
- $filter = new $nsClass();
- }
- }
-
- if (!isset($filter)) {
- $this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
- return;
- }
-
- if (!($filter instanceof AbstractFilter)) {
- $this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
- return;
- }
-
- if (isset($config['params'])) {
- $this->setOptions($filter, $config['params']);
- }
-
- $filter->activateOptions();
- $appender->addFilter($filter);
- }
-
- /**
- * Configures the root logger
- * @see configureLogger()
- */
- private function configureRootLogger(Hierarchy $hierarchy, $config) {
- $logger = $hierarchy->getRootLogger();
- $this->configureLogger($logger, $config);
- }
-
- /**
- * Configures a logger which is not root.
- * @see configureLogger()
- */
- private function configureOtherLogger(Hierarchy $hierarchy, $name, $config) {
- // Get logger from hierarchy (this creates it if it doesn't already exist)
- $logger = $hierarchy->getLogger($name);
- $this->configureLogger($logger, $config);
- }
-
- /**
- * Configures a logger.
- *
- * @param Logger $logger The logger to configure
- * @param array $config Logger configuration options.
- */
- private function configureLogger(Logger $logger, $config) {
- $loggerName = $logger->getName();
-
- // Set logger level
- if (isset($config['level'])) {
- $level = Level::toLevel($config['level']);
- if (isset($level)) {
- $logger->setLevel($level);
- } else {
- $this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
- }
- }
-
- // Link appenders to logger
- if (isset($config['appenders'])) {
- foreach($config['appenders'] as $appenderName) {
- if (isset($this->appenders[$appenderName])) {
- $logger->addAppender($this->appenders[$appenderName]);
- } else {
- $this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
- }
- }
- }
-
- // Set logger additivity
- if (isset($config['additivity'])) {
- try {
- $additivity = OptionConverter::toBooleanEx($config['additivity'], null);
- $logger->setAdditivity($additivity);
- } catch (LoggerException $ex) {
- $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
- }
- }
- }
-
- /**
- * Helper method which applies given options to an object which has setters
- * for these options (such as appenders, layouts, etc.).
- *
- * For example, if options are:
- * <code>
- * array(
- * 'file' => '/tmp/myfile.log',
- * 'append' => true
- * )
- * </code>
- *
- * This method will call:
- * <code>
- * $object->setFile('/tmp/myfile.log')
- * $object->setAppend(true)
- * </code>
- *
- * If required setters do not exist, it will produce a warning.
- *
- * @param mixed $object The object to configure.
- * @param unknown_type $options
- */
- private function setOptions($object, $options) {
- foreach($options as $name => $value) {
- $setter = "set$name";
- if (method_exists($object, $setter)) {
- $object->$setter($value);
- } else {
- $class = get_class($object);
- $this->warn("Nonexistant option [$name] specified on [$class]. Skipping.");
- }
- }
- }
-
- /** Helper method to simplify error reporting. */
- private function warn($message) {
- trigger_error("log4php: $message", E_USER_WARNING);
- }
+ );
+
+ /** Holds the appenders before they are linked to loggers. */
+ private $appenders = array();
+
+ /**
+ * Configures log4php based on the given configuration. The input can
+ * either be a path to the config file, or a PHP array holding the
+ * configuration.
+ *
+ * If no configuration is given, or if the given configuration cannot be
+ * parsed for whatever reason, a warning will be issued, and log4php
+ * will use the default configuration contained in
+ * {@link $defaultConfiguration}.
+ *
+ * @param Hierarchy $hierarchy The hierarchy on which to perform
+ * the configuration.
+ * @param string|array $input Either path to the config file or the
+ * configuration as an array. If not set, default configuration
+ * will be used.
+ */
+ public function configure(Hierarchy $hierarchy, $input = null)
+ {
+ $config = $this->parse($input);
+ $this->doConfigure($hierarchy, $config);
+ }
+
+ /**
+ * Parses the given configuration and returns the parsed configuration
+ * as a PHP array. Does not perform any configuration.
+ *
+ * If no configuration is given, or if the given configuration cannot be
+ * parsed for whatever reason, a warning will be issued, and the default
+ * configuration will be returned ({@link $defaultConfiguration}).
+ *
+ * @param string|array $input Either path to the config file or the
+ * configuration as an array. If not set, default configuration
+ * will be used.
+ * @return array The parsed configuration.
+ */
+ public function parse($input)
+ {
+ // No input - use default configuration
+ if (!isset($input)) {
+ $config = self::$defaultConfiguration;
+ }
+
+ // Array input - contains configuration within the array
+ else if (is_array($input)) {
+ $config = $input;
+ }
+
+ // String input - contains path to configuration file
+ else if (is_string($input)) {
+ try {
+ $config = $this->parseFile($input);
+ } catch (LoggerException $e) {
+ $this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
+ $config = self::$defaultConfiguration;
+ }
+ }
+
+ // Anything else is an error
+ else {
+ $this->warn("Invalid configuration param given. Reverting to default configuration.");
+ $config = self::$defaultConfiguration;
+ }
+
+ return $config;
+ }
+
+ /**
+ * Returns the default log4php configuration.
+ * @return array
+ */
+ public static function getDefaultConfiguration()
+ {
+ return self::$defaultConfiguration;
+ }
+
+ /**
+ * Loads the configuration file from the given URL, determines which
+ * adapter to use, converts the configuration to a PHP array and
+ * returns it.
+ *
+ * @param string $url Path to the config file.
+ * @return The configuration from the config file, as a PHP array.
+ * @throws LoggerException If the configuration file cannot be loaded, or
+ * if the parsing fails.
+ */
+ private function parseFile($url)
+ {
+ if (!file_exists($url)) {
+ throw new LoggerException("File not found at [$url].");
+ }
+
+ $type = $this->getConfigType($url);
+ $adapterClass = "Apache\\Log4php\\Configuration\\Adapters\\" . $this->adapters[$type];
+
+ $adapter = new $adapterClass();
+
+ return $adapter->convert($url);
+ }
+
+ /** Determines configuration file type based on the file extension. */
+ private function getConfigType($url)
+ {
+ $info = pathinfo($url);
+ $ext = strtolower($info['extension']);
+
+ switch ($ext) {
+ case 'xml':
+ return self::FORMAT_XML;
+
+ case 'ini':
+ case 'properties':
+ return self::FORMAT_INI;
+
+ case 'php':
+ return self::FORMAT_PHP;
+
+ default:
+ throw new LoggerException("Unsupported configuration file extension: $ext");
+ }
+ }
+
+ /**
+ * Constructs the logger hierarchy based on configuration.
+ *
+ * @param Hierarchy $hierarchy
+ * @param array $config
+ */
+ private function doConfigure(Hierarchy $hierarchy, $config)
+ {
+ if (isset($config['threshold'])) {
+ $threshold = Level::toLevel($config['threshold']);
+ if (isset($threshold)) {
+ $hierarchy->setThreshold($threshold);
+ } else {
+ $this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
+ }
+ }
+
+ // Configure appenders and add them to the appender pool
+ if (isset($config['appenders']) && is_array($config['appenders'])) {
+ foreach ($config['appenders'] as $name => $appenderConfig) {
+ $this->configureAppender($name, $appenderConfig);
+ }
+ }
+
+ // Configure root logger
+ if (isset($config['rootLogger'])) {
+ $this->configureRootLogger($hierarchy, $config['rootLogger']);
+ }
+
+ // Configure loggers
+ if (isset($config['loggers']) && is_array($config['loggers'])) {
+ foreach ($config['loggers'] as $loggerName => $loggerConfig) {
+ $this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
+ }
+ }
+
+ // Configure renderers
+ if (isset($config['renderers']) && is_array($config['renderers'])) {
+ foreach ($config['renderers'] as $rendererConfig) {
+ $this->configureRenderer($hierarchy, $rendererConfig);
+ }
+ }
+
+ if (isset($config['defaultRenderer'])) {
+ $this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
+ }
+ }
+
+ private function configureRenderer(Hierarchy $hierarchy, $config)
+ {
+ if (empty($config['renderingClass'])) {
+ $this->warn("Rendering class not specified. Skipping renderer definition.");
+
+ return;
+ }
+
+ if (empty($config['renderedClass'])) {
+ $this->warn("Rendered class not specified. Skipping renderer definition.");
+
+ return;
+ }
+
+ // Error handling performed by RendererMap
+ $hierarchy->getRendererMap()->addRenderer($config['renderedClass'], $config['renderingClass']);
+ }
+
+ private function configureDefaultRenderer(Hierarchy $hierarchy, $class)
+ {
+ if (empty($class)) {
+ $this->warn("Rendering class not specified. Skipping default renderer definition.");
+
+ return;
+ }
+
+ // Error handling performed by RendererMap
+ $hierarchy->getRendererMap()->setDefaultRenderer($class);
+ }
+
+ /**
+ * Configures an appender based on given config and saves it to
+ * {@link $appenders} array so it can be later linked to loggers.
+ * @param string $name Appender name.
+ * @param array $config Appender configuration options.
+ */
+ private function configureAppender($name, $config)
+ {
+ // TODO: add this check to other places where it might be useful
+ if (!is_array($config)) {
+ $type = gettype($config);
+ $this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
+
+ return;
+ }
+
+ // Parse appender class
+ $class = $config['class'];
+ if (empty($class)) {
+ $this->warn("No class given for appender [$name]. Skipping appender definition.");
+
+ return;
+ }
+
+ // Instantiate the appender
+ if (class_exists($class)) {
+ $appender = new $class($name);
+ } else {
+ // Try the default namespace
+ $nsClass = "\\Apache\\Log4php\\Appenders\\$class";
+ if (class_exists($nsClass)) {
+ $appender = new $nsClass($name);
+ }
+ }
+
+ if (!isset($appender)) {
+ $this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
+
+ return;
+ }
+
+ if (!($appender instanceof AbstractAppender)) {
+ $this->warn("Invalid class [$class] given for appender [$name]. Not a valid Appender class. Skipping appender definition.");
+
+ return;
+ }
+
+ // Parse the appender threshold
+ if (isset($config['threshold'])) {
+ $threshold = Level::toLevel($config['threshold']);
+ if ($threshold instanceof Level) {
+ $appender->setThreshold($threshold);
+ } else {
+ $this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
+ }
+ }
+
+ // Parse the appender layout
+ if ($appender->requiresLayout() && isset($config['layout'])) {
+ $this->createAppenderLayout($appender, $config['layout']);
+ }
+
+ // Parse filters
+ if (isset($config['filters']) && is_array($config['filters'])) {
+ foreach ($config['filters'] as $filterConfig) {
+ $this->createAppenderFilter($appender, $filterConfig);
+ }
+ }
+
+ // Set options if any
+ if (isset($config['params'])) {
+ $this->setOptions($appender, $config['params']);
+ }
+
+ // Activate and save for later linking to loggers
+ $appender->activateOptions();
+ $this->appenders[$name] = $appender;
+ }
+
+ /**
+ * Parses layout config, creates the layout and links it to the appender.
+ * @param AbstractAppender $appender
+ * @param array $config Layout configuration.
+ */
+ private function createAppenderLayout(AbstractAppender $appender, $config)
+ {
+ $name = $appender->getName();
+ $class = $config['class'];
+ if (empty($class)) {
+ $this->warn("Layout class not specified for appender [$name]. Reverting to default layout.");
+
+ return;
+ }
+
+ if (class_exists($class)) {
+ $layout = new $class();
+ } else {
+ $nsClass = "Apache\\Log4php\\Layouts\\$class";
+ if (class_exists($nsClass)) {
+ $layout = new $nsClass();
+ }
+ }
+
+ if (!isset($layout)) {
+ $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
+
+ return;
+ }
+
+ if (!($layout instanceof AbstractLayout)) {
+ $this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout.");
+
+ return;
+ }
+
+ if (isset($config['params'])) {
+ $this->setOptions($layout, $config['params']);
+ }
+
+ $layout->activateOptions();
+ $appender->setLayout($layout);
+ }
+
+ /**
+ * Parses filter config, creates the filter and adds it to the appender's
+ * filter chain.
+ * @param Appender $appender
+ * @param array $config Filter configuration.
+ */
+ private function createAppenderFilter(AbstractAppender $appender, $config)
+ {
+ $name = $appender->getName();
+ $class = $config['class'];
+
+ if (class_exists($class)) {
+ $filter = new $class();
+ } else {
+ $nsClass = "Apache\\Log4php\\Filters\\$class";
+ if (class_exists($nsClass)) {
+ $filter = new $nsClass();
+ }
+ }
+
+ if (!isset($filter)) {
+ $this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
+
+ return;
+ }
+
+ if (!($filter instanceof AbstractFilter)) {
+ $this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
+
+ return;
+ }
+
+ if (isset($config['params'])) {
+ $this->setOptions($filter, $config['params']);
+ }
+
+ $filter->activateOptions();
+ $appender->addFilter($filter);
+ }
+
+ /**
+ * Configures the root logger
+ * @see configureLogger()
+ */
+ private function configureRootLogger(Hierarchy $hierarchy, $config)
+ {
+ $logger = $hierarchy->getRootLogger();
+ $this->configureLogger($logger, $config);
+ }
+
+ /**
+ * Configures a logger which is not root.
+ * @see configureLogger()
+ */
+ private function configureOtherLogger(Hierarchy $hierarchy, $name, $config)
+ {
+ // Get logger from hierarchy (this creates it if it doesn't already exist)
+ $logger = $hierarchy->getLogger($name);
+ $this->configureLogger($logger, $config);
+ }
+
+ /**
+ * Configures a logger.
+ *
+ * @param Logger $logger The logger to configure
+ * @param array $config Logger configuration options.
+ */
+ private function configureLogger(Logger $logger, $config)
+ {
+ $loggerName = $logger->getName();
+
+ // Set logger level
+ if (isset($config['level'])) {
+ $level = Level::toLevel($config['level']);
+ if (isset($level)) {
+ $logger->setLevel($level);
+ } else {
+ $this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
+ }
+ }
+
+ // Link appenders to logger
+ if (isset($config['appenders'])) {
+ foreach ($config['appenders'] as $appenderName) {
+ if (isset($this->appenders[$appenderName])) {
+ $logger->addAppender($this->appenders[$appenderName]);
+ } else {
+ $this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
+ }
+ }
+ }
+
+ // Set logger additivity
+ if (isset($config['additivity'])) {
+ try {
+ $additivity = OptionConverter::toBooleanEx($config['additivity'], null);
+ $logger->setAdditivity($additivity);
+ } catch (LoggerException $ex) {
+ $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
+ }
+ }
+ }
+
+ /**
+ * Helper method which applies given options to an object which has setters
+ * for these options (such as appenders, layouts, etc.).
+ *
+ * For example, if options are:
+ * <code>
+ * array(
+ * 'file' => '/tmp/myfile.log',
+ * 'append' => true
+ * )
+ * </code>
+ *
+ * This method will call:
+ * <code>
+ * $object->setFile('/tmp/myfile.log')
+ * $object->setAppend(true)
+ * </code>
+ *
+ * If required setters do not exist, it will produce a warning.
+ *
+ * @param mixed $object The object to configure.
+ * @param unknown_type $options
+ */
+ private function setOptions($object, $options)
+ {
+ foreach ($options as $name => $value) {
+ $setter = "set$name";
+ if (method_exists($object, $setter)) {
+ $object->$setter($value);
+ } else {
+ $class = get_class($object);
+ $this->warn("Nonexistant option [$name] specified on [$class]. Skipping.");
+ }
+ }
+ }
+
+ /** Helper method to simplify error reporting. */
+ private function warn($message)
+ {
+ trigger_error("log4php: $message", E_USER_WARNING);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configuration/adapters/AdapterInterface.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/AdapterInterface.php b/src/Configuration/adapters/AdapterInterface.php
index f0fea69..15b565a 100644
--- a/src/Configuration/adapters/AdapterInterface.php
+++ b/src/Configuration/adapters/AdapterInterface.php
@@ -29,7 +29,7 @@ namespace Apache\Log4php\Configuration\Adapters;
*/
interface AdapterInterface
{
- /** Converts the configuration file to PHP format usable by the configurator. */
- public function convert($input);
+ /** Converts the configuration file to PHP format usable by the configurator. */
+ public function convert($input);
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configuration/adapters/IniAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/IniAdapter.php b/src/Configuration/adapters/IniAdapter.php
index 61c003b..fcc50e2 100644
--- a/src/Configuration/adapters/IniAdapter.php
+++ b/src/Configuration/adapters/IniAdapter.php
@@ -28,267 +28,276 @@ use Apache\Log4php\LoggerException;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @since 2.2
*/
-class IniAdapter implements AdapterInterface {
-
- /** Name to assign to the root logger. */
- const ROOT_LOGGER_NAME = "root";
-
- /** Prefix used for defining logger additivity. */
- const ADDITIVITY_PREFIX = "log4php.additivity.";
-
- /** Prefix used for defining logger threshold. */
- const THRESHOLD_PREFIX = "log4php.threshold";
-
- /** Prefix used for defining the root logger. */
- const ROOT_LOGGER_PREFIX = "log4php.rootLogger";
-
- /** Prefix used for defining a logger. */
- const LOGGER_PREFIX = "log4php.logger.";
-
- /** Prefix used for defining an appender. */
- const APPENDER_PREFIX = "log4php.appender.";
-
- /** Prefix used for defining a renderer. */
- const RENDERER_PREFIX = "log4php.renderer.";
-
- /** Holds the configuration. */
- private $config = array();
-
- /**
- * Loads and parses the INI configuration file.
- *
- * @param string $url Path to the config file.
- * @throws LoggerException
- */
- private function load($url) {
- if (!file_exists($url)) {
- throw new LoggerException("File [$url] does not exist.");
- }
-
- $properties = @parse_ini_file($url, true);
- if ($properties === false) {
- $error = error_get_last();
- throw new LoggerException("Error parsing configuration file: {$error['message']}");
- }
-
- return $properties;
- }
-
- /**
- * Converts the provided INI configuration file to a PHP array config.
- *
- * @param string $path Path to the config file.
- * @throws LoggerException If the file cannot be loaded or parsed.
- */
- public function convert($path) {
- // Load the configuration
- $properties = $this->load($path);
-
- // Parse threshold
- if (isset($properties[self::THRESHOLD_PREFIX])) {
- $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX];
- }
-
- // Parse root logger
- if (isset($properties[self::ROOT_LOGGER_PREFIX])) {
- $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME);
- }
-
- $appenders = array();
-
- foreach($properties as $key => $value) {
- // Parse loggers
- if ($this->beginsWith($key, self::LOGGER_PREFIX)) {
- $name = substr($key, strlen(self::LOGGER_PREFIX));
- $this->parseLogger($value, $name);
- }
-
- // Parse additivity
- if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) {
- $name = substr($key, strlen(self::ADDITIVITY_PREFIX));
- $this->config['loggers'][$name]['additivity'] = $value;
- }
-
- // Parse appenders
- else if ($this->beginsWith($key, self::APPENDER_PREFIX)) {
- $this->parseAppender($key, $value);
- }
-
- // Parse renderers
- else if ($this->beginsWith($key, self::RENDERER_PREFIX)) {
- $this->parseRenderer($key, $value);
- }
- }
-
- return $this->config;
- }
-
-
- /**
- * Parses a logger definition.
- *
- * Loggers are defined in the following manner:
- * <pre>
- * log4php.logger.<name> = [<level>], [<appender-ref>, <appender-ref>, ...]
- * </pre>
- *
- * @param string $value The configuration value (level and appender-refs).
- * @param string $name Logger name.
- */
- private function parseLogger($value, $name) {
- // Value is divided by commas
- $parts = explode(',', $value);
- if (empty($value) || empty($parts)) {
- return;
- }
-
- // The first value is the logger level
- $level = array_shift($parts);
-
- // The remaining values are appender references
- $appenders = array();
- while($appender = array_shift($parts)) {
- $appender = trim($appender);
- if (!empty($appender)) {
- $appenders[] = trim($appender);
- }
- }
-
- // Find the target configuration
- if ($name == self::ROOT_LOGGER_NAME) {
- $this->config['rootLogger']['level'] = trim($level);
- $this->config['rootLogger']['appenders'] = $appenders;
- } else {
- $this->config['loggers'][$name]['level'] = trim($level);
- $this->config['loggers'][$name]['appenders'] = $appenders;
- }
- }
-
- /**
- * Parses an configuration line pertaining to an appender.
- *
- * Parses the following patterns:
- *
- * Appender class:
- * <pre>
- * log4php.appender.<name> = <class>
- * </pre>
- *
- * Appender parameter:
- * <pre>
- * log4php.appender.<name>.<param> = <value>
- * </pre>
- *
- * Appender threshold:
- * <pre>
- * log4php.appender.<name>.threshold = <level>
- * </pre>
- *
- * Appender layout:
- * <pre>
- * log4php.appender.<name>.layout = <layoutClass>
- * </pre>
- *
- * Layout parameter:
- * <pre>
- * log4php.appender.<name>.layout.<param> = <value>
- * </pre>
- *
- * For example, a full appender config might look like:
- * <pre>
- * log4php.appender.myAppender = ConsoleAppender
- * log4php.appender.myAppender.threshold = info
- * log4php.appender.myAppender.target = stdout
- * log4php.appender.myAppender.layout = PatternLayout
- * log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n"
- * </pre>
- *
- * After parsing all these options, the following configuration can be
- * found under $this->config['appenders']['myAppender']:
- * <pre>
- * array(
- * 'class' => ConsoleAppender,
- * 'threshold' => info,
- * 'params' => array(
- * 'target' => 'stdout'
- * ),
- * 'layout' => array(
- * 'class' => 'ConsoleAppender',
- * 'params' => array(
- * 'conversionPattern' => '%d %c: %m%n'
- * )
- * )
- * )
- * </pre>
- *
- * @param string $key
- * @param string $value
- */
- private function parseAppender($key, $value) {
-
- // Remove the appender prefix from key
- $subKey = substr($key, strlen(self::APPENDER_PREFIX));
-
- // Divide the string by dots
- $parts = explode('.', $subKey);
- $count = count($parts);
-
- // The first part is always the appender name
- $name = trim($parts[0]);
-
- // Only one part - this line defines the appender class
- if ($count == 1) {
- $this->config['appenders'][$name]['class'] = $value;
- return;
- }
-
- // Two parts - either a parameter, a threshold or layout class
- else if ($count == 2) {
-
- if ($parts[1] == 'layout') {
- $this->config['appenders'][$name]['layout']['class'] = $value;
- return;
- } else if ($parts[1] == 'threshold') {
- $this->config['appenders'][$name]['threshold'] = $value;
- return;
- } else {
- $this->config['appenders'][$name]['params'][$parts[1]] = $value;
- return;
- }
- }
-
- // Three parts - this can only be a layout parameter
- else if ($count == 3) {
- if ($parts[1] == 'layout') {
- $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
- return;
- }
- }
-
- trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
- }
-
- /**
- * Parses a renderer definition.
- *
- * Renderers are defined as:
- * <pre>
- * log4php.renderer.<renderedClass> = <renderingClass>
- * </pre>
- *
- * @param string $key log4php.renderer.<renderedClass>
- * @param string $value <renderingClass>
- */
- private function parseRenderer($key, $value) {
- // Remove the appender prefix from key
- $renderedClass = substr($key, strlen(self::APPENDER_PREFIX));
- $renderingClass = $value;
-
- $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
- }
-
- /** Helper method. Returns true if $str begins with $sub. */
- private function beginsWith($str, $sub) {
- return (strncmp($str, $sub, strlen($sub)) == 0);
- }
+class IniAdapter implements AdapterInterface
+{
+ /** Name to assign to the root logger. */
+ const ROOT_LOGGER_NAME = "root";
+
+ /** Prefix used for defining logger additivity. */
+ const ADDITIVITY_PREFIX = "log4php.additivity.";
+
+ /** Prefix used for defining logger threshold. */
+ const THRESHOLD_PREFIX = "log4php.threshold";
+
+ /** Prefix used for defining the root logger. */
+ const ROOT_LOGGER_PREFIX = "log4php.rootLogger";
+
+ /** Prefix used for defining a logger. */
+ const LOGGER_PREFIX = "log4php.logger.";
+
+ /** Prefix used for defining an appender. */
+ const APPENDER_PREFIX = "log4php.appender.";
+
+ /** Prefix used for defining a renderer. */
+ const RENDERER_PREFIX = "log4php.renderer.";
+
+ /** Holds the configuration. */
+ private $config = array();
+
+ /**
+ * Loads and parses the INI configuration file.
+ *
+ * @param string $url Path to the config file.
+ * @throws LoggerException
+ */
+ private function load($url)
+ {
+ if (!file_exists($url)) {
+ throw new LoggerException("File [$url] does not exist.");
+ }
+
+ $properties = @parse_ini_file($url, true);
+ if ($properties === false) {
+ $error = error_get_last();
+ throw new LoggerException("Error parsing configuration file: {$error['message']}");
+ }
+
+ return $properties;
+ }
+
+ /**
+ * Converts the provided INI configuration file to a PHP array config.
+ *
+ * @param string $path Path to the config file.
+ * @throws LoggerException If the file cannot be loaded or parsed.
+ */
+ public function convert($path)
+ {
+ // Load the configuration
+ $properties = $this->load($path);
+
+ // Parse threshold
+ if (isset($properties[self::THRESHOLD_PREFIX])) {
+ $this->config['threshold'] = $properties[self::THRESHOLD_PREFIX];
+ }
+
+ // Parse root logger
+ if (isset($properties[self::ROOT_LOGGER_PREFIX])) {
+ $this->parseLogger($properties[self::ROOT_LOGGER_PREFIX], self::ROOT_LOGGER_NAME);
+ }
+
+ $appenders = array();
+
+ foreach ($properties as $key => $value) {
+ // Parse loggers
+ if ($this->beginsWith($key, self::LOGGER_PREFIX)) {
+ $name = substr($key, strlen(self::LOGGER_PREFIX));
+ $this->parseLogger($value, $name);
+ }
+
+ // Parse additivity
+ if ($this->beginsWith($key, self::ADDITIVITY_PREFIX)) {
+ $name = substr($key, strlen(self::ADDITIVITY_PREFIX));
+ $this->config['loggers'][$name]['additivity'] = $value;
+ }
+
+ // Parse appenders
+ else if ($this->beginsWith($key, self::APPENDER_PREFIX)) {
+ $this->parseAppender($key, $value);
+ }
+
+ // Parse renderers
+ else if ($this->beginsWith($key, self::RENDERER_PREFIX)) {
+ $this->parseRenderer($key, $value);
+ }
+ }
+
+ return $this->config;
+ }
+
+ /**
+ * Parses a logger definition.
+ *
+ * Loggers are defined in the following manner:
+ * <pre>
+ * log4php.logger.<name> = [<level>], [<appender-ref>, <appender-ref>, ...]
+ * </pre>
+ *
+ * @param string $value The configuration value (level and appender-refs).
+ * @param string $name Logger name.
+ */
+ private function parseLogger($value, $name)
+ {
+ // Value is divided by commas
+ $parts = explode(',', $value);
+ if (empty($value) || empty($parts)) {
+ return;
+ }
+
+ // The first value is the logger level
+ $level = array_shift($parts);
+
+ // The remaining values are appender references
+ $appenders = array();
+ while ($appender = array_shift($parts)) {
+ $appender = trim($appender);
+ if (!empty($appender)) {
+ $appenders[] = trim($appender);
+ }
+ }
+
+ // Find the target configuration
+ if ($name == self::ROOT_LOGGER_NAME) {
+ $this->config['rootLogger']['level'] = trim($level);
+ $this->config['rootLogger']['appenders'] = $appenders;
+ } else {
+ $this->config['loggers'][$name]['level'] = trim($level);
+ $this->config['loggers'][$name]['appenders'] = $appenders;
+ }
+ }
+
+ /**
+ * Parses an configuration line pertaining to an appender.
+ *
+ * Parses the following patterns:
+ *
+ * Appender class:
+ * <pre>
+ * log4php.appender.<name> = <class>
+ * </pre>
+ *
+ * Appender parameter:
+ * <pre>
+ * log4php.appender.<name>.<param> = <value>
+ * </pre>
+ *
+ * Appender threshold:
+ * <pre>
+ * log4php.appender.<name>.threshold = <level>
+ * </pre>
+ *
+ * Appender layout:
+ * <pre>
+ * log4php.appender.<name>.layout = <layoutClass>
+ * </pre>
+ *
+ * Layout parameter:
+ * <pre>
+ * log4php.appender.<name>.layout.<param> = <value>
+ * </pre>
+ *
+ * For example, a full appender config might look like:
+ * <pre>
+ * log4php.appender.myAppender = ConsoleAppender
+ * log4php.appender.myAppender.threshold = info
+ * log4php.appender.myAppender.target = stdout
+ * log4php.appender.myAppender.layout = PatternLayout
+ * log4php.appender.myAppender.layout.conversionPattern = "%d %c: %m%n"
+ * </pre>
+ *
+ * After parsing all these options, the following configuration can be
+ * found under $this->config['appenders']['myAppender']:
+ * <pre>
+ * array(
+ * 'class' => ConsoleAppender,
+ * 'threshold' => info,
+ * 'params' => array(
+ * 'target' => 'stdout'
+ * ),
+ * 'layout' => array(
+ * 'class' => 'ConsoleAppender',
+ * 'params' => array(
+ * 'conversionPattern' => '%d %c: %m%n'
+ * )
+ * )
+ * )
+ * </pre>
+ *
+ * @param string $key
+ * @param string $value
+ */
+ private function parseAppender($key, $value)
+ {
+ // Remove the appender prefix from key
+ $subKey = substr($key, strlen(self::APPENDER_PREFIX));
+
+ // Divide the string by dots
+ $parts = explode('.', $subKey);
+ $count = count($parts);
+
+ // The first part is always the appender name
+ $name = trim($parts[0]);
+
+ // Only one part - this line defines the appender class
+ if ($count == 1) {
+ $this->config['appenders'][$name]['class'] = $value;
+
+ return;
+ }
+
+ // Two parts - either a parameter, a threshold or layout class
+ else if ($count == 2) {
+
+ if ($parts[1] == 'layout') {
+ $this->config['appenders'][$name]['layout']['class'] = $value;
+
+ return;
+ } elseif ($parts[1] == 'threshold') {
+ $this->config['appenders'][$name]['threshold'] = $value;
+
+ return;
+ } else {
+ $this->config['appenders'][$name]['params'][$parts[1]] = $value;
+
+ return;
+ }
+ }
+
+ // Three parts - this can only be a layout parameter
+ else if ($count == 3) {
+ if ($parts[1] == 'layout') {
+ $this->config['appenders'][$name]['layout']['params'][$parts[2]] = $value;
+
+ return;
+ }
+ }
+
+ trigger_error("log4php: Don't know how to parse the following line: \"$key = $value\". Skipping.");
+ }
+
+ /**
+ * Parses a renderer definition.
+ *
+ * Renderers are defined as:
+ * <pre>
+ * log4php.renderer.<renderedClass> = <renderingClass>
+ * </pre>
+ *
+ * @param string $key log4php.renderer.<renderedClass>
+ * @param string $value <renderingClass>
+ */
+ private function parseRenderer($key, $value)
+ {
+ // Remove the appender prefix from key
+ $renderedClass = substr($key, strlen(self::APPENDER_PREFIX));
+ $renderingClass = $value;
+
+ $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
+ }
+
+ /** Helper method. Returns true if $str begins with $sub. */
+ private function beginsWith($str, $sub)
+ {
+ return (strncmp($str, $sub, strlen($sub)) == 0);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configuration/adapters/PhpAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/PhpAdapter.php b/src/Configuration/adapters/PhpAdapter.php
index 71d245b..6e22c1d 100644
--- a/src/Configuration/adapters/PhpAdapter.php
+++ b/src/Configuration/adapters/PhpAdapter.php
@@ -49,34 +49,34 @@ use Apache\Log4php\LoggerException;
*/
class PhpAdapter implements AdapterInterface
{
- public function convert($url) {
- if (!file_exists($url)) {
- throw new LoggerException("File [$url] does not exist.");
- }
+ public function convert($url)
+ {
+ if (!file_exists($url)) {
+ throw new LoggerException("File [$url] does not exist.");
+ }
- // Load the config file
- $data = @file_get_contents($url);
- if ($data === false) {
- $error = error_get_last();
- throw new LoggerException("Error loading config file: {$error['message']}");
- }
+ // Load the config file
+ $data = @file_get_contents($url);
+ if ($data === false) {
+ $error = error_get_last();
+ throw new LoggerException("Error loading config file: {$error['message']}");
+ }
- $config = @eval('?>' . $data);
+ $config = @eval('?>' . $data);
- if ($config === false) {
- $error = error_get_last();
- throw new LoggerException("Error parsing configuration: " . $error['message']);
- }
+ if ($config === false) {
+ $error = error_get_last();
+ throw new LoggerException("Error parsing configuration: " . $error['message']);
+ }
- if (empty($config)) {
- throw new LoggerException("Invalid configuration: empty configuration array.");
- }
+ if (empty($config)) {
+ throw new LoggerException("Invalid configuration: empty configuration array.");
+ }
- if (!is_array($config)) {
- throw new LoggerException("Invalid configuration: not an array.");
- }
+ if (!is_array($config)) {
+ throw new LoggerException("Invalid configuration: not an array.");
+ }
- return $config;
- }
+ return $config;
+ }
}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Configuration/adapters/XmlAdapter.php
----------------------------------------------------------------------
diff --git a/src/Configuration/adapters/XmlAdapter.php b/src/Configuration/adapters/XmlAdapter.php
index d7495b8..829b6d9 100644
--- a/src/Configuration/adapters/XmlAdapter.php
+++ b/src/Configuration/adapters/XmlAdapter.php
@@ -27,251 +27,266 @@ use Apache\Log4php\LoggerException;
*/
class XmlAdapter implements AdapterInterface
{
- /** Path to the XML schema used for validation. */
- const SCHEMA_PATH = '/../xml/log4php.xsd';
-
- private $config = array(
- 'appenders' => array(),
- 'loggers' => array(),
- 'renderers' => array(),
- );
-
- public function convert($url) {
- $xml = $this->loadXML($url);
-
- $this->parseConfiguration($xml);
-
- // Parse the <root> node
- if (isset($xml->root)) {
- $this->parseRootLogger($xml->root);
- }
-
- // Process <logger> nodes
- foreach($xml->logger as $logger) {
- $this->parseLogger($logger);
- }
-
- // Process <appender> nodes
- foreach($xml->appender as $appender) {
- $this->parseAppender($appender);
- }
-
- // Process <renderer> nodes
- foreach($xml->renderer as $rendererNode) {
- $this->parseRenderer($rendererNode);
- }
-
- // Process <defaultRenderer> node
- foreach($xml->defaultRenderer as $rendererNode) {
- $this->parseDefaultRenderer($rendererNode);
- }
-
- return $this->config;
- }
-
- /**
- * Loads and validates the XML.
- * @param string $url Input XML.
- */
- private function loadXML($url) {
- if (!file_exists($url)) {
- throw new LoggerException("File [$url] does not exist.");
- }
-
- libxml_clear_errors();
- $oldValue = libxml_use_internal_errors(true);
-
- // Load XML
- $xml = @simplexml_load_file($url);
- if ($xml === false) {
-
- $errorStr = "";
- foreach(libxml_get_errors() as $error) {
- $errorStr .= $error->message;
- }
-
- throw new LoggerException("Error loading configuration file: " . trim($errorStr));
- }
-
- libxml_clear_errors();
- libxml_use_internal_errors($oldValue);
-
- return $xml;
- }
-
- /**
- * Parses the <configuration> node.
- */
- private function parseConfiguration(\SimpleXMLElement $xml) {
- $attributes = $xml->attributes();
- if (isset($attributes['threshold'])) {
- $this->config['threshold'] = (string) $attributes['threshold'];
- }
- }
-
- /** Parses an <appender> node. */
- private function parseAppender(\SimpleXMLElement $node) {
- $name = $this->getAttributeValue($node, 'name');
- if (empty($name)) {
- $this->warn("An <appender> node is missing the required 'name' attribute. Skipping appender definition.");
- return;
- }
-
- $appender = array();
- $appender['class'] = $this->getAttributeValue($node, 'class');
-
- if (isset($node['threshold'])) {
- $appender['threshold'] = $this->getAttributeValue($node, 'threshold');
- }
-
- if (isset($node->layout)) {
- $appender['layout']= $this->parseLayout($node->layout, $name);
- }
-
- if (count($node->param) > 0) {
- $appender['params'] = $this->parseParameters($node);
- }
-
- foreach($node->filter as $filterNode) {
- $appender['filters'][] = $this->parseFilter($filterNode);
- }
-
- $this->config['appenders'][$name] = $appender;
- }
-
- /** Parses a <layout> node. */
- private function parseLayout(\SimpleXMLElement $node, $appenderName) {
- $layout = array();
- $layout['class'] = $this->getAttributeValue($node, 'class');
-
- if (count($node->param) > 0) {
- $layout['params'] = $this->parseParameters($node);
- }
-
- return $layout;
- }
-
- /** Parses any <param> child nodes returning them in an array. */
- private function parseParameters($paramsNode) {
- $params = array();
-
- foreach($paramsNode->param as $paramNode) {
- if (empty($paramNode['name'])) {
- $this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
- continue;
- }
-
- $name = $this->getAttributeValue($paramNode, 'name');
- $value = $this->getAttributeValue($paramNode, 'value');
-
- $params[$name] = $value;
- }
-
- return $params;
- }
-
- /** Parses a <root> node. */
- private function parseRootLogger(\SimpleXMLElement $node) {
- $logger = array();
-
- if (isset($node->level)) {
- $logger['level'] = $this->getAttributeValue($node->level, 'value');
- }
-
- $logger['appenders'] = $this->parseAppenderReferences($node);
-
- $this->config['rootLogger'] = $logger;
- }
-
- /** Parses a <logger> node. */
- private function parseLogger(\SimpleXMLElement $node) {
- $logger = array();
-
- $name = $this->getAttributeValue($node, 'name');
- if (empty($name)) {
- $this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
- return;
- }
-
- if (isset($node->level)) {
- $logger['level'] = $this->getAttributeValue($node->level, 'value');
- }
-
- if (isset($node['additivity'])) {
- $logger['additivity'] = $this->getAttributeValue($node, 'additivity');
- }
-
- $logger['appenders'] = $this->parseAppenderReferences($node);
-
- // Check for duplicate loggers
- if (isset($this->config['loggers'][$name])) {
- $this->warn("Duplicate logger definition [$name]. Overwriting.");
- }
-
- $this->config['loggers'][$name] = $logger;
- }
-
- /**
- * Parses a <logger> node for appender references and returns them in an array.
- *
- * Previous versions supported appender-ref, as well as appender_ref so both
- * are parsed for backward compatibility.
- */
- private function parseAppenderReferences(\SimpleXMLElement $node) {
- $refs = array();
- foreach($node->appender_ref as $ref) {
- $refs[] = $this->getAttributeValue($ref, 'ref');
- }
-
- foreach($node->{'appender-ref'} as $ref) {
- $refs[] = $this->getAttributeValue($ref, 'ref');
- }
-
- return $refs;
- }
-
- /** Parses a <filter> node. */
- private function parseFilter($filterNode) {
- $filter = array();
- $filter['class'] = $this->getAttributeValue($filterNode, 'class');
-
- if (count($filterNode->param) > 0) {
- $filter['params'] = $this->parseParameters($filterNode);
- }
-
- return $filter;
- }
-
- /** Parses a <renderer> node. */
- private function parseRenderer(\SimpleXMLElement $node) {
- $renderedClass = $this->getAttributeValue($node, 'renderedClass');
- $renderingClass = $this->getAttributeValue($node, 'renderingClass');
-
- $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
- }
-
- /** Parses a <defaultRenderer> node. */
- private function parseDefaultRenderer(\SimpleXMLElement $node) {
- $renderingClass = $this->getAttributeValue($node, 'renderingClass');
-
- // Warn on duplicates
- if(isset($this->config['defaultRenderer'])) {
- $this->warn("Duplicate <defaultRenderer> node. Overwriting.");
- }
-
- $this->config['defaultRenderer'] = $renderingClass;
- }
-
- // ******************************************
- // ** Helper methods **
- // ******************************************
-
- private function getAttributeValue(\SimpleXMLElement $node, $name) {
- return isset($node[$name]) ? (string) $node[$name] : null;
- }
-
- private function warn($message) {
- trigger_error("log4php: " . $message, E_USER_WARNING);
- }
+ /** Path to the XML schema used for validation. */
+ const SCHEMA_PATH = '/../xml/log4php.xsd';
+
+ private $config = array(
+ 'appenders' => array(),
+ 'loggers' => array(),
+ 'renderers' => array(),
+ );
+
+ public function convert($url)
+ {
+ $xml = $this->loadXML($url);
+
+ $this->parseConfiguration($xml);
+
+ // Parse the <root> node
+ if (isset($xml->root)) {
+ $this->parseRootLogger($xml->root);
+ }
+
+ // Process <logger> nodes
+ foreach ($xml->logger as $logger) {
+ $this->parseLogger($logger);
+ }
+
+ // Process <appender> nodes
+ foreach ($xml->appender as $appender) {
+ $this->parseAppender($appender);
+ }
+
+ // Process <renderer> nodes
+ foreach ($xml->renderer as $rendererNode) {
+ $this->parseRenderer($rendererNode);
+ }
+
+ // Process <defaultRenderer> node
+ foreach ($xml->defaultRenderer as $rendererNode) {
+ $this->parseDefaultRenderer($rendererNode);
+ }
+
+ return $this->config;
+ }
+
+ /**
+ * Loads and validates the XML.
+ * @param string $url Input XML.
+ */
+ private function loadXML($url)
+ {
+ if (!file_exists($url)) {
+ throw new LoggerException("File [$url] does not exist.");
+ }
+
+ libxml_clear_errors();
+ $oldValue = libxml_use_internal_errors(true);
+
+ // Load XML
+ $xml = @simplexml_load_file($url);
+ if ($xml === false) {
+
+ $errorStr = "";
+ foreach (libxml_get_errors() as $error) {
+ $errorStr .= $error->message;
+ }
+
+ throw new LoggerException("Error loading configuration file: " . trim($errorStr));
+ }
+
+ libxml_clear_errors();
+ libxml_use_internal_errors($oldValue);
+
+ return $xml;
+ }
+
+ /**
+ * Parses the <configuration> node.
+ */
+ private function parseConfiguration(\SimpleXMLElement $xml)
+ {
+ $attributes = $xml->attributes();
+ if (isset($attributes['threshold'])) {
+ $this->config['threshold'] = (string) $attributes['threshold'];
+ }
+ }
+
+ /** Parses an <appender> node. */
+ private function parseAppender(\SimpleXMLElement $node)
+ {
+ $name = $this->getAttributeValue($node, 'name');
+ if (empty($name)) {
+ $this->warn("An <appender> node is missing the required 'name' attribute. Skipping appender definition.");
+
+ return;
+ }
+
+ $appender = array();
+ $appender['class'] = $this->getAttributeValue($node, 'class');
+
+ if (isset($node['threshold'])) {
+ $appender['threshold'] = $this->getAttributeValue($node, 'threshold');
+ }
+
+ if (isset($node->layout)) {
+ $appender['layout']= $this->parseLayout($node->layout, $name);
+ }
+
+ if (count($node->param) > 0) {
+ $appender['params'] = $this->parseParameters($node);
+ }
+
+ foreach ($node->filter as $filterNode) {
+ $appender['filters'][] = $this->parseFilter($filterNode);
+ }
+
+ $this->config['appenders'][$name] = $appender;
+ }
+
+ /** Parses a <layout> node. */
+ private function parseLayout(\SimpleXMLElement $node, $appenderName)
+ {
+ $layout = array();
+ $layout['class'] = $this->getAttributeValue($node, 'class');
+
+ if (count($node->param) > 0) {
+ $layout['params'] = $this->parseParameters($node);
+ }
+
+ return $layout;
+ }
+
+ /** Parses any <param> child nodes returning them in an array. */
+ private function parseParameters($paramsNode)
+ {
+ $params = array();
+
+ foreach ($paramsNode->param as $paramNode) {
+ if (empty($paramNode['name'])) {
+ $this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
+ continue;
+ }
+
+ $name = $this->getAttributeValue($paramNode, 'name');
+ $value = $this->getAttributeValue($paramNode, 'value');
+
+ $params[$name] = $value;
+ }
+
+ return $params;
+ }
+
+ /** Parses a <root> node. */
+ private function parseRootLogger(\SimpleXMLElement $node)
+ {
+ $logger = array();
+
+ if (isset($node->level)) {
+ $logger['level'] = $this->getAttributeValue($node->level, 'value');
+ }
+
+ $logger['appenders'] = $this->parseAppenderReferences($node);
+
+ $this->config['rootLogger'] = $logger;
+ }
+
+ /** Parses a <logger> node. */
+ private function parseLogger(\SimpleXMLElement $node)
+ {
+ $logger = array();
+
+ $name = $this->getAttributeValue($node, 'name');
+ if (empty($name)) {
+ $this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
+
+ return;
+ }
+
+ if (isset($node->level)) {
+ $logger['level'] = $this->getAttributeValue($node->level, 'value');
+ }
+
+ if (isset($node['additivity'])) {
+ $logger['additivity'] = $this->getAttributeValue($node, 'additivity');
+ }
+
+ $logger['appenders'] = $this->parseAppenderReferences($node);
+
+ // Check for duplicate loggers
+ if (isset($this->config['loggers'][$name])) {
+ $this->warn("Duplicate logger definition [$name]. Overwriting.");
+ }
+
+ $this->config['loggers'][$name] = $logger;
+ }
+
+ /**
+ * Parses a <logger> node for appender references and returns them in an array.
+ *
+ * Previous versions supported appender-ref, as well as appender_ref so both
+ * are parsed for backward compatibility.
+ */
+ private function parseAppenderReferences(\SimpleXMLElement $node)
+ {
+ $refs = array();
+ foreach ($node->appender_ref as $ref) {
+ $refs[] = $this->getAttributeValue($ref, 'ref');
+ }
+
+ foreach ($node->{'appender-ref'} as $ref) {
+ $refs[] = $this->getAttributeValue($ref, 'ref');
+ }
+
+ return $refs;
+ }
+
+ /** Parses a <filter> node. */
+ private function parseFilter($filterNode)
+ {
+ $filter = array();
+ $filter['class'] = $this->getAttributeValue($filterNode, 'class');
+
+ if (count($filterNode->param) > 0) {
+ $filter['params'] = $this->parseParameters($filterNode);
+ }
+
+ return $filter;
+ }
+
+ /** Parses a <renderer> node. */
+ private function parseRenderer(\SimpleXMLElement $node)
+ {
+ $renderedClass = $this->getAttributeValue($node, 'renderedClass');
+ $renderingClass = $this->getAttributeValue($node, 'renderingClass');
+
+ $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
+ }
+
+ /** Parses a <defaultRenderer> node. */
+ private function parseDefaultRenderer(\SimpleXMLElement $node)
+ {
+ $renderingClass = $this->getAttributeValue($node, 'renderingClass');
+
+ // Warn on duplicates
+ if (isset($this->config['defaultRenderer'])) {
+ $this->warn("Duplicate <defaultRenderer> node. Overwriting.");
+ }
+
+ $this->config['defaultRenderer'] = $renderingClass;
+ }
+
+ // ******************************************
+ // ** Helper methods **
+ // ******************************************
+
+ private function getAttributeValue(\SimpleXMLElement $node, $name)
+ {
+ return isset($node[$name]) ? (string) $node[$name] : null;
+ }
+
+ private function warn($message)
+ {
+ trigger_error("log4php: " . $message, E_USER_WARNING);
+ }
}
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Filters/AbstractFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/AbstractFilter.php b/src/Filters/AbstractFilter.php
index 81663e3..9b884a7 100644
--- a/src/Filters/AbstractFilter.php
+++ b/src/Filters/AbstractFilter.php
@@ -53,74 +53,78 @@ use Apache\Log4php\LoggingEvent;
* <p>The philosophy of log4php filters is largely inspired from the
* Linux ipchains.
*/
-abstract class AbstractFilter extends Configurable {
+abstract class AbstractFilter extends Configurable
+{
+ /**
+ * The log event must be logged immediately without consulting with
+ * the remaining filters, if any, in the chain.
+ */
+ const ACCEPT = 1;
- /**
- * The log event must be logged immediately without consulting with
- * the remaining filters, if any, in the chain.
- */
- const ACCEPT = 1;
+ /**
+ * This filter is neutral with respect to the log event. The
+ * remaining filters, if any, should be consulted for a final decision.
+ */
+ const NEUTRAL = 0;
- /**
- * This filter is neutral with respect to the log event. The
- * remaining filters, if any, should be consulted for a final decision.
- */
- const NEUTRAL = 0;
+ /**
+ * The log event must be dropped immediately without consulting
+ * with the remaining filters, if any, in the chain.
+ */
+ const DENY = -1;
- /**
- * The log event must be dropped immediately without consulting
- * with the remaining filters, if any, in the chain.
- */
- const DENY = -1;
+ /**
+ * @var AbstractFilter Points to the next {@link AbstractFilter} in the filter chain.
+ */
+ protected $next;
- /**
- * @var AbstractFilter Points to the next {@link AbstractFilter} in the filter chain.
- */
- protected $next;
+ /**
+ * Usually filters options become active when set. We provide a
+ * default do-nothing implementation for convenience.
+ */
+ public function activateOptions()
+ {
+ }
- /**
- * Usually filters options become active when set. We provide a
- * default do-nothing implementation for convenience.
- */
- public function activateOptions() {
- }
+ /**
+ * Decide what to do.
+ * <p>If the decision is {@link AbstractFilter::DENY}, then the event will be
+ * dropped. If the decision is {@link AbstractFilter::NEUTRAL}, then the next
+ * filter, if any, will be invoked. If the decision is {@link AbstractFilter::ACCEPT} then
+ * the event will be logged without consulting with other filters in
+ * the chain.
+ *
+ * @param LoggingEvent $event The {@link LoggingEvent} to decide upon.
+ * @return integer {@link AbstractFilter::NEUTRAL} or {@link AbstractFilter::DENY}|{@link AbstractFilter::ACCEPT}
+ */
+ public function decide(LoggingEvent $event)
+ {
+ return self::NEUTRAL;
+ }
- /**
- * Decide what to do.
- * <p>If the decision is {@link AbstractFilter::DENY}, then the event will be
- * dropped. If the decision is {@link AbstractFilter::NEUTRAL}, then the next
- * filter, if any, will be invoked. If the decision is {@link AbstractFilter::ACCEPT} then
- * the event will be logged without consulting with other filters in
- * the chain.
- *
- * @param LoggingEvent $event The {@link LoggingEvent} to decide upon.
- * @return integer {@link AbstractFilter::NEUTRAL} or {@link AbstractFilter::DENY}|{@link AbstractFilter::ACCEPT}
- */
- public function decide(LoggingEvent $event) {
- return self::NEUTRAL;
- }
+ /**
+ * Adds a new filter to the filter chain this filter is a part of.
+ * If this filter has already and follow up filter, the param filter
+ * is passed on until it is the last filter in chain.
+ *
+ * @param $filter - the filter to add to this chain
+ */
+ public function addNext($filter)
+ {
+ if ($this->next !== null) {
+ $this->next->addNext($filter);
+ } else {
+ $this->next = $filter;
+ }
+ }
- /**
- * Adds a new filter to the filter chain this filter is a part of.
- * If this filter has already and follow up filter, the param filter
- * is passed on until it is the last filter in chain.
- *
- * @param $filter - the filter to add to this chain
- */
- public function addNext($filter) {
- if($this->next !== null) {
- $this->next->addNext($filter);
- } else {
- $this->next = $filter;
- }
- }
-
- /**
- * Returns the next filter in this chain
- * @return the next filter
- */
- public function getNext() {
- return $this->next;
- }
+ /**
+ * Returns the next filter in this chain
+ * @return the next filter
+ */
+ public function getNext()
+ {
+ return $this->next;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Filters/DenyAllFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/DenyAllFilter.php b/src/Filters/DenyAllFilter.php
index 1d34357..6781b55 100644
--- a/src/Filters/DenyAllFilter.php
+++ b/src/Filters/DenyAllFilter.php
@@ -30,16 +30,17 @@ use Apache\Log4php\LoggingEvent;
*
* @since 0.3
*/
-class DenyAllFilter extends AbstractFilter {
-
- /**
- * Always returns the integer constant {@link AbstractFilter::DENY}
- * regardless of the {@link LoggingEvent} parameter.
- *
- * @param LoggingEvent $event The {@link LoggingEvent} to filter.
- * @return AbstractFilter::DENY Always returns {@link AbstractFilter::DENY}
- */
- public function decide(LoggingEvent $event) {
- return AbstractFilter::DENY;
- }
+class DenyAllFilter extends AbstractFilter
+{
+ /**
+ * Always returns the integer constant {@link AbstractFilter::DENY}
+ * regardless of the {@link LoggingEvent} parameter.
+ *
+ * @param LoggingEvent $event The {@link LoggingEvent} to filter.
+ * @return AbstractFilter::DENY Always returns {@link AbstractFilter::DENY}
+ */
+ public function decide(LoggingEvent $event)
+ {
+ return AbstractFilter::DENY;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Filters/LevelMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/LevelMatchFilter.php b/src/Filters/LevelMatchFilter.php
index 4573c4c..2ace612 100644
--- a/src/Filters/LevelMatchFilter.php
+++ b/src/Filters/LevelMatchFilter.php
@@ -43,56 +43,59 @@ use Apache\Log4php\LoggingEvent;
* {@example ../../examples/resources/filter_levelmatch.xml 18}
* @since 0.6
*/
-class LevelMatchFilter extends AbstractFilter {
+class LevelMatchFilter extends AbstractFilter
+{
+ /**
+ * Indicates if this event should be accepted or denied on match
+ * @var boolean
+ */
+ protected $acceptOnMatch = true;
- /**
- * Indicates if this event should be accepted or denied on match
- * @var boolean
- */
- protected $acceptOnMatch = true;
+ /**
+ * The level, when to match
+ * @var Level
+ */
+ protected $levelToMatch;
- /**
- * The level, when to match
- * @var Level
- */
- protected $levelToMatch;
+ /**
+ * @param boolean $acceptOnMatch
+ */
+ public function setAcceptOnMatch($acceptOnMatch)
+ {
+ $this->setBoolean('acceptOnMatch', $acceptOnMatch);
+ }
- /**
- * @param boolean $acceptOnMatch
- */
- public function setAcceptOnMatch($acceptOnMatch) {
- $this->setBoolean('acceptOnMatch', $acceptOnMatch);
- }
+ /**
+ * @param string $l the level to match
+ */
+ public function setLevelToMatch($level)
+ {
+ $this->setLevel('levelToMatch', $level);
+ }
- /**
- * @param string $l the level to match
- */
- public function setLevelToMatch($level) {
- $this->setLevel('levelToMatch', $level);
- }
+ /**
+ * Return the decision of this filter.
+ *
+ * Returns {@link AbstractFilter::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 AbstractFilter::ACCEPT} if the
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
+ * returned decision is {@link AbstractFilter::DENY} if the
+ * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
+ *
+ * @param LoggingEvent $event
+ * @return integer
+ */
+ public function decide(LoggingEvent $event)
+ {
+ if ($this->levelToMatch === null) {
+ return AbstractFilter::NEUTRAL;
+ }
- /**
- * Return the decision of this filter.
- *
- * Returns {@link AbstractFilter::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 AbstractFilter::ACCEPT} if the
- * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
- * returned decision is {@link AbstractFilter::DENY} if the
- * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
- *
- * @param LoggingEvent $event
- * @return integer
- */
- public function decide(LoggingEvent $event) {
- if($this->levelToMatch === null) {
- return AbstractFilter::NEUTRAL;
- }
-
- if($this->levelToMatch->equals($event->getLevel())) {
- return $this->acceptOnMatch ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
- } else {
- return AbstractFilter::NEUTRAL;
- }
- }
+ if ($this->levelToMatch->equals($event->getLevel())) {
+ return $this->acceptOnMatch ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
+ } else {
+ return AbstractFilter::NEUTRAL;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Filters/LevelRangeFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/LevelRangeFilter.php b/src/Filters/LevelRangeFilter.php
index d30f5ae..6eb62f5 100644
--- a/src/Filters/LevelRangeFilter.php
+++ b/src/Filters/LevelRangeFilter.php
@@ -60,77 +60,81 @@ use Apache\Log4php\LoggingEvent;
* @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
* @since 0.6
*/
-class LevelRangeFilter extends AbstractFilter {
+class LevelRangeFilter extends AbstractFilter
+{
+ /**
+ * @var boolean
+ */
+ protected $acceptOnMatch = true;
- /**
- * @var boolean
- */
- protected $acceptOnMatch = true;
+ /**
+ * @var Level
+ */
+ protected $levelMin;
- /**
- * @var Level
- */
- protected $levelMin;
+ /**
+ * @var Level
+ */
+ protected $levelMax;
- /**
- * @var Level
- */
- protected $levelMax;
+ /**
+ * @param boolean $acceptOnMatch
+ */
+ public function setAcceptOnMatch($acceptOnMatch)
+ {
+ $this->setBoolean('acceptOnMatch', $acceptOnMatch);
+ }
- /**
- * @param boolean $acceptOnMatch
- */
- public function setAcceptOnMatch($acceptOnMatch) {
- $this->setBoolean('acceptOnMatch', $acceptOnMatch);
- }
+ /**
+ * @param string $l the level min to match
+ */
+ public function setLevelMin($level)
+ {
+ $this->setLevel('levelMin', $level);
+ }
- /**
- * @param string $l the level min to match
- */
- public function setLevelMin($level) {
- $this->setLevel('levelMin', $level);
- }
+ /**
+ * @param string $l the level max to match
+ */
+ public function setLevelMax($level)
+ {
+ $this->setLevel('levelMax', $level);
+ }
- /**
- * @param string $l the level max to match
- */
- public function setLevelMax($level) {
- $this->setLevel('levelMax', $level);
- }
+ /**
+ * Return the decision of this filter.
+ *
+ * @param LoggingEvent $event
+ * @return integer
+ */
+ public function decide(LoggingEvent $event)
+ {
+ $level = $event->getLevel();
- /**
- * Return the decision of this filter.
- *
- * @param LoggingEvent $event
- * @return integer
- */
- public function decide(LoggingEvent $event) {
- $level = $event->getLevel();
+ if ($this->levelMin !== null) {
+ if ($level->isGreaterOrEqual($this->levelMin) == false) {
+ // level of event is less than minimum
+ return AbstractFilter::DENY;
+ }
+ }
- if($this->levelMin !== null) {
- if($level->isGreaterOrEqual($this->levelMin) == false) {
- // level of event is less than minimum
- return AbstractFilter::DENY;
- }
- }
+ if ($this->levelMax !== null) {
+ if ($level->toInt() > $this->levelMax->toInt()) {
+ // level of event is greater than maximum
+ // Alas, there is no Level.isGreater method. and using
+ // a combo of isGreaterOrEqual && !Equal seems worse than
+ // checking the int values of the level objects..
+ return AbstractFilter::DENY;
+ }
+ }
- if($this->levelMax !== null) {
- if($level->toInt() > $this->levelMax->toInt()) {
- // level of event is greater than maximum
- // Alas, there is no Level.isGreater method. and using
- // a combo of isGreaterOrEqual && !Equal seems worse than
- // checking the int values of the level objects..
- return AbstractFilter::DENY;
- }
- }
-
- if($this->acceptOnMatch) {
- // this filter set up to bypass later filters and always return
- // accept if level in range
- return AbstractFilter::ACCEPT;
- } else {
- // event is ok for this filter; allow later filters to have a look..
- return AbstractFilter::NEUTRAL;
- }
- }
+ if ($this->acceptOnMatch) {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return AbstractFilter::ACCEPT;
+ } else {
+ // event is ok for this filter; allow later filters to have a look..
+ return AbstractFilter::NEUTRAL;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Filters/StringMatchFilter.php
----------------------------------------------------------------------
diff --git a/src/Filters/StringMatchFilter.php b/src/Filters/StringMatchFilter.php
index 152c9c9..c6e6359 100644
--- a/src/Filters/StringMatchFilter.php
+++ b/src/Filters/StringMatchFilter.php
@@ -43,45 +43,49 @@ use Apache\Log4php\LoggingEvent;
* {@example ../../examples/resources/filter_stringmatch.xml 18}
* @since 0.3
*/
-class StringMatchFilter extends AbstractFilter {
+class StringMatchFilter extends AbstractFilter
+{
+ /**
+ * @var boolean
+ */
+ protected $acceptOnMatch = true;
- /**
- * @var boolean
- */
- protected $acceptOnMatch = true;
+ /**
+ * @var string
+ */
+ protected $stringToMatch;
- /**
- * @var string
- */
- protected $stringToMatch;
+ /**
+ * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
+ */
+ public function setAcceptOnMatch($acceptOnMatch)
+ {
+ $this->setBoolean('acceptOnMatch', $acceptOnMatch);
+ }
- /**
- * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
- */
- public function setAcceptOnMatch($acceptOnMatch) {
- $this->setBoolean('acceptOnMatch', $acceptOnMatch);
- }
+ /**
+ * @param string $s the string to match
+ */
+ public function setStringToMatch($string)
+ {
+ $this->setString('stringToMatch', $string);
+ }
- /**
- * @param string $s the string to match
- */
- public function setStringToMatch($string) {
- $this->setString('stringToMatch', $string);
- }
+ /**
+ * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
+ */
+ public function decide(LoggingEvent $event)
+ {
+ $msg = $event->getRenderedMessage();
- /**
- * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
- */
- public function decide(LoggingEvent $event) {
- $msg = $event->getRenderedMessage();
+ if ($msg === null or $this->stringToMatch === null) {
+ return AbstractFilter::NEUTRAL;
+ }
- if($msg === null or $this->stringToMatch === null) {
- return AbstractFilter::NEUTRAL;
- }
+ if (strpos($msg, $this->stringToMatch) !== false ) {
+ return ($this->acceptOnMatch) ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
+ }
- if(strpos($msg, $this->stringToMatch) !== false ) {
- return ($this->acceptOnMatch) ? AbstractFilter::ACCEPT : AbstractFilter::DENY;
- }
- return AbstractFilter::NEUTRAL;
- }
+ return AbstractFilter::NEUTRAL;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/35dfd5d3/src/Helpers/FormattingInfo.php
----------------------------------------------------------------------
diff --git a/src/Helpers/FormattingInfo.php b/src/Helpers/FormattingInfo.php
index 9f2bb3b..fb824b4 100644
--- a/src/Helpers/FormattingInfo.php
+++ b/src/Helpers/FormattingInfo.php
@@ -23,29 +23,29 @@ namespace Apache\Log4php\Helpers;
* formatting modifiers in conversion modifiers.
* @since 0.3
*/
-class FormattingInfo {
+class FormattingInfo
+{
+ /**
+ * Minimal output length. If output is shorter than this value, it will be
+ * padded with spaces.
+ */
+ public $min = 0;
- /**
- * Minimal output length. If output is shorter than this value, it will be
- * padded with spaces.
- */
- public $min = 0;
+ /**
+ * Maximum output length. If output is longer than this value, it will be
+ * trimmed.
+ */
+ public $max = PHP_INT_MAX;
- /**
- * Maximum output length. If output is longer than this value, it will be
- * trimmed.
- */
- public $max = PHP_INT_MAX;
+ /**
+ * Whether to pad the string from the left. If set to false, the string
+ * will be padded from the right.
+ */
+ public $padLeft = true;
- /**
- * Whether to pad the string from the left. If set to false, the string
- * will be padded from the right.
- */
- public $padLeft = true;
-
- /**
- * Whether to trim the string from the left. If set to false, the string
- * will be trimmed from the right.
- */
- public $trimLeft = false;
+ /**
+ * Whether to trim the string from the left. If set to false, the string
+ * will be trimmed from the right.
+ */
+ public $trimLeft = false;
}
[23/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
deleted file mode 100644
index 666469c..0000000
--- a/src/changes/changes.xml
+++ /dev/null
@@ -1,167 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<document xmlns="http://maven.apache.org/changes/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
- <properties>
- <title>Apache log4php changelog</title>
- </properties>
- <body>
- <release version="2.3.0" date="SVN">
- <action date="2012-10-07" type="fix" issue="LOG4PHP-163" dev="Ivan Habunek" due-to="Daniel Wong" due-to-email="dan at dsmwong dot com">LoggerPatternConverter formats max incorrectly</action>
- <action date="2012-10-07" type="fix" issue="LOG4PHP-188" dev="Ivan Habunek">Events logged by upstream loggers even if disabled by level.</action>
- <action date="2012-10-06" type="update" issue="LOG4PHP-186" dev="Ivan Habunek" due-to="Rasmus Lerdorf" due-to-email="rasmus at lerdorf dot com">Don't clear the entire stat cache on an append.</action>
- <action date="2012-10-06" type="add" issue="LOG4PHP-141" dev="Ivan Habunek">Allow setting of a default renderer.</action>
- <action date="2012-09-08" type="update" issue="LOG4PHP-120" dev="Ivan Habunek" due-to="Michal Vanek" due-to-email="michal dot vanek at gmail dot com">Fixed LoggerAppenderDailyFile to rollover on date change in long running scipts.</action>
- <action date="2012-08-18" type="fix" issue="LOG4PHP-184" dev="Ivan Habunek">Re-enabled usage of PHP constants in config parameters.</action>
- <action date="2012-05-29" type="update" dev="Ivan Habunek">Removed $_ENV and $_SERVER access from LoggerMDC.</action>
- <action date="2012-03-19" type="update" dev="Ivan Habunek">Made LoggerLayoutTTCC deprecated.</action>
- <action date="2012-02-28" type="fix" issue="LOG4PHP-163" dev="Ivan Habunek">Fixed formatting bug in LoggerLayoutPattern.</action>
- <action date="2012-02-28" type="update" issue="LOG4PHP-172" dev="Ivan Habunek">Rewritten pattern system to allow longer conversion words and some new ones.</action>
- <action date="2012-02-28" type="add" issue="LOG4PHP-134" dev="Ivan Habunek">Added reconnectAttempts parameter to LoggerAppenderPDO. Adds support for reconnect if connection fails while appending.</action>
- <action date="2012-03-26" type="add" issue="LOG4PHP-174" dev="Florian Semm">Firephp appender logs to Firebug console.</action>
- </release>
- <release version="2.2.1" date="2012-02-18">
- <action date="2012-02-07" type="fix" issue="LOG4PHP-168" dev="Ivan Habunek">Fixed a bug which prevented configuration by passing a LoggerConfigurator instance.</action>
- <action date="2012-01-29" type="fix" issue="LOG4PHP-167" dev="Ivan Habunek">Fixed a bug which prevented parsing of INI configuration files when using PHP 5.2.x.</action>
- <action date="2011-12-22" type="update" issue="LOG4PHP-166" dev="Ivan Habunek" due-to="David Hilowitz" due-to-email="dhilowitz at gmail dot com">Added connection timeout parameter to MongoDB appender.</action>
- </release>
- <release version="2.2.0" date="2011-12-20">
- <action date="2011-12-13" type="fix" issue="LOG4PHP-158" dev="Ivan Habunek">LoggerAppenderFile throws wrong warning messages.</action>
- <action date="2011-12-12" type="update" issue="LOG4PHP-161" dev="Ivan Habunek">All configurable components should report errors when given invalid values</action>
- <action date="2011-12-10" type="update" issue="LOG4PHP-165" dev="Ivan Habunek" due-to="Johannes Wohlgemuth" due-to-email="j dot wohlgemuth at findologic dot com">Extended LoggerLayoutXml to include MDC info</action>
- <action date="2011-12-09" type="fix" issue="LOG4PHP-162" dev="Ivan Habunek">Warning for invalid appender threshold level never called.</action>
- <action date="2011-12-08" type="fix" issue="LOG4PHP-114" dev="Ivan Habunek">Order of params in LoggerAppenderDailyFile configuration is significant.</action>
- <action date="2011-12-08" type="update" issue="LOG4PHP-154" dev="Ivan Habunek">Rewritten LoggerAppenderSocket to use a layout.</action>
- <action date="2011-12-04" type="add" issue="LOG4PHP-160" dev="Ivan Habunek" due-to="Florian Semm" due-to-email="florian dot semm at gmx dot de">Appeneders should use a default layout is no layout is specified in configuration</action>
- <action date="2011-10-23" type="add" issue="LOG4PHP-155" dev="Ivan Habunek">Created a new layout LoggerLayoutSerialized which formats events as serialized objects.</action>
- <action date="2011-10-23" type="fix" issue="LOG4PHP-159" dev="Ivan Habunek" due-to="Justin Cherniak" due-to-email="justin dot cherniak at gmail dot com">Appenders do not close gracefully if a fatal error occurs.</action>
- <action date="2011-10-15" type="fix" issue="LOG4PHP-101" dev="Ivan Habunek">Wrong order in configuration breaks logging.</action>
- <action date="2011-10-15" type="update" issue="LOG4PHP-152" dev="Ivan Habunek">A rewrite of the configurator.</action>
- <action date="2011-09-11" type="fix" issue="LOG4PHP-147" dev="Ivan Habunek">Bugs during HipHop build</action>
- <action date="2011-09-07" type="update" issue="LOG4PHP-151" dev="Ivan Habunek">Move common appender methods to parent class</action>
- <action date="2011-09-03" type="fix" issue="LOG4PHP-145" dev="Ivan Habunek">The syslog appender does not correctly parse options</action>
- <action date="2011-08-31" type="remove" issue="LOG4PHP-149" dev="Ivan Habunek">Remove deprecated appender LoggerAppenderAdodb</action>
- <action date="2011-08-31" type="fix" issue="LOG4PHP-148" dev="Ivan Habunek">LoggerUserFieldPatternConverter class missing in log4php archive</action>
- <action date="2011-08-18" type="update" issue="LOG4PHP-137" dev="Ivan Habunek">Improve pear build.</action>
- <action date="2011-07-14" type="fix" issue="LOG4PHP-143" dev="Ivan Habunek" due-to="Justin Cherniak" due-to-email="justin dot cherniak at gmail dot com">LoggerConfiguratorPhp does not accept integer constants for appender threshold</action>
- </release>
- <release version="2.1.0" date="2011-07-13" description="Stabilizing">
- <action date="2011-06-01" type="fix" issue="LOG4PHP-138" dev="Christian Grobmeier">Permission denied while renaming log file when hundred of users are accessing the application</action>
- <action date="2011-05-28" type="fix" issue="LOG4PHP-140" dev="Ivan Habunek">Fixed incorrect usage of changes.xml</action>
- <action date="2011-05-28" type="fix" issue="LOG4PHP-129" dev="Ivan Habunek">Log4PHP causes odd errors in the underlying application if used with source having an existing __autoload function</action>
- <action date="2011-05-20" type="fix" issue="LOG4PHP-122" dev="Ivan Habunek" due-to="Moritz Schmidt" due-to-email="fusselwurm at gmail dot com">RendererMap::getByClassName doesnt recognize instances of child classes</action>
- <action date="2011-05-20" type="fix" issue="LOG4PHP-123" dev="Ivan Habunek" due-to="Moritz Schmidt" due-to-email="fusselwurm at gmail dot com">LoggerConfiguratorPhp does not parse renderer configuration</action>
- <action date="2011-05-15" type="fix" issue="LOG4PHP-110" dev="Ivan Habunek" due-to="Vladimir Gorej" due-to-email="binarygroop at gmail dot com">Adapted MongoDB appender to better fit in log4php codebase.</action>
- <action date="2011-02-15" type="fix" issue="LOG4PHP-126" dev="Christian Grobmeier" due-to="Peter Chapman" due-to-email="pchapman at pobox dot com">LoggerConfiguratorPhp does not appear to respect appender file property from config</action>
- <action date="2011-02-15" type="fix" issue="LOG4PHP-118" dev="Christian Grobmeier" due-to="Craig Marvelley" due-to-email="craig dot marvelley at boxuk dot com">Additivity cannot be disabled through log4php.properties ini file.</action>
- <action date="2011-02-15" type="add" issue="LOG4PHP-110" dev="Christian Grobmeier" due-to="Vladimir Gorej" due-to-email="binarygroop at gmail dot com">Added MongoDB appender</action>
- <action date="2011-01-16" type="fix" issue="LOG4PHP-131" dev="Ivan Habunek">File appenders parameters (removed overloading of setFile()).</action>
- <action date="2011-01-12" type="fix" issue="LOG4PHP-133" dev="Ivan Habunek" due-to="Dmitry Katemirov" due-to-email="dmitry at infozonelab dot com">PDO appender doesn't close connections</action>
- <action date="2011-01-11" type="fix" dev="Ivan Habunek">Replaced calls to deprecated PHPUnit method assertTypeOf() with assertInternalType() and assertInstanceOf().</action>
- <action date="2010-09-18" type="fix" issue="LOG4PHP-104" dev="Ivan Habunek">Refactored LoggerNDC and added tests</action>
- <action date="2010-09-18" type="fix" issue="LOG4PHP-105" dev="Ivan Habunek">LoggerMDC needs refactoring + tests</action>
- <action date="2010-09-18" type="update" dev="Ivan Habunek">Added __toString magic method to LoggerLevel.</action>
- <action date="2010-07-20" type="fix" issue="LOG4PHP-117" dev="Ivan Habunek" due-to="Maciej Mazur" due-to-email="mamciek at gmail dot com">LoggerConfiguratorIni::configure() and unexptected results from error_get_last()</action>
- <action date="2010-07-20" type="fix" issue="LOG4PHP-113" dev="Ivan Habunek">Milliseconds do not change when using LoggerLayoutPattern</action>
- <action date="2010-06-18" type="fix" issue="LOG4PHP-115" dev="Christian Grobmeier" due-to="Vaceletm" due-to-email="manuel dot vacelet at gmail dot com">Instanciate LoggerAppenderPDO by hand throw exception</action>
- <action date="2010-06-18" type="update" issue="LOG4PHP-36" dev="Christian Grobmeier" due-to="Moritz Schmidt" due-to-email="fusselwurm at gmail dot com">PHP Configurator: set remaining properties to appenders</action>
- <action date="2010-06-18" type="update" issue="LOG4PHP-110" dev="Christian Grobmeier" due-to="Vladimir Gorej" due-to-email="binarygroop at gmail dot com">MongoDB: improved exception handling</action>
- <action date="2010-05-27" type="fix" issue="LOG4PHP-112" dev="Christian Grobmeier" due-to="Darja Ryazhskikh" due-to-email="ifndef at yandex dot ru">Logging ClassName doesn't work</action>
- <action date="2010-05-04" type="update" issue="LOG4PHP-108" dev="Christian Grobmeier" due-to="Ivan Habunek" due-to-email="ivan dot habunek at gmail dot com">Improved add HTML line break feature in LoggerAppenderEcho</action>
- <action date="2010-04-23" type="update" issue="LOG4PHP-109" dev="Christian Grobmeier" due-to="Vladimir Gorej" due-to-email="binarygroop at gmail dot com">patch for Throwable information associated with logging event</action>
- <action date="2010-04-22" type="update" issue="LOG4PHP-111" dev="Christian Grobmeier" due-to="Ivan Habunek" due-to-email="ivan dot habunek at gmail dot com">Documentation: Problem using a custom ConversionPattern</action>
- <action date="2010-04-22" type="add" issue="LOG4PHP-108" dev="Christian Grobmeier" due-to="Florian Platzer" due-to-email="florian dot platzer at kfv dot at ">Add HTML line break to LoggerAppenderEcho output</action>
- <action date="2010-03-25" type="fix" dev="Christian Hammers">Lowered pear_installer version dependency to 1.7.0</action>
- <action date="2010-03-22" type="update" dev="Christian Grobmeier" due-to="Ivan Habunek" due-to-email="ivan dot habunek at gmail dot com">Included new LoggerLayoutPattern tests</action>
- <action date="2010-03-22" type="fix" issue="LOG4PHP-103" dev="Christian Grobmeier" due-to="Moritz Schmidt" due-to-email="fusselwurm at gmail dot com">Exception when using more than one LoggerAppenderFile</action>
- <action date="2010-03-22" type="fix" issue="LOG4PHP-102" dev="Christian Grobmeier" due-to="Ivan Habunek" due-to-email="ivan dot habunek at gmail dot com">LoggerLayoutPattern fails tests</action>
- <action date="2010-03-22" type="update" issue="LOG4PHP-100" dev="Christian Grobmeier" due-to="Moritz Schmidt" due-to-email="fusselwurm at gmail dot com">Directly assign an array on Logger PHP configuration</action>
- <action date="2010-02-20" type="add" issue="LOG4PHP-95" dev="Christian Grobmeier" due-to="Ivan Habunek" due-to-email="ivan dot habunek at gmail dot com">Add trace level to Log4PHP</action>
- <action date="2010-01-29" type="fix" issue="LOG4PHP-96" dev="Christian Grobmeier" due-to="Tommy Montgomery">Some of the tests don't pass under Windows</action>
- <action date="2010-01-05" type="fix" issue="LOG4PHP-93" dev="Christian Grobmeier" due-to="Hiroaki Kawai" due-to-email="kawai at apache dot org ">LoggerClassNamePatternConverter accessing private property</action>
- <action date="2010-01-05" type="fix" issue="LOG4PHP-91" dev="Christian Grobmeier" due-to="Dan Barkwell" due-to-email="dan at barkwell dot com">LoginOptionConverter.php (used wrong constant name)</action>
- </release>
- <release version="2.0.0" date="2009-12-12" description="PHP 5 compatibility">
- <action type="fix" issue="LOG4PHP-3">Maven 2.0 build</action>
- <action type="fix" issue="LOG4PHP-7">Updated source file headers with current ASF notice</action>
- <action type="fix">PHP 5 compatibility modification.</action>
- <action type="fix" issue="LOG4PHP-1" dev="Christian Grobmeier">removed all @author tags. All contributors are named (with task) in the changelog file</action>
- <action type="fix" issue="LOG4PHP-4" dev="Michael Aichler">Fatal error for constructor in LoggerAppenderRollingFile</action>
- <action type="fix" issue="LOG4PHP-5" dev="Michael Aichler">LoggerAppenderRollingFile unable to open file and append logs</action>
- <action type="fix" issue="LOG4PHP-7" dev="Curt Arnold">Change copyright notices to conform to the Source Header and Copyright Notice Policy</action>
- <action type="fix" issue="LOG4PHP-9" dev="Christian Grobmeier">log4php.dtd should be reviewed</action>
- <action type="fix" issue="LOG4PHP-11" dev="Hiroaki Kawai">trailing "\n"</action>
- <action type="fix" issue="LOG4PHP-12" dev="Knut Urdalen">LoggerAppenderFile does not create missing directories</action>
- <action type="fix" issue="LOG4PHP-13" dev="Michael Aichler">LoggerPropertyConfigurator: Only variables should be assigned by reference</action>
- <action type="fix" issue="LOG4PHP-14" dev="Michael Aichler">LoggerPropertySetter: warnings about is_a() and non-static method</action>
- <action type="fix" issue="LOG4PHP-15" dev="Michael Aichler">Logger: warnings about is_a()</action>
- <action type="fix" issue="LOG4PHP-16" dev="Gary Richardson">Patch for LoggerAppenderSyslog to use Layouts</action>
- <action type="fix" issue="LOG4PHP-17" dev="Yomei Komiya">%l Pattern layout raises a protected property access error</action>
- <action type="fix" issue="LOG4PHP-18" dev="Yomei Komiya">Date pattern %d conversion is invalid</action>
- <action type="fix" issue="LOG4PHP-19" dev="Yomei Komiya">Logger location info is invalid in log outputs of Logger's subclasses</action>
- <action type="fix" issue="LOG4PHP-20" dev="Corin Lawson">Custom layout for LoggerAppenderPhp</action>
- <action type="fix" issue="LOG4PHP-22" dev="Christian Grobmeier">log4php.dtd invalid</action>
- <action type="fix" issue="LOG4PHP-23" dev="Christian Grobmeier">Mixed PHP4 and PHP5 syntax</action>
- <action type="fix" issue="LOG4PHP-24" dev="Dennis Korbar">LoggerAppenderRollingFile unable to rollover</action>
- <action type="fix" issue="LOG4PHP-25" dev="Christian Hammers, Knut Urdalen">Allow to set environment variables in LoggerOptionConverter</action>
- <action type="fix" issue="LOG4PHP-28" dev="Michael Kuenzli, Knut Urdalen">LoggerAppenderConsole doesn't write to STDERR</action>
- <action type="fix" issue="LOG4PHP-33" dev="Knut Urdalen">Appenders is not properly closed upon destruction</action>
- <action type="update" issue="LOG4PHP-29" dev="Knut Urdalen">Load classes through autoload instead of explicitly include them</action>
- <action type="update" issue="LOG4PHP-30" dev="Christian Grobmeier">Implement LoggerAppenderPDO</action>
- <action type="update" issue="LOG4PHP-31" dev="Knut Urdalen">Removing unnecessary use of LOG4PHP_DIR</action>
- <action type="update" issue="LOG4PHP-32" dev="Knut Urdalen, Christian Grobmeier">Refactor from using define to class contants (Knut Urdalen, Christian Grobmeier)</action>
- <action type="update" issue="LOG4PHP-34" dev="Christian Grobmeier">Remove all internal debugging</action>
- <action type="update" issue="LOG4PHP-35" dev="Knut Urdalen">Replace LOG4PHP_LINE_SEP with PHP_EOL</action>
- <action type="update" issue="LOG4PHP-37" dev="Christian Grobmeier">removed LoggerAppenderDB in favour to LoggerAppenderPDO</action>
- <action type="update" issue="LOG4PHP-38" dev="Knut Urdalen">Replace is_a() with instanceof</action>
- <action type="update" issue="LOG4PHP-39" dev="Knut Urdalen">Remove deprecated methods</action>
- <action type="update" issue="LOG4PHP-40" dev="Christian Grobmeier">Merge LoggerAppender and LoggerAppenderSkeleton</action>
- <action type="update" issue="LOG4PHP-43" dev="Knut Urdalen">Remove size restriction of MDC table in LoggerMDC</action>
- <action type="update" issue="LOG4PHP-44" dev="Knut Urdalen">PEAR package</action>
- <action type="fix" issue="LOG4PHP-46" dev="Christian Hammers">Use PreparedStatement in PDO-Appender</action>
- <action type="fix" issue="LOG4PHP-47" dev="Christian Hammers">PDO Appender now uses quote() due to PreparedStatements</action>
- <action type="update" issue="LOG4PHP-50" dev="Christian Grobmeier">Create more File Appender Tests</action>
- <action type="update" issue="LOG4PHP-52" dev="Christian Grobmeier">Use of custom factorys is discouraged - clean up</action>
- <action type="update" issue="LOG4PHP-53" dev="Christian Grobmeier">Removed references were appropriate</action>
- <action type="fix" issue="LOG4PHP-54" dev="Christian Grobmeier">PHPDoc is wrong due to class movements - clean up</action>
- <action type="update" issue="LOG4PHP-56" dev="Christian Grobmeier">Replace define('LOG4PHP_CONFIGURATION' by static variable</action>
- <action type="update" issue="LOG4PHP-57" dev="Christian Grobmeier">Make use of destructors instead of Logger::shutdown</action>
- <action type="fix" issue="LOG4PHP-59" dev="Christian Grobmeier, Christian Hammers">LoggerAppenderConsole is initialized wrong</action>
- <action type="update" issue="LOG4PHP-60" dev="Christian Hammers">Improved quickstart.apt</action>
- <action type="update" issue="LOG4PHP-62" dev="Christian Hammers">Does not print warning if ini file is corrupt</action>
- <action type="update" issue="LOG4PHP-63" dev="Christian Hammers">PDOAppender should throw LoggerException on database problems</action>
- <action type="fix" issue="LOG4PHP-64" dev="Christian Hammers">Remove deprecated call-by-reference in LoggerLayoutPattern</action>
- <action type="fix" issue="LOG4PHP-65" dev="Christian Grobmeier">Mixing protected and private in Logger and the inheriting LoggerRoot</action>
- <action type="fix" issue="LOG4PHP-66" dev="Christian Hammers">LoggerConfiguratorBasicTest fails in "mvn test" but not in phpunit</action>
- <action type="fix" issue="LOG4PHP-67" dev="Christian Hammers">Refactoring: Use Logger instead of LoggerManager</action>
- <action type="fix" issue="LOG4PHP-71" dev="Christian Grobmeier">Using LoggerAppenderFile logging to the log file in one Apache session blocks every other Apache session that tries to write to the file until the original request has been processed</action>
- <action type="fix" issue="LOG4PHP-76" dev="Dan Hansen">Unable to configure socket appender with attribute useXml = true</action>
- <action type="fix" issue="LOG4PHP-77" dev="Dan Hansen">LoggerReflectionUtils::setter() should be defined as a static method</action>
- <action type="fix" issue="LOG4PHP-79" dev="Christian Hammers">Increased field sizes in AppenderPDO database tables</action>
- <action type="fix" issue="LOG4PHP-80" dev="Christian Hammers">An exception is now thrown if an unknown property is set via config file</action>
- <action type="fix" issue="LOG4PHP-81" dev="Christian Hammers">Boolean values in .properties files are now correctly parsed</action>
- <action type="fix" issue="LOG4PHP-82" dev="Christian Hammers">Added more examples to the API docs</action>
- <action type="fix" issue="LOG4PHP-84" dev="Christian Hammers">Fixed call of undefined method when using RendererMap</action>
- <action type="fix" issue="LOG4PHP-86" dev="Christian Hammers">LoggerAppenderRollingFile should not fail if the file does not already exist</action>
- <action type="fix" dev="Christian Grobmeier">LoggerXmlConfigurator can now interpret threshold commands at appender level</action>
- <action type="update" dev="Knut Urdalen">Initial port to PHP 5</action>
- <action type="update" dev="Knut Urdalen">Established new unit test suite</action>
- <action type="update" dev="Knut Urdalen">Added a range of examples</action>
- <action type="update">Created common ReflectionUtils class and moved factory calls to there</action>
- </release>
- </body>
-</document>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_console.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_console.php b/src/examples/php/appender_console.php
deleted file mode 100644
index 1803e39..0000000
--- a/src/examples/php/appender_console.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_console.properties');
-
-$logger = Logger::getRootLogger();
-$logger->debug("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_dailyfile.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_dailyfile.php b/src/examples/php/appender_dailyfile.php
deleted file mode 100644
index 6cd78d8..0000000
--- a/src/examples/php/appender_dailyfile.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_dailyfile.properties');
-
-$logger = Logger::getRootLogger();
-$logger->debug("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_echo.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_echo.php b/src/examples/php/appender_echo.php
deleted file mode 100644
index b96f1b0..0000000
--- a/src/examples/php/appender_echo.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_echo.properties');
-$logger = Logger::getLogger('appender_echo');
-$logger->debug("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_file.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_file.php b/src/examples/php/appender_file.php
deleted file mode 100644
index 45a9359..0000000
--- a/src/examples/php/appender_file.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_file.properties');
-$logger = Logger::getRootLogger();
-$logger->debug("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_firephp.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_firephp.php b/src/examples/php/appender_firephp.php
deleted file mode 100644
index 6fd2277..0000000
--- a/src/examples/php/appender_firephp.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-/**
- * Appender_Firephp example. Copy this file into your DOCUMENT_ROOT
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor
- * license agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership. The ASF licenses this
- * file to you under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software distributed
- * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * PHP version 5
- *
- * @category Example
- * @package LoggerAppenderFirephp
- * @author Bruce Ingalls <Bruce.Ingalls-at-gmail-dot-com>
- * @copyright 2012 Apache Software Foundation
- * @license Apache License, Version 2.0
- * @version SVN: $Id:$
- * @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Configuration/Constants
- * @link https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/FirePHPHandler.php
- * @since Feb 22, 2012
- * @internal CodeSniffs as PEAR, adapted to Apache style. Phpmd clean.
- */
-
-//Change next line to URL path following domain. I.e. chop off 'http://localhost'
-define('INSIGHT_SERVER_PATH', $_SERVER['REQUEST_URI']);
-//define('INSIGHT_SERVER_PATH', $_SERVER['SCRIPT_NAME']);
-define('INSIGHT_DEBUG', true); //Comment, after config is debugged, to remove 'Flushing headers'
-define('INSIGHT_IPS', '*'); //Your IP here for extra security
-//Works, but replace next line with free key from Developer Companion, for security on live sites
-define('INSIGHT_AUTHKEYS', '*');
-define('INSIGHT_PATHS', dirname(__FILE__));
-
-//EDIT YOUR FirePHP LOCATION HERE
-// If using ZIP Archive
-//TODO: Add 'lib/' of extracted archive to include path
-require_once 'FirePHP/Init.php'; //Must be declared before log4php
-
-// If using PHAR Archive (php 5.3+)
-//require_once('phar://.../firephp.phar/FirePHP/Init.php');
-// TODO: Replace ----^^^
-
-
-
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_firephp.xml');
-
-?>
-<!-- RUN THIS FROM WEB DOCUMENT_ROOT (~/public_html/ or /var/www/) -->
-
-<h1>FirePHP appender test & configuration</h1>
-<h2>Requirements</h2>
-<ul>
- <li>
- <a href="http://logging.apache.org/log4php/">Apache log4php</a>
- >= v2.2.2
- </li>
- <li>
- <a href="http://getfirebug.com/">Mozilla Firebug</a> with console & net enabled.
- </li>
- <li>
- <a href="http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Welcome"
- >FirePHP >= 1.0</a> (beta, as of March 2012) server lib & Firefox plugin.
- This one is also referred to as <i>Insight</i> or <i>Developer's Companion</i>
- </li>
-</ul>
-
-<h2>Untested (or not supported)</h2>
-<ul>
- <li>Old versions of Mozilla Firefox</li>
- <li>
- Versions of FirePHP prior to <b>v1.0beta</b>!
- Currently, this is the default at addons.mozilla.org !
- </li>
- <li>
- <a href="https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/FirePHPHandler.php"
- >Monolog</a>
- </li>
- <li>*FirePHP* for Google Chrome</li>
- <li>No other browser currently has a similar plugin</li>
-</ul>
-
-<h2>Instructions</h2>
-<ul>
- <li>Install the requirements above, following their instructions</li>
- <li>If you installed the phar package, edit its location at the top of this file</li>
- <li>Ensure this file has web server read permissions in <code>DOCUMENT_ROOT</code></li>
- <li>
- Copy <code>appender_firephp.xml</code> to log4php.xml into your DOCUMENT_ROOT
- <small>(Note that log4php.xml runs LogggerAppenderFirephp at debug level)</small>
- </li>
- <li>Optional: launch Developer Companion. Follow its instructions to generate a key</li>
- <li>Open the Firebug console (window), and enable <i>Console</i> & <i>Net</i></li>
- <li>Reload Firefox</li>
- <li>
- If the greeting in Firebug console displays with problems, click on it,
- to see a stack trace
- </li>
- <li>
- Comment out <b><code>define('INSIGHT_DEBUG', true);</code></b> at the top of
- this file, to disable the notice:
- <small style="border: 2px solid black; background-color: red;">
- <span style="font-weight: bold;">[INSIGHT]</span> Flushing headers
- </small>
- </li>
-</ul>
-
-<h2>If you see a greeting in Firebug, you can now return to work!</h2>
-
-<?php
-$log = Logger::getLogger('FirePhp_Example_Logger_Name');
-$log->debug('Congrats! Enjoy log4php with FirePHP!');
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_mail.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_mail.php b/src/examples/php/appender_mail.php
deleted file mode 100644
index f1815ff..0000000
--- a/src/examples/php/appender_mail.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_mail.properties');
-$logger = Logger::getRootLogger();
-$logger->fatal("Some critical message!");
-$logger->fatal("Some more critical message!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_mailevent.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_mailevent.php b/src/examples/php/appender_mailevent.php
deleted file mode 100644
index 2921ff0..0000000
--- a/src/examples/php/appender_mailevent.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_mailevent.properties');
-$logger = Logger::getRootLogger();
-$logger->fatal("Some critical message!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_mongodb.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_mongodb.php b/src/examples/php/appender_mongodb.php
deleted file mode 100644
index b3d8b73..0000000
--- a/src/examples/php/appender_mongodb.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_mongodb.xml');
-
-$logger = Logger::getLogger('main');
-$logger->debug("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_null.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_null.php b/src/examples/php/appender_null.php
deleted file mode 100644
index 82fbe8a..0000000
--- a/src/examples/php/appender_null.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_null.properties');
-$logger = Logger::getRootLogger();
-$logger->fatal("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_pdo.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_pdo.php b/src/examples/php/appender_pdo.php
deleted file mode 100644
index f695c5e..0000000
--- a/src/examples/php/appender_pdo.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_pdo.properties');
-$logger = Logger::getRootLogger();
-$logger->fatal("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_php.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_php.php b/src/examples/php/appender_php.php
deleted file mode 100644
index fd5816a..0000000
--- a/src/examples/php/appender_php.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_php.properties');
-$logger = Logger::getRootLogger();
-$logger->debug("Hello PHP!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_rollingfile.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_rollingfile.php b/src/examples/php/appender_rollingfile.php
deleted file mode 100644
index 1455705..0000000
--- a/src/examples/php/appender_rollingfile.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_rollingfile.properties');
-
-$logger = Logger::getRootLogger();
-$logger->debug("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_socket.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_socket.php b/src/examples/php/appender_socket.php
deleted file mode 100644
index 3a8c4c3..0000000
--- a/src/examples/php/appender_socket.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_socket.properties');
-$logger = Logger::getRootLogger();
-$logger->fatal("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_socket_server.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_socket_server.php b/src/examples/php/appender_socket_server.php
deleted file mode 100644
index ed68225..0000000
--- a/src/examples/php/appender_socket_server.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/appender_socket_server.properties');
-
-require_once 'Net/Server.php';
-require_once 'Net/Server/Handler.php';
-
-class Net_Server_Handler_Log extends Net_Server_Handler {
-
- private $hierarchy;
-
- function onStart() {
- $this->hierarchy = Logger::getRootLogger();
- }
-
- function onReceiveData($clientId = 0, $data = "") {
- $events = $this->getEvents($data);
- foreach($events as $event) {
- $root = $this->hierarchy->getRootLogger();
- if($event->getLoggerName() === 'root') {
- $root->callAppenders($event);
- } else {
- $loggers = $this->hierarchy->getCurrentLoggers();
- foreach($loggers as $logger) {
- $root->callAppenders($event);
- $appenders = $logger->getAllAppenders();
- foreach($appenders as $appender) {
- $appender->doAppend($event);
- }
- }
- }
- }
- }
-
- function getEvents($data) {
- if (preg_match('/^<log4php:event/', $data)) {
- throw new Exception("Please use 'log4php.appender.default.useXml = false' in appender_socket.properties file!");
- }
- preg_match('/^(O:\d+)/', $data, $parts);
- $events = split($parts[1], $data);
- array_shift($events);
- $size = count($events);
- for($i=0; $i<$size; $i++) {
- $events[$i] = unserialize($parts[1].$events[$i]);
- }
- return $events;
- }
-}
-
-$host = 'localhost';
-$port = 4242;
-$server = Net_Server::create('sequential', $host, $port);
-$handler = new Net_Server_Handler_Log();
-$server->setCallbackObject($handler);
-$server->start();
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/appender_syslog.php
----------------------------------------------------------------------
diff --git a/src/examples/php/appender_syslog.php b/src/examples/php/appender_syslog.php
deleted file mode 100644
index b43336c..0000000
--- a/src/examples/php/appender_syslog.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/appender_syslog.properties');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/cache.php
----------------------------------------------------------------------
diff --git a/src/examples/php/cache.php b/src/examples/php/cache.php
deleted file mode 100644
index 43ef88e..0000000
--- a/src/examples/php/cache.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/cache.properties');
-
-$cache = 'target/examples/hierarchy.cache';
-
-if(!file_exists($cache)) {
- $dir = dirname($cache);
- if(!is_dir($dir)) {
- mkdir($dir, 0777, true);
- }
- $old_logger = Logger::getRootLogger();
- file_put_contents($cache, serialize($old_logger));
-}
-$logger = unserialize(file_get_contents($cache));
-
-$logger->debug('Debug message from cached logger');
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/configurator_basic.php
----------------------------------------------------------------------
diff --git a/src/examples/php/configurator_basic.php b/src/examples/php/configurator_basic.php
deleted file mode 100644
index 60a664b..0000000
--- a/src/examples/php/configurator_basic.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-define('LOG4PHP_CONFIGURATOR_CLASS', 'LoggerConfiguratorBasic');
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/configurator_php.php
----------------------------------------------------------------------
diff --git a/src/examples/php/configurator_php.php b/src/examples/php/configurator_php.php
deleted file mode 100644
index 8544912..0000000
--- a/src/examples/php/configurator_php.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/configurator_php.php', 'LoggerConfiguratorPhp');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/configurator_xml.php
----------------------------------------------------------------------
diff --git a/src/examples/php/configurator_xml.php b/src/examples/php/configurator_xml.php
deleted file mode 100644
index d8fef03..0000000
--- a/src/examples/php/configurator_xml.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/configurator_xml.xml');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/filter_denyall.php
----------------------------------------------------------------------
diff --git a/src/examples/php/filter_denyall.php b/src/examples/php/filter_denyall.php
deleted file mode 100644
index 103684c..0000000
--- a/src/examples/php/filter_denyall.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/filter_denyall.xml');
-$logger = Logger::getRootLogger();
-$logger->info("Some text that will be discarded");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/filter_levelmatch.php
----------------------------------------------------------------------
diff --git a/src/examples/php/filter_levelmatch.php b/src/examples/php/filter_levelmatch.php
deleted file mode 100644
index 8e76051..0000000
--- a/src/examples/php/filter_levelmatch.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/filter_levelmatch.xml');
-$logger = Logger::getRootLogger();
-$logger->debug("Matching and will be rejected");
-$logger->info("Not matching and will be accepted");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/filter_levelrange.php
----------------------------------------------------------------------
diff --git a/src/examples/php/filter_levelrange.php b/src/examples/php/filter_levelrange.php
deleted file mode 100644
index 6263951..0000000
--- a/src/examples/php/filter_levelrange.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/filter_levelrange.xml');
-$logger = Logger::getRootLogger();
-$logger->debug("This is a debug message");
-$logger->info("This is an info message");
-$logger->warn("This is a warning");
-$logger->error("This is an error");
-$logger->fatal("This is a fatal error");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/filter_stringmatch.php
----------------------------------------------------------------------
diff --git a/src/examples/php/filter_stringmatch.php b/src/examples/php/filter_stringmatch.php
deleted file mode 100644
index ac3e38d..0000000
--- a/src/examples/php/filter_stringmatch.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/filter_stringmatch.xml');
-$logger = Logger::getRootLogger();
-$logger->debug("Some text to match that will be rejected");
-$logger->info("Some other text that will be accepted");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/layout_html.php
----------------------------------------------------------------------
diff --git a/src/examples/php/layout_html.php b/src/examples/php/layout_html.php
deleted file mode 100644
index 2ea66a7..0000000
--- a/src/examples/php/layout_html.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/layout_html.properties');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/layout_pattern.php
----------------------------------------------------------------------
diff --git a/src/examples/php/layout_pattern.php b/src/examples/php/layout_pattern.php
deleted file mode 100644
index 345f96e..0000000
--- a/src/examples/php/layout_pattern.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/layout_pattern.properties');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
-$logger->debug("Second line");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/layout_simple.php
----------------------------------------------------------------------
diff --git a/src/examples/php/layout_simple.php b/src/examples/php/layout_simple.php
deleted file mode 100644
index a9fac35..0000000
--- a/src/examples/php/layout_simple.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/layout_simple.properties');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/layout_ttcc.php
----------------------------------------------------------------------
diff --git a/src/examples/php/layout_ttcc.php b/src/examples/php/layout_ttcc.php
deleted file mode 100644
index 41b0969..0000000
--- a/src/examples/php/layout_ttcc.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/layout_ttcc.properties');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/layout_xml.php
----------------------------------------------------------------------
diff --git a/src/examples/php/layout_xml.php b/src/examples/php/layout_xml.php
deleted file mode 100644
index e9c91a2..0000000
--- a/src/examples/php/layout_xml.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/layout_xml.properties');
-$logger = Logger::getRootLogger();
-$logger->info("Hello World!");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/mdc.php
----------------------------------------------------------------------
diff --git a/src/examples/php/mdc.php b/src/examples/php/mdc.php
deleted file mode 100644
index 2b17302..0000000
--- a/src/examples/php/mdc.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-Logger::configure(dirname(__FILE__).'/../resources/mdc.properties');
-LoggerMDC::put('username', 'knut');
-$logger = Logger::getRootLogger();
-$logger->debug("Testing MDC");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/ndc.php
----------------------------------------------------------------------
diff --git a/src/examples/php/ndc.php b/src/examples/php/ndc.php
deleted file mode 100644
index 4edec6a..0000000
--- a/src/examples/php/ndc.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/ndc.properties');
-$logger = Logger::getRootLogger();
-
-LoggerNDC::push('conn=1234');
-$logger->debug("just received a new connection");
-LoggerNDC::push('client=ab23');
-$logger->debug("some more messages that can");
-$logger->debug("now related to a client");
-LoggerNDC::pop();
-LoggerNDC::pop();
-$logger->debug("back and waiting for new connections");
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/renderer_default.php
----------------------------------------------------------------------
diff --git a/src/examples/php/renderer_default.php b/src/examples/php/renderer_default.php
deleted file mode 100644
index 1100cec..0000000
--- a/src/examples/php/renderer_default.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/renderer_default.properties');
-
-class Person {
- public $firstName = 'John';
- public $lastName = 'Doe';
-
- public function __toString() {
- return $this->lastName . ', ' . $this->firstName;
- }
-}
-
-$person = new Person();
-
-$logger = Logger::getRootLogger();
-$logger->debug("Now comes the current MyClass object:");
-$logger->debug($person);
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/renderer_map.php
----------------------------------------------------------------------
diff --git a/src/examples/php/renderer_map.php b/src/examples/php/renderer_map.php
deleted file mode 100644
index 8f9e802..0000000
--- a/src/examples/php/renderer_map.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-Logger::configure(dirname(__FILE__).'/../resources/renderer_map.properties');
-
-class Person {
- public $firstName = 'John';
- public $lastName = 'Doe';
-}
-
-class PersonRenderer implements LoggerRendererObject {
- public function render($o) {
- return $o->lastName.', '.$o->firstName;
- }
-}
-
-$person = new Person();
-
-$logger = Logger::getRootLogger();
-$logger->debug("Now comes the current Person object:");
-$logger->debug($person);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/php/simple.php
----------------------------------------------------------------------
diff --git a/src/examples/php/simple.php b/src/examples/php/simple.php
deleted file mode 100644
index 3dc9a37..0000000
--- a/src/examples/php/simple.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// START SNIPPET: doxia
-require_once dirname(__FILE__).'/../../main/php/Logger.php';
-
-class Log4phpTest {
- private $_logger;
-
- public function __construct() {
- $this->_logger = Logger::getLogger('Log4phpTest');
- $this->_logger->debug('Hello!');
- }
-}
-
-function Log4phpTestFunction() {
- $logger = Logger::getLogger('Log4phpTestFunction');
- $logger->debug('Hello again!');
-}
-
-$test = new Log4phpTest();
-Log4phpTestFunction();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_console.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_console.properties b/src/examples/resources/appender_console.properties
deleted file mode 100644
index d2f99e8..0000000
--- a/src/examples/resources/appender_console.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.console = LoggerAppenderConsole
-log4php.appender.console.target = STDOUT
-log4php.appender.console.layout = LoggerLayoutSimple
-log4php.rootLogger = DEBUG, console
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_dailyfile.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_dailyfile.properties b/src/examples/resources/appender_dailyfile.properties
deleted file mode 100644
index 955029c..0000000
--- a/src/examples/resources/appender_dailyfile.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderDailyFile
-log4php.appender.default.layout = LoggerLayoutTTCC
-log4php.appender.default.datePattern = Ymd
-log4php.appender.default.file = target/examples/daily_%s.log
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_echo.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_echo.properties b/src/examples/resources/appender_echo.properties
deleted file mode 100644
index 854c45b..0000000
--- a/src/examples/resources/appender_echo.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutTTCC
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_file.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_file.properties b/src/examples/resources/appender_file.properties
deleted file mode 100644
index b55142e..0000000
--- a/src/examples/resources/appender_file.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderFile
-log4php.appender.default.file = target/examples/file.log
-log4php.appender.default.layout = LoggerLayoutTTCC
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_firephp.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_firephp.xml b/src/examples/resources/appender_firephp.xml
deleted file mode 100644
index 279444e..0000000
--- a/src/examples/resources/appender_firephp.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration xmlns="http://logging.apache.org/log4php/">
- <appender name="firePhpAppender" class="LoggerAppenderFirephp">
- <layout class="LoggerLayoutSimple" />
- <param name="medium" value="page" />
- </appender>
- <appender name="consoleAppender" class="LoggerAppenderConsole" />
-
- <root>
- <level value="DEBUG" />
- <appender_ref ref="firePhpAppender" />
- <appender_ref ref="consoleAppender" />
- </root>
-</configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_mail.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_mail.properties b/src/examples/resources/appender_mail.properties
deleted file mode 100644
index 66cf586..0000000
--- a/src/examples/resources/appender_mail.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.email = LoggerAppenderMail
-log4php.appender.email.layout = LoggerLayoutTTCC
-log4php.appender.email.from = someone@example.com
-log4php.appender.email.to = root@localhost
-log4php.appender.email.subject = Log4php test
-log4php.rootLogger = FATAL, email
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_mailevent.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_mailevent.properties b/src/examples/resources/appender_mailevent.properties
deleted file mode 100644
index 2ec31fc..0000000
--- a/src/examples/resources/appender_mailevent.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.email = LoggerAppenderMail
-log4php.appender.email.layout = LoggerLayoutTTCC
-log4php.appender.email.from = someone@example.com
-log4php.appender.email.to = root
-log4php.appender.email.subject = Log4php test
-log4php.rootLogger = FATAL, email
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_mongodb.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_mongodb.xml b/src/examples/resources/appender_mongodb.xml
deleted file mode 100644
index bd9416c..0000000
--- a/src/examples/resources/appender_mongodb.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
- <appender name="default" class="LoggerAppenderMongoDB">
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</log4php:configuration>
[07/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerAppenderTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerAppenderTest.php b/src/test/php/LoggerAppenderTest.php
deleted file mode 100644
index 9b5aac8..0000000
--- a/src/test/php/LoggerAppenderTest.php
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderTest extends PHPUnit_Framework_TestCase {
-
- public function testThreshold() {
- $appender = new LoggerAppenderEcho("LoggerAppenderTest");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
-
- $warn = LoggerLevel::getLevelWarn();
- $appender->setThreshold($warn);
- $appender->activateOptions();
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelFatal(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "FATAL - testmessage" . PHP_EOL;
- self::assertEquals($e, $v);
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "ERROR - testmessage" . PHP_EOL;
- self::assertEquals($e, $v);
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "WARN - testmessage" . PHP_EOL;
- self::assertEquals($e, $v);
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelInfo(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "";
- self::assertEquals($e, $v);
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
- ob_start();
- $appender->doAppend($event);
- $v = ob_get_contents();
- ob_end_clean();
- $e = "";
- self::assertEquals($e, $v);
- }
-
- public function testGetThreshold() {
- $appender = new LoggerAppenderEcho("LoggerAppenderTest");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
-
- $warn = LoggerLevel::getLevelWarn();
- $appender->setThreshold($warn);
-
- $a = $appender->getThreshold();
- self::assertEquals($warn, $a);
- }
-
- public function testSetStringThreshold() {
- $appender = new LoggerAppenderEcho("LoggerAppenderTest");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
-
- $warn = LoggerLevel::getLevelWarn();
- $appender->setThreshold('WARN');
- $a = $appender->getThreshold();
- self::assertEquals($warn, $a);
-
- $e = LoggerLevel::getLevelFatal();
- $appender->setThreshold('FATAL');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
-
- $e = LoggerLevel::getLevelError();
- $appender->setThreshold('ERROR');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
-
- $e = LoggerLevel::getLevelDebug();
- $appender->setThreshold('DEBUG');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
-
- $e = LoggerLevel::getLevelInfo();
- $appender->setThreshold('INFO');
- $a = $appender->getThreshold();
- self::assertEquals($e, $a);
- }
-
- public function testSetFilter() {
- $appender = new LoggerAppenderEcho("LoggerAppenderTest");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
-
- $filter = new LoggerFilterDenyAll();
- $appender->addFilter($filter);
-
- $filter2 = new LoggerFilterLevelMatch();
- $appender->addFilter($filter2);
-
- $first = $appender->getFilter();
- self::assertEquals($first, $filter);
-
- $next = $first->getNext();
- self::assertEquals($next, $filter2);
-
- $appender->clearFilters();
- $nullfilter = $appender->getFilter();
- self::assertNull($nullfilter);
- }
-
- public function testInstanciateWithLayout() {
- $appender = new LoggerAppenderEcho("LoggerAppenderTest");
-
- $expected = "LoggerLayoutSimple";
- $actual = $appender->getLayout();
- $this->assertInstanceof($expected, $actual);
- }
-
- public function testOverwriteLayout() {
- $layout = new LoggerLayoutSimple();
- $appender = new LoggerAppenderEcho("LoggerAppenderTest");
- $appender->setLayout($layout);
-
- $actual = $appender->getLayout();
- $this->assertEquals($layout, $actual);
- }
-
- public function testRequiresNoLayout() {
- $appender = new LoggerAppenderNull("LoggerAppenderTest");
-
- $actual = $appender->getLayout();
- $this->assertNull($actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerConfiguratorTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerConfiguratorTest.php b/src/test/php/LoggerConfiguratorTest.php
deleted file mode 100644
index e8ff410..0000000
--- a/src/test/php/LoggerConfiguratorTest.php
+++ /dev/null
@@ -1,452 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-
-class CostumDefaultRenderer implements LoggerRenderer {
- public function render($o) { }
-}
-
-
-/**
- *
- * @group configurators
- *
- */
- class LoggerConfiguratorTest extends PHPUnit_Framework_TestCase
- {
- /** Reset configuration after each test. */
- public function setUp() {
- Logger::resetConfiguration();
- }
- /** Reset configuration after each test. */
- public function tearDown() {
- Logger::resetConfiguration();
- }
-
- /** Check default setup. */
- public function testDefaultConfig() {
- Logger::configure();
-
- $actual = Logger::getCurrentLoggers();
- $expected = array();
- $this->assertSame($expected, $actual);
-
- $appenders = Logger::getRootLogger()->getAllAppenders();
- $this->assertInternalType('array', $appenders);
- $this->assertEquals(count($appenders), 1);
-
- $names = array_keys($appenders);
- $this->assertSame('default', $names[0]);
-
- $appender = array_shift($appenders);
- $this->assertInstanceOf('LoggerAppenderEcho', $appender);
- $this->assertSame('default', $appender->getName());
-
- $layout = $appender->getLayout();
- $this->assertInstanceOf('LoggerLayoutSimple', $layout);
-
- $root = Logger::getRootLogger();
- $appenders = $root->getAllAppenders();
- $this->assertInternalType('array', $appenders);
- $this->assertEquals(count($appenders), 1);
-
- $actual = $root->getLevel();
- $expected = LoggerLevel::getLevelDebug();
- $this->assertEquals($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid configuration param given. Reverting to default configuration.
- */
- public function testInputIsInteger() {
- Logger::configure(12345);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Configuration failed. Unsupported configuration file extension: yml
- */
- public function testYAMLFile() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/config.yml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid configuration provided for appender
- */
- public function testAppenderConfigNotArray() {
- $hierachyMock = $this->getMock('LoggerHierarchy', array(), array(), '', false);
-
- $config = array(
- 'appenders' => array(
- 'default',
- ),
- );
-
- $configurator = new LoggerConfiguratorDefault();
- $configurator->configure($hierachyMock, $config);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage No class given for appender
- */
- public function testNoAppenderClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid class [unknownClass] given for appender [foo]. Class does not exist. Skipping appender definition.
- */
- public function testNotExistingAppenderClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid class [stdClass] given for appender [foo]. Not a valid LoggerAppender class. Skipping appender definition.
- */
- public function testInvalidAppenderClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_appender_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistant filter class [Foo] specified on appender [foo]. Skipping filter definition.
- */
- public function testNotExistingAppenderFilterClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_filter_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistant option [fooParameter] specified on [LoggerFilterStringMatch]. Skipping.
- */
- public function testInvalidAppenderFilterParamter() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_parameters.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid filter class [stdClass] sepcified on appender [foo]. Skipping filter definition.
- */
- public function testInvalidAppenderFilterClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_filter_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistant layout class [Foo] specified for appender [foo]. Reverting to default layout.
- */
- public function testNotExistingAppenderLayoutClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_not_existing_layout_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid layout class [stdClass] sepcified for appender [foo]. Reverting to default layout.
- */
- public function testInvalidAppenderLayoutClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_invalid_layout_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Layout class not specified for appender [foo]. Reverting to default layout.
- */
- public function testNoAppenderLayoutClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/appenders/config_no_layout_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [stdClass] does not implement the LoggerRenderer interface.
- */
- public function testInvalidRenderingClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_invalid_rendering_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Rendering class not specified. Skipping renderer definition.
- */
- public function testNoRenderingClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendering_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Rendered class not specified. Skipping renderer definition.
- */
- public function testNoRenderedClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_no_rendered_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Failed adding renderer. Rendering class [DoesNotExistRenderer] not found.
- */
- public function testNotExistingRenderingClassSet() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/renderers/config_not_existing_rendering_class.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid additivity value [4711] specified for logger [myLogger].
- */
- public function testInvalidLoggerAddivity() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_invalid_additivity.xml');
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Nonexistnant appender [unknownAppender] linked to logger [myLogger].
- */
- public function testNotExistingLoggerAppendersClass() {
- Logger::configure(PHPUNIT_CONFIG_DIR . '/loggers/config_not_existing_appenders.xml');
- }
-
- /**
- * Test that an error is reported when config file is not found.
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Configuration failed. File not found
- */
- public function testNonexistantFile() {
- Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
-
- }
-
- /** Test correct fallback to the default configuration. */
- public function testNonexistantFileFallback() {
- @Logger::configure('hopefully/this/path/doesnt/exist/config.xml');
- $this->testDefaultConfig();
- }
-
- public function testAppendersWithLayout() {
- $config = Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('app1', 'app2')
- ),
- 'loggers' => array(
- 'myLogger' => array(
- 'appenders' => array('app1'),
- 'additivity'=> true
- )
- ),
- 'renderers' => array(
- array('renderedClass' => 'stdClass', 'renderingClass' => 'LoggerRendererDefault')
- ),
- 'appenders' => array(
- 'app1' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'params' => array(
- 'htmlLineBreaks' => false
- )
- ),
- 'app2' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'params' => array(
- 'conversionPattern' => 'message: %m%n'
- )
- ),
- 'filters' => array(
- array(
- 'class' => 'LoggerFilterStringMatch',
- 'params'=> array(
- 'stringToMatch' => 'foo',
- 'acceptOnMatch' => false
- )
- )
- )
- ),
- )
- ));
-
- ob_start();
- Logger::getRootLogger()->info('info');
- $actual = ob_get_contents();
- ob_end_clean();
-
- $expected = "INFO - info" . PHP_EOL . "message: info" . PHP_EOL;
- $this->assertSame($expected, $actual);
- }
-
- public function testThreshold()
- {
- Logger::configure(array(
- 'threshold' => 'WARN',
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- )
- ));
-
- $actual = Logger::getHierarchy()->getThreshold();
- $expected = LoggerLevel::getLevelWarn();
-
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid threshold value [FOO] specified. Ignoring threshold definition.
- */
- public function testInvalidThreshold()
- {
- Logger::configure(array(
- 'threshold' => 'FOO',
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- )
- ));
- }
-
- public function testAppenderThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'threshold' => 'INFO'
- ),
- )
- ));
-
- $actual = Logger::getRootLogger()->getAppender('default')->getThreshold();
- $expected = LoggerLevel::getLevelInfo();
-
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid threshold value [FOO] specified for appender [default]. Ignoring threshold definition.
- */
- public function testAppenderInvalidThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default')
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'threshold' => 'FOO'
- ),
- )
- ));
- }
-
- public function testLoggerThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- 'level' => 'ERROR'
- ),
- 'loggers' => array(
- 'default' => array(
- 'appenders' => array('default'),
- 'level' => 'WARN'
- )
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- )
- ));
-
- // Check root logger
- $actual = Logger::getRootLogger()->getLevel();
- $expected = LoggerLevel::getLevelError();
- self::assertSame($expected, $actual);
-
- // Check default logger
- $actual = Logger::getLogger('default')->getLevel();
- $expected = LoggerLevel::getLevelWarn();
- self::assertSame($expected, $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid level value [FOO] specified for logger [default]. Ignoring level definition.
- */
- public function testInvalidLoggerThreshold()
- {
- Logger::configure(array(
- 'loggers' => array(
- 'default' => array(
- 'appenders' => array('default'),
- 'level' => 'FOO'
- )
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- )
- ));
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Invalid level value [FOO] specified for logger [root]. Ignoring level definition.
- */
- public function testInvalidRootLoggerThreshold()
- {
- Logger::configure(array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- 'level' => 'FOO'
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- ),
- )
- ));
- }
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerExceptionTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerExceptionTest.php b/src/test/php/LoggerExceptionTest.php
deleted file mode 100644
index 5cb9978..0000000
--- a/src/test/php/LoggerExceptionTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-class MyException extends Exception { }
-
-/**
- * @group main
- */
-class LoggerExceptionTest extends PHPUnit_Framework_TestCase {
- /**
- * @expectedException LoggerException
- */
- public function testMessage() {
- try {
- throw new LoggerException("TEST");
- } catch (LoggerException $e) {
- self::assertEquals("TEST", $e->getMessage());
- throw $e;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerFilterTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerFilterTest.php b/src/test/php/LoggerFilterTest.php
deleted file mode 100644
index 3d32445..0000000
--- a/src/test/php/LoggerFilterTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage filters
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-class MyFilter extends LoggerFilter {}
-
-/**
- * @group filters
- */
-class LoggerFilterTest extends PHPUnit_Framework_TestCase {
-
- public function testDecide() {
- $filter = new MyFilter();
- // activateOptions is empty, but should at least throw no exeception
- $filter->activateOptions();
- $eventError = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
- $eventDebug = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
- $eventWarn = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
-
- $result = $filter->decide($eventError);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventDebug);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
-
- $result = $filter->decide($eventWarn);
- self::assertEquals($result, LoggerFilter::NEUTRAL);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerHierarchyTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerHierarchyTest.php b/src/test/php/LoggerHierarchyTest.php
deleted file mode 100644
index dabc4bc..0000000
--- a/src/test/php/LoggerHierarchyTest.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerHierarchyTest extends PHPUnit_Framework_TestCase {
-
- private $hierarchy;
-
- protected function setUp() {
- $this->hierarchy = new LoggerHierarchy(new LoggerRoot());
- }
-
- public function testResetConfiguration() {
- $root = $this->hierarchy->getRootLogger();
- $appender = new LoggerAppenderConsole('A1');
- $root->addAppender($appender);
-
- $logger = $this->hierarchy->getLogger('test');
- self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
-
- $this->hierarchy->resetConfiguration();
- self::assertEquals(LoggerLevel::getLevelDebug(), $root->getLevel());
- self::assertEquals(LoggerLevel::getLevelAll(), $this->hierarchy->getThreshold());
- self::assertEquals(1, count($this->hierarchy->getCurrentLoggers()));
-
- foreach($this->hierarchy->getCurrentLoggers() as $logger) {
- self::assertNull($logger->getLevel());
- self::assertTrue($logger->getAdditivity());
- self::assertEquals(0, count($logger->getAllAppenders()), 0);
- }
- }
-
- public function testSettingParents() {
- $hierarchy = $this->hierarchy;
- $loggerDE = $hierarchy->getLogger("de");
- $root = $loggerDE->getParent();
- self::assertEquals('root', $root->getName());
-
- $loggerDEBLUB = $hierarchy->getLogger("de.blub");
- self::assertEquals('de.blub', $loggerDEBLUB->getName());
- $p = $loggerDEBLUB->getParent();
- self::assertEquals('de', $p->getName());
-
- $loggerDEBLA = $hierarchy->getLogger("de.bla");
- $p = $loggerDEBLA->getParent();
- self::assertEquals('de', $p->getName());
-
- $logger3 = $hierarchy->getLogger("de.bla.third");
- $p = $logger3->getParent();
- self::assertEquals('de.bla', $p->getName());
-
- $p = $p->getParent();
- self::assertEquals('de', $p->getName());
- }
-
- public function testExists() {
- $hierarchy = $this->hierarchy;
- $logger = $hierarchy->getLogger("de");
-
- self::assertTrue($hierarchy->exists("de"));
-
- $logger = $hierarchy->getLogger("de.blub");
- self::assertTrue($hierarchy->exists("de.blub"));
- self::assertTrue($hierarchy->exists("de"));
-
- $logger = $hierarchy->getLogger("de.de");
- self::assertTrue($hierarchy->exists("de.de"));
- }
-
- public function testClear() {
- $hierarchy = $this->hierarchy;
- $logger = $hierarchy->getLogger("de");
- self::assertTrue($hierarchy->exists("de"));
- $hierarchy->clear();
- self::assertFalse($hierarchy->exists("de"));
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerLevelTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerLevelTest.php b/src/test/php/LoggerLevelTest.php
deleted file mode 100644
index 283c9c5..0000000
--- a/src/test/php/LoggerLevelTest.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerLevelTest extends PHPUnit_Framework_TestCase {
-
- protected function doTestLevel($level, $code, $str, $syslog) {
- self::assertTrue($level instanceof LoggerLevel);
- self::assertEquals($level->toInt(), $code);
- self::assertEquals($level->toString(), $str);
- self::assertEquals($level->getSyslogEquivalent(), $syslog);
- }
-
- public function testLevelOff() {
- $this->doTestLevel(LoggerLevel::getLevelOff(), LoggerLevel::OFF, 'OFF', LOG_ALERT);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::OFF), LoggerLevel::OFF, 'OFF', LOG_ALERT);
- $this->doTestLevel(LoggerLevel::toLevel('OFF'), LoggerLevel::OFF, 'OFF', LOG_ALERT);
- }
-
- public function testLevelFatal() {
- $this->doTestLevel(LoggerLevel::getLevelFatal(), LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::FATAL), LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
- $this->doTestLevel(LoggerLevel::toLevel('FATAL'), LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
- }
-
- public function testLevelError() {
- $this->doTestLevel(LoggerLevel::getLevelError(), LoggerLevel::ERROR, 'ERROR', LOG_ERR);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::ERROR), LoggerLevel::ERROR, 'ERROR', LOG_ERR);
- $this->doTestLevel(LoggerLevel::toLevel('ERROR'), LoggerLevel::ERROR, 'ERROR', LOG_ERR);
- }
-
- public function testLevelWarn() {
- $this->doTestLevel(LoggerLevel::getLevelWarn(), LoggerLevel::WARN, 'WARN', LOG_WARNING);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::WARN), LoggerLevel::WARN, 'WARN', LOG_WARNING);
- $this->doTestLevel(LoggerLevel::toLevel('WARN'), LoggerLevel::WARN, 'WARN', LOG_WARNING);
- }
-
- public function testLevelInfo() {
- $this->doTestLevel(LoggerLevel::getLevelInfo(), LoggerLevel::INFO, 'INFO', LOG_INFO);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::INFO), LoggerLevel::INFO, 'INFO', LOG_INFO);
- $this->doTestLevel(LoggerLevel::toLevel('INFO'), LoggerLevel::INFO, 'INFO', LOG_INFO);
- }
-
- public function testLevelDebug() {
- $this->doTestLevel(LoggerLevel::getLevelDebug(), LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::DEBUG), LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
- $this->doTestLevel(LoggerLevel::toLevel('DEBUG'), LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
- }
-
- public function testLevelTrace() {
- $this->doTestLevel(LoggerLevel::getLevelTrace(), LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::TRACE), LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
- $this->doTestLevel(LoggerLevel::toLevel('TRACE'), LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
- }
-
- public function testLevelAll() {
- $this->doTestLevel(LoggerLevel::getLevelAll(), LoggerLevel::ALL, 'ALL', LOG_DEBUG);
- $this->doTestLevel(LoggerLevel::toLevel(LoggerLevel::ALL), LoggerLevel::ALL, 'ALL', LOG_DEBUG);
- $this->doTestLevel(LoggerLevel::toLevel('ALL'), LoggerLevel::ALL, 'ALL', LOG_DEBUG);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerLoggingEventTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerLoggingEventTest.php b/src/test/php/LoggerLoggingEventTest.php
deleted file mode 100644
index 3f1ea3e..0000000
--- a/src/test/php/LoggerLoggingEventTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-class LoggerLoggingEventTestCaseAppender extends LoggerAppenderNull {
-
- protected $requiresLayout = true;
-
- public function append(LoggerLoggingEvent $event) {
- $this->layout->format($event);
- }
-
-}
-
-class LoggerLoggingEventTestCaseLayout extends LoggerLayout {
-
- public function activateOptions() {
- return;
- }
-
- public function format(LoggerLoggingEvent $event) {
- LoggerLoggingEventTest::$locationInfo = $event->getLocationInformation();
- LoggerLoggingEventTest::$throwableInfo = $event->getThrowableInformation();
- }
-}
-
-/**
- * @group main
- */
-class LoggerLoggingEventTest extends PHPUnit_Framework_TestCase {
-
- public static $locationInfo;
- public static $throwableInfo;
-
- public function testConstructWithLoggerName() {
- $l = LoggerLevel :: getLevelDebug();
- $e = new LoggerLoggingEvent('fqcn', 'TestLogger', $l, 'test');
- self::assertEquals($e->getLoggerName(), 'TestLogger');
- }
-
- public function testConstructWithTimestamp() {
- $l = LoggerLevel :: getLevelDebug();
- $timestamp = microtime(true);
- $e = new LoggerLoggingEvent('fqcn', 'TestLogger', $l, 'test', $timestamp);
- self::assertEquals($e->getTimeStamp(), $timestamp);
- }
-
- public function testGetStartTime() {
- $time = LoggerLoggingEvent :: getStartTime();
- self::assertInternalType('float', $time);
- $time2 = LoggerLoggingEvent :: getStartTime();
- self::assertEquals($time, $time2);
- }
-
- public function testGetLocationInformation() {
- $hierarchy = Logger::getHierarchy();
- $root = $hierarchy->getRootLogger();
-
- $a = new LoggerLoggingEventTestCaseAppender('A1');
- $a->setLayout( new LoggerLoggingEventTestCaseLayout() );
- $root->addAppender($a);
-
- $logger = $hierarchy->getLogger('test');
-
- $line = __LINE__; $logger->debug('test');
- $hierarchy->shutdown();
-
- $li = self::$locationInfo;
-
- self::assertEquals($li->getClassName(), get_class($this));
- self::assertEquals($li->getFileName(), __FILE__);
- self::assertEquals($li->getLineNumber(), $line);
- self::assertEquals($li->getMethodName(), __FUNCTION__);
-
- }
-
- public function testGetThrowableInformation1() {
- $hierarchy = Logger::getHierarchy();
- $root = $hierarchy->getRootLogger();
-
- $a = new LoggerLoggingEventTestCaseAppender('A1');
- $a->setLayout( new LoggerLoggingEventTestCaseLayout() );
- $root->addAppender($a);
-
- $logger = $hierarchy->getLogger('test');
- $logger->debug('test');
- $hierarchy->shutdown();
-
- $ti = self::$throwableInfo;
-
- self::assertEquals($ti, null);
- }
-
- public function testGetThrowableInformation2() {
- $hierarchy = Logger::getHierarchy();
- $root = $hierarchy->getRootLogger();
-
- $a = new LoggerLoggingEventTestCaseAppender('A1');
- $a->setLayout( new LoggerLoggingEventTestCaseLayout() );
- $root->addAppender($a);
-
- $ex = new Exception('Message1');
- $logger = $hierarchy->getLogger('test');
- $logger->debug('test', $ex);
- $hierarchy->shutdown();
-
- $ti = self::$throwableInfo;
-
- self::assertTrue($ti instanceof LoggerThrowableInformation);
-
- $result = $ti->getStringRepresentation();
- self::assertInternalType('array', $result);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerMDCTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerMDCTest.php b/src/test/php/LoggerMDCTest.php
deleted file mode 100644
index 20db81a..0000000
--- a/src/test/php/LoggerMDCTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerMDCTest extends PHPUnit_Framework_TestCase {
-
- /** A pattern with 1 key. */
- private $pattern1 = "%-5p %c: %X{key1} %m";
-
- /** A pattern with 2 keys. */
- private $pattern2 = "%-5p %c: %X{key1} %X{key2} %m";
-
- /** A pattern with 3 keys (one is numeric). */
- private $pattern3 = "%-5p %c: %X{key1} %X{key2} %X{3} %m";
-
- /** A pattern with a non-existant key. */
- private $pattern4 = "%-5p %c: %X{key_does_not_exist} %m";
-
- /** A pattern without a key. */
- private $pattern5 = "%-5p %c: %X %m";
-
- protected function setUp() {
- LoggerMDC::clear();
- }
-
- protected function tearDown() {
- LoggerMDC::clear();
- }
-
- public function testPatterns() {
-
- // Create some data to test with
- LoggerMDC::put('key1', 'valueofkey1');
- LoggerMDC::put('key2', 'valueofkey2');
- LoggerMDC::put(3, 'valueofkey3');
-
- $expected = array(
- 'key1' => 'valueofkey1',
- 'key2' => 'valueofkey2',
- 3 => 'valueofkey3',
- );
- $actual = LoggerMDC::getMap();
-
- self::assertSame($expected, $actual);
-
- $event = LoggerTestHelper::getInfoEvent("Test message");
-
- // Pattern with 1 key
- $actual = $this->formatEvent($event, $this->pattern1);
- $expected = "INFO test: valueofkey1 Test message";
- self::assertEquals($expected, $actual);
-
- // Pattern with 2 keys
- $actual = $this->formatEvent($event, $this->pattern2);
- $expected = "INFO test: valueofkey1 valueofkey2 Test message";
- self::assertEquals($expected, $actual);
-
- // Pattern with 3 keys (one numeric)
- $actual = $this->formatEvent($event, $this->pattern3);
- $expected = "INFO test: valueofkey1 valueofkey2 valueofkey3 Test message";
- self::assertEquals($expected, $actual);
-
- // Pattern with non-existant key
- $actual = $this->formatEvent($event, $this->pattern4);
- $expected = "INFO test: Test message";
- self::assertEquals($expected, $actual);
-
- // Pattern with an empty key
- $actual = $this->formatEvent($event, $this->pattern5);
- $expected = "INFO test: key1=valueofkey1, key2=valueofkey2, 3=valueofkey3 Test message";
- self::assertEquals($expected, $actual);
-
- // Test key removal
- LoggerMDC::remove('key1');
- $value = LoggerMDC::get('key1');
- self::assertEquals('', $value);
-
- // Pattern with 1 key, now removed
- $actual = $this->formatEvent($event, $this->pattern1);
- $expected = "INFO test: Test message";
- self::assertEquals($expected, $actual);
- }
-
- private function formatEvent($event, $pattern) {
- $layout = new LoggerLayoutPattern();
- $layout->setConversionPattern($pattern);
- $layout->activateOptions();
- return $layout->format($event);
- }
-}
-
-?>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerNDCTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerNDCTest.php b/src/test/php/LoggerNDCTest.php
deleted file mode 100644
index 380f3ae..0000000
--- a/src/test/php/LoggerNDCTest.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerNDCTest extends PHPUnit_Framework_TestCase {
-
- public function testItemHandling()
- {
- // Test the empty stack
- self::assertSame('', LoggerNDC::get());
- self::assertSame('', LoggerNDC::peek());
- self::assertSame(0, LoggerNDC::getDepth());
- self::assertSame('', LoggerNDC::pop());
-
- // Add some data to the stack
- LoggerNDC::push('1');
- LoggerNDC::push('2');
- LoggerNDC::push('3');
-
- self::assertSame('1 2 3', LoggerNDC::get());
- self::assertSame('3', LoggerNDC::peek());
- self::assertSame(3, LoggerNDC::getDepth());
-
- // Remove last item
- self::assertSame('3', LoggerNDC::pop());
- self::assertSame('1 2', LoggerNDC::get());
- self::assertSame('2', LoggerNDC::peek());
- self::assertSame(2, LoggerNDC::getDepth());
-
- // Remove all items
- LoggerNDC::remove();
-
- // Test the empty stack
- self::assertSame('', LoggerNDC::get());
- self::assertSame('', LoggerNDC::peek());
- self::assertSame(0, LoggerNDC::getDepth());
- self::assertSame('', LoggerNDC::pop());
- }
-
- public function testMaxDepth()
- {
- // Clear stack; add some testing data
- LoggerNDC::clear();
- LoggerNDC::push('1');
- LoggerNDC::push('2');
- LoggerNDC::push('3');
- LoggerNDC::push('4');
- LoggerNDC::push('5');
- LoggerNDC::push('6');
-
- self::assertSame('1 2 3 4 5 6', LoggerNDC::get());
-
- // Edge case, should not change stack
- LoggerNDC::setMaxDepth(6);
- self::assertSame('1 2 3 4 5 6', LoggerNDC::get());
- self::assertSame(6, LoggerNDC::getDepth());
-
- LoggerNDC::setMaxDepth(3);
- self::assertSame('1 2 3', LoggerNDC::get());
- self::assertSame(3, LoggerNDC::getDepth());
-
- LoggerNDC::setMaxDepth(0);
- self::assertSame('', LoggerNDC::get());
- self::assertSame(0, LoggerNDC::getDepth());
- }
-}
-
-?>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerReflectionUtilsTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerReflectionUtilsTest.php b/src/test/php/LoggerReflectionUtilsTest.php
deleted file mode 100644
index 5fe9cba..0000000
--- a/src/test/php/LoggerReflectionUtilsTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-
-class Simple {
- private $name;
- private $male;
-
- public function getName() {
- return $this->name;
- }
-
- public function isMale() {
- return $this->male;
- }
-
- public function setName($name) {
- $this->name = $name;
- }
-
- public function setMale($male) {
- $this->male = $male;
- }
-}
-
-/**
- * @group main
- */
-class LoggerReflectionUtilsTest extends PHPUnit_Framework_TestCase {
-
- public function testSimpleSet() {
- $s = new Simple();
- $ps = new LoggerReflectionUtils($s);
- $ps->setProperty("name", "Joe");
- $ps->setProperty("male", true);
-
- $this->assertEquals($s->isMale(), true);
- $this->assertEquals($s->getName(), 'Joe');
- }
-
- public function testSimpleArraySet() {
- $arr['xxxname'] = 'Joe';
- $arr['xxxmale'] = true;
-
- $s = new Simple();
- $ps = new LoggerReflectionUtils($s);
- $ps->setProperties($arr, "xxx");
-
- $this->assertEquals($s->getName(), 'Joe');
- $this->assertEquals($s->isMale(), true);
- }
-
- public function testStaticArraySet() {
- $arr['xxxname'] = 'Joe';
- $arr['xxxmale'] = true;
-
- $s = new Simple();
- LoggerReflectionUtils::setPropertiesByObject($s,$arr,"xxx");
-
- $this->assertEquals($s->getName(), 'Joe');
- $this->assertEquals($s->isMale(), true);
- }
- public function testCreateObject() {
- $object = LoggerReflectionUtils::createObject('LoggerLayoutSimple');
- $name = get_class($object);
- self::assertEquals($name, 'LoggerLayoutSimple');
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerRootTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerRootTest.php b/src/test/php/LoggerRootTest.php
deleted file mode 100644
index 056a50d..0000000
--- a/src/test/php/LoggerRootTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerRootTest extends PHPUnit_Framework_TestCase {
-
- public function testInitialSetup() {
- $root = new LoggerRoot();
- self::assertSame(LoggerLevel::getLevelAll(), $root->getLevel());
- self::assertSame(LoggerLevel::getLevelAll(), $root->getEffectiveLevel());
- self::assertSame('root', $root->getName());
- self::assertNull($root->getParent());
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: LoggerRoot cannot have a parent.
- */
- public function testSetParentWarning() {
- $root = new LoggerRoot();
- $logger = new Logger('test');
- $root->setParent($logger);
- }
-
- public function testSetParentResult() {
- $root = new LoggerRoot();
- $logger = new Logger('test');
- @$root->setParent($logger);
- self::assertNull($root->getParent());
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage log4php: Cannot set LoggerRoot level to null.
- */
- public function testNullLevelWarning() {
- $root = new LoggerRoot();
- $root->setLevel(null);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerTest.php b/src/test/php/LoggerTest.php
deleted file mode 100644
index 145ac20..0000000
--- a/src/test/php/LoggerTest.php
+++ /dev/null
@@ -1,223 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerTest extends PHPUnit_Framework_TestCase {
-
- private $testConfig1 = array (
- 'rootLogger' => array (
- 'level' => 'ERROR',
- 'appenders' => array (
- 'default',
- ),
- ),
- 'appenders' => array (
- 'default' => array (
- 'class' => 'LoggerAppenderEcho',
- ),
- ),
- 'loggers' => array (
- 'mylogger' => array (
- 'additivity' => 'false',
- 'level' => 'DEBUG',
- 'appenders' => array (
- 'default',
- ),
- ),
- ),
- );
-
- // For testing additivity
- private $testConfig2 = array (
- 'appenders' => array (
- 'default' => array (
- 'class' => 'LoggerAppenderEcho',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'loggers' => array (
- 'foo' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar.baz' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- ),
- );
-
- // For testing additivity
- private $testConfig3 = array (
- 'appenders' => array (
- 'default' => array (
- 'class' => 'LoggerAppenderEcho',
- ),
- ),
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'loggers' => array (
- 'foo' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar' => array (
- 'appenders' => array (
- 'default',
- ),
- ),
- 'foo.bar.baz' => array (
- 'level' => 'ERROR',
- 'appenders' => array (
- 'default',
- ),
- ),
- ),
- );
-
- protected function setUp() {
- Logger::clear();
- Logger::resetConfiguration();
- }
-
- protected function tearDown() {
- Logger::clear();
- Logger::resetConfiguration();
- }
-
- public function testLoggerExist() {
- $l = Logger::getLogger('test');
- self::assertEquals($l->getName(), 'test');
- self::assertTrue(Logger::exists('test'));
- }
-
- public function testCanGetRootLogger() {
- $l = Logger::getRootLogger();
- self::assertEquals($l->getName(), 'root');
- }
-
- public function testCanGetASpecificLogger() {
- $l = Logger::getLogger('test');
- self::assertEquals($l->getName(), 'test');
- }
-
- public function testCanLogToAllLevels() {
- Logger::configure($this->testConfig1);
-
- $logger = Logger::getLogger('mylogger');
- ob_start();
- $logger->info('this is an info');
- $logger->warn('this is a warning');
- $logger->error('this is an error');
- $logger->debug('this is a debug message');
- $logger->fatal('this is a fatal message');
- $v = ob_get_contents();
- ob_end_clean();
-
- $e = 'INFO - this is an info'.PHP_EOL;
- $e .= 'WARN - this is a warning'.PHP_EOL;
- $e .= 'ERROR - this is an error'.PHP_EOL;
- $e .= 'DEBUG - this is a debug message'.PHP_EOL;
- $e .= 'FATAL - this is a fatal message'.PHP_EOL;
-
- self::assertEquals($v, $e);
- }
-
- public function testIsEnabledFor() {
- Logger::configure($this->testConfig1);
-
- $logger = Logger::getLogger('mylogger');
-
- self::assertFalse($logger->isTraceEnabled());
- self::assertTrue($logger->isDebugEnabled());
- self::assertTrue($logger->isInfoEnabled());
- self::assertTrue($logger->isWarnEnabled());
- self::assertTrue($logger->isErrorEnabled());
- self::assertTrue($logger->isFatalEnabled());
-
- $logger = Logger::getRootLogger();
-
- self::assertFalse($logger->isTraceEnabled());
- self::assertFalse($logger->isDebugEnabled());
- self::assertFalse($logger->isInfoEnabled());
- self::assertFalse($logger->isWarnEnabled());
- self::assertTrue($logger->isErrorEnabled());
- self::assertTrue($logger->isFatalEnabled());
- }
-
- public function testGetCurrentLoggers() {
- Logger::clear();
- Logger::resetConfiguration();
-
- self::assertEquals(0, count(Logger::getCurrentLoggers()));
-
- Logger::configure($this->testConfig1);
- self::assertEquals(1, count(Logger::getCurrentLoggers()));
- $list = Logger::getCurrentLoggers();
- self::assertEquals('mylogger', $list[0]->getName());
- }
-
- public function testAdditivity() {
- Logger::configure($this->testConfig2);
-
- $logger = Logger::getLogger('foo.bar.baz');
- ob_start();
- $logger->info('test');
- $actual = ob_get_contents();
- ob_end_clean();
-
- // The message should get logged 4 times: once by every logger in the
- // hierarchy (including root)
- $expected = str_repeat('INFO - test' . PHP_EOL, 4);
- self::assertSame($expected, $actual);
- }
-
- public function testAdditivity2() {
- Logger::configure($this->testConfig3);
-
- $logger = Logger::getLogger('foo.bar.baz');
- ob_start();
- $logger->info('test');
- $actual = ob_get_contents();
- ob_end_clean();
-
- // The message should get logged 3 times: once by every logger in the
- // hierarchy, except foo.bar.baz which is set to level ERROR
- $expected = str_repeat('INFO - test' . PHP_EOL, 3);
- self::assertSame($expected, $actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerTestHelper.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerTestHelper.php b/src/test/php/LoggerTestHelper.php
deleted file mode 100644
index c4ea0ff..0000000
--- a/src/test/php/LoggerTestHelper.php
+++ /dev/null
@@ -1,156 +0,0 @@
-<?php
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/** A set of helper functions for running tests. */
-class LoggerTestHelper {
-
- /**
- * Returns a test logging event with level set to TRACE.
- * @return LoggerLoggingEvent
- */
- public static function getTraceEvent($message = 'test', $logger = "test") {
- return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelTrace(), $message);
- }
-
- /**
- * Returns a test logging event with level set to DEBUG.
- * @return LoggerLoggingEvent
- */
- public static function getDebugEvent($message = 'test', $logger = "test") {
- return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelDebug(), $message);
- }
-
- /**
- * Returns a test logging event with level set to INFO.
- * @return LoggerLoggingEvent
- */
- public static function getInfoEvent($message = 'test', $logger = "test") {
- return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelInfo(), $message);
- }
-
- /**
- * Returns a test logging event with level set to WARN.
- * @return LoggerLoggingEvent
- */
- public static function getWarnEvent($message = 'test', $logger = "test") {
- return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelWarn(), $message);
- }
-
- /**
- * Returns a test logging event with level set to ERROR.
- * @return LoggerLoggingEvent
- */
- public static function getErrorEvent($message = 'test', $logger = "test") {
- return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelError(), $message);
- }
-
- /**
- * Returns a test logging event with level set to FATAL.
- * @return LoggerLoggingEvent
- */
- public static function getFatalEvent($message = 'test', $logger = "test") {
- return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelFatal(), $message);
- }
-
- /**
- * Returns an array of logging events, one for each level, sorted ascending
- * by severitiy.
- */
- public static function getAllEvents($message = 'test') {
- return array(
- self::getTraceEvent($message),
- self::getDebugEvent($message),
- self::getInfoEvent($message),
- self::getWarnEvent($message),
- self::getErrorEvent($message),
- self::getFatalEvent($message),
- );
- }
-
- /** Returns an array of all existing levels, sorted ascending by severity. */
- public static function getAllLevels() {
- return array(
- LoggerLevel::getLevelTrace(),
- LoggerLevel::getLevelDebug(),
- LoggerLevel::getLevelInfo(),
- LoggerLevel::getLevelWarn(),
- LoggerLevel::getLevelError(),
- LoggerLevel::getLevelFatal(),
- );
- }
-
- /** Returns a string representation of a filter decision. */
- public static function decisionToString($decision) {
- switch($decision) {
- case LoggerFilter::ACCEPT: return 'ACCEPT';
- case LoggerFilter::NEUTRAL: return 'NEUTRAL';
- case LoggerFilter::DENY: return 'DENY';
- }
- }
-
- /** Returns a simple configuration with one echo appender tied to root logger. */
- public static function getEchoConfig() {
- return array(
- 'threshold' => 'ALL',
- 'rootLogger' => array(
- 'level' => 'trace',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple',
- ),
- ),
- ),
- );
- }
-
- /** Returns a simple configuration with one echo appender using the pattern layout. */
- public static function getEchoPatternConfig($pattern) {
- return array(
- 'threshold' => 'ALL',
- 'rootLogger' => array(
- 'level' => 'trace',
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'params' => array(
- 'conversionPattern' => $pattern
- )
- ),
- ),
- ),
- );
- }
-}
-
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/LoggerThrowableInformationTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/LoggerThrowableInformationTest.php b/src/test/php/LoggerThrowableInformationTest.php
deleted file mode 100644
index bc0a296..0000000
--- a/src/test/php/LoggerThrowableInformationTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group main
- */
-class LoggerThrowableInformationTest extends PHPUnit_Framework_TestCase {
-
- public function testConstructor() {
- $ex = new Exception();
- $tInfo = new LoggerThrowableInformation($ex);
-
- $result = $tInfo->getStringRepresentation();
- $this->assertInternalType('array', $result);
- }
-
- public function testExceptionChain() {
- $ex1 = new LoggerThrowableInformationTestException('Message1');
- $ex2 = new LoggerThrowableInformationTestException('Message2', 0, $ex1);
- $ex3 = new LoggerThrowableInformationTestException('Message3', 0, $ex2);
-
- $tInfo = new LoggerThrowableInformation($ex3);
- $result = $tInfo->getStringRepresentation();
- $this->assertInternalType('array', $result);
- }
-
- public function testGetThrowable() {
- $ex = new LoggerThrowableInformationTestException('Message1');
- $tInfo = new LoggerThrowableInformation($ex);
- $result = $tInfo->getThrowable();
- $this->assertEquals($ex, $result);
- }
-}
-
-
-if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
- class LoggerThrowableInformationTestException extends Exception { }
-} else {
- class LoggerThrowableInformationTestException extends Exception {
-
- protected $previous;
-
- public function __construct($message = '', $code = 0, Exception $previous = null) {
- parent::__construct($message, $code);
- $this->previous = $previous;
- }
-
- public function getPrevious() {
- return $this->previous;
- }
- }
-}
-?>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/README
----------------------------------------------------------------------
diff --git a/src/test/php/README b/src/test/php/README
deleted file mode 100644
index 693e23e..0000000
--- a/src/test/php/README
+++ /dev/null
@@ -1,19 +0,0 @@
-All tests can be run from the root of the package by running:
-$ phpunit
-
-Tests classes are divided into groups which can be run individually:
-$ phpunit --group main
-$ phpunit --group appenders
-$ phpunit --group configurators
-$ phpunit --group filters
-$ phpunit --group helpers
-$ phpunit --group layouts
-$ phpunit --group renderers
-
-Individual test classes can be run using e.g.:
-$ phpunit src/test/php/appenders/LoggerAppenderSocketTest.php
-
-Do not use relative file paths in the tests. Absoulte paths may be constructed
-using snippets like:
-* dirname(__FILE__) . '/../path/to/file'
-* PHPUNIT_TEMP_DIR . '/../path/to/file'
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderConsoleTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderConsoleTest.php b/src/test/php/appenders/LoggerAppenderConsoleTest.php
deleted file mode 100644
index 24b72e0..0000000
--- a/src/test/php/appenders/LoggerAppenderConsoleTest.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderConsoleTest extends PHPUnit_Framework_TestCase {
-
- private $config = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderConsole',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'params' => array(
- // Intentionally blank so output doesn't clutter phpunit output
- 'conversionPattern' => ''
- )
- ),
- )
- )
- );
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderConsole();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testAppendDefault() {
- Logger::configure($this->config);
- $log = Logger::getRootLogger();
-
- $expected = LoggerAppenderConsole::STDOUT;
- $actual = $log->getAppender('default')->getTarget();
- $this->assertSame($expected, $actual);
-
- $log->info("hello");
- }
-
- public function testAppendStdout() {
- $this->config['appenders']['default']['params']['target'] = 'stdout';
-
- Logger::configure($this->config);
- $log = Logger::getRootLogger();
-
- $expected = LoggerAppenderConsole::STDOUT;
- $actual = $log->getAppender('default')->getTarget();
- $this->assertSame($expected, $actual);
-
- $log->info("hello");
- }
-
- public function testAppendStderr() {
- $this->config['appenders']['default']['params']['target'] = 'stderr';
- Logger::configure($this->config);
- $log = Logger::getRootLogger();
- $expected = LoggerAppenderConsole::STDERR;
-
- $actual = $log->getAppender('default')->getTarget();
- $this->assertSame($expected, $actual);
-
- $log->info("hello");
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderDailyFileTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderDailyFileTest.php b/src/test/php/appenders/LoggerAppenderDailyFileTest.php
deleted file mode 100644
index 332ebf2..0000000
--- a/src/test/php/appenders/LoggerAppenderDailyFileTest.php
+++ /dev/null
@@ -1,190 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderDailyFileTest extends PHPUnit_Framework_TestCase {
-
- protected function setUp() {
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Ymd'));
- @unlink(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date('Y'));
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderDailyFile();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testDefaultLayout() {
- $appender = new LoggerAppenderDailyFile();
- $actual = $appender->getLayout();
- self::assertInstanceOf('LoggerLayoutSimple', $actual);
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'file' not set.
- */
- public function testRequiredParamWarning1() {
- $appender = new LoggerAppenderDailyFile();
- $appender->activateOptions();
- }
-
- /**
- * @expectedException PHPUnit_Framework_Error
- * @expectedExceptionMessage Required parameter 'datePattern' not set.
- */
- public function testRequiredParamWarning2() {
- $appender = new LoggerAppenderDailyFile();
- $appender->setFile('file.log');
- $appender->setDatePattern('');
- $appender->activateOptions();
- }
-
- public function testGetDatePattern() {
- $appender = new LoggerAppenderDailyFile();
-
- // Default pattern
- $actual = $appender->getDatePattern();
- self::assertEquals('Ymd', $actual);
-
- // Custom pattern
- $appender->setDatePattern('xyz');
- $actual = $appender->getDatePattern();
- self::assertEquals('xyz', $actual);
- }
-
- /**
- * For greater code coverage!
- * Override the warning so remaining code is reached.
- */
- public function testRequiredParamWarning3() {
- $appender = new LoggerAppenderDailyFile();
- $appender->setFile('file.log');
- $appender->setDatePattern('');
- @$appender->activateOptions();
- }
-
- public function testLazyFileOpen() {
- $event = LoggerTestHelper::getWarnEvent("my message");
- $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
- $pattern = 'Y-m-d';
-
- $date = date($pattern, $event->getTimeStamp());
- $path = PHPUNIT_TEMP_DIR . "/lazy-file.$date.log";
-
- if (file_exists($path)) {
- unlink($path);
- }
-
- $appender = new LoggerAppenderDailyFile();
- $appender->setFile($file);
- $appender->setDatePattern('Y-m-d');
- $appender->activateOptions();
-
- // File should not exist before first append
- self::assertFileNotExists($path);
- $appender->append($event);
- self::assertFileExists($path);
- }
-
- public function testRollover()
- {
- $message = uniqid();
- $level = LoggerLevel::getLevelDebug();
-
- $file = PHPUNIT_TEMP_DIR . '/lazy-file.%s.log';
- $pattern = 'Y-m-d';
-
- // Get some timestamps for events - different date for each
- $ts1 = mktime(10, 0, 0, 7, 3, 1980);
- $ts2 = mktime(10, 0, 0, 7, 4, 1980);
- $ts3 = mktime(10, 0, 0, 7, 5, 1980);
-
- $e1 = new LoggerLoggingEvent(__CLASS__, 'test', $level, $message, $ts1);
- $e2 = new LoggerLoggingEvent(__CLASS__, 'test', $level, $message, $ts2);
- $e3 = new LoggerLoggingEvent(__CLASS__, 'test', $level, $message, $ts3);
-
- // Expected paths
- $path1 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-03.log';
- $path2 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-04.log';
- $path3 = PHPUNIT_TEMP_DIR . '/lazy-file.1980-07-05.log';
-
- @unlink($path1);
- @unlink($path2);
- @unlink($path3);
-
- $appender = new LoggerAppenderDailyFile();
- $appender->setFile($file);
- $appender->setDatePattern('Y-m-d');
- $appender->activateOptions();
-
- $appender->append($e1);
- $appender->append($e2);
- $appender->append($e3);
-
- $actual1 = file_get_contents($path1);
- $actual2 = file_get_contents($path2);
- $actual3 = file_get_contents($path3);
-
- $expected1 = "DEBUG - $message" . PHP_EOL;
- $expected2 = "DEBUG - $message" . PHP_EOL;
- $expected3 = "DEBUG - $message" . PHP_EOL;
-
- self::assertSame($expected1, $actual1);
- self::assertSame($expected2, $actual2);
- self::assertSame($expected3, $actual3);
- }
-
- public function testSimpleLogging() {
- $event = LoggerTestHelper::getWarnEvent("my message");
-
- $appender = new LoggerAppenderDailyFile();
- $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Ymd"));
- $expected = "WARN - my message".PHP_EOL;
- self::assertEquals($expected, $actual);
- }
-
- public function testChangedDateFormat() {
- $event = LoggerTestHelper::getWarnEvent("my message");
-
- $appender = new LoggerAppenderDailyFile();
- $appender->setDatePattern('Y');
- $appender->setFile(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.%s');
- $appender->activateOptions();
- $appender->append($event);
- $appender->close();
-
- $actual = file_get_contents(PHPUNIT_TEMP_DIR . '/TEST-daily.txt.' . date("Y"));
- $expected = "WARN - my message".PHP_EOL;
- self::assertEquals($expected, $actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderEchoTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderEchoTest.php b/src/test/php/appenders/LoggerAppenderEchoTest.php
deleted file mode 100644
index b70e282..0000000
--- a/src/test/php/appenders/LoggerAppenderEchoTest.php
+++ /dev/null
@@ -1,165 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderEchoTest extends PHPUnit_Framework_TestCase {
-
- private $config1 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- )
- )
- );
-
- private $config2 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'params' => array(
- 'htmlLineBreaks' => true
- )
- )
- )
- );
-
- private $config3 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'params' => array(
- 'htmlLineBreaks' => 'foo'
- )
- )
- )
- );
-
- public function testAppend() {
- Logger::configure($this->config1);
- $log = Logger::getRootLogger();
-
- $hlb = $log->getAppender('default')->getHtmlLineBreaks();
- $this->assertSame(false, $hlb);
-
- ob_start();
- $log->info("This is a test");
- $log->debug("And this too");
- $actual = ob_get_clean();
- $expected = "INFO - This is a test" . PHP_EOL . "DEBUG - And this too". PHP_EOL;
-
- $this->assertSame($expected, $actual);
- }
-
- public function testHtmlLineBreaks() {
- Logger::configure($this->config2);
- $log = Logger::getRootLogger();
-
- $hlb = $log->getAppender('default')->getHtmlLineBreaks();
- $this->assertSame(true, $hlb);
-
- ob_start();
- $log->info("This is a test" . PHP_EOL . "With more than one line");
- $log->debug("And this too");
- $actual = ob_get_clean();
- $expected = "INFO - This is a test<br />" . PHP_EOL . "With more than one line<br />" . PHP_EOL . "DEBUG - And this too<br />" . PHP_EOL;
-
- $this->assertSame($expected, $actual);
- }
-
-// public function testHtmlLineBreaksInvalidOption() {
-// Logger::configure($this->config3);
-// }
-
-
- public function testEcho() {
- $appender = new LoggerAppenderEcho("myname ");
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
- $appender->activateOptions();
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $expected = "ERROR - testmessage" . PHP_EOL;
- ob_start();
- $appender->append($event);
- $actual = ob_get_clean();
-
- self::assertEquals($expected, $actual);
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderEcho();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testEchoHtml() {
- $appender = new LoggerAppenderEcho("myname ");
- $appender->setHtmlLineBreaks(true);
-
- $layout = new LoggerLayoutSimple();
- $appender->setLayout($layout);
- $appender->activateOptions();
-
- // Single line message
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
- $expected = "ERROR - testmessage<br />" . PHP_EOL;
- ob_start();
- $appender->append($event);
- $actual = ob_get_clean();
- self::assertEquals($expected, $actual);
-
- // Multi-line message
- $msg = "This message\nis in several lines\r\nto test various line breaks.";
- $expected = "ERROR - This message<br />\nis in several lines<br />\r\nto test various line breaks.<br />" . PHP_EOL;
-
- $event = new LoggerLoggingEvent("LoggerAppenderEchoTest", new Logger("TEST"), LoggerLevel::getLevelError(), $msg);
- ob_start();
- $appender->append($event);
- $actual = ob_get_clean();
- self::assertEquals($expected, $actual);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/test/php/appenders/LoggerAppenderFileTest.php
----------------------------------------------------------------------
diff --git a/src/test/php/appenders/LoggerAppenderFileTest.php b/src/test/php/appenders/LoggerAppenderFileTest.php
deleted file mode 100644
index 5ed3eef..0000000
--- a/src/test/php/appenders/LoggerAppenderFileTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category tests
- * @package log4php
- * @subpackage appenders
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @link http://logging.apache.org/log4php
- */
-
-/**
- * @group appenders
- */
-class LoggerAppenderFileTest extends PHPUnit_Framework_TestCase {
-
- private $config1 = array(
- 'rootLogger' => array(
- 'appenders' => array('default'),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderFile',
- 'layout' => array(
- 'class' => 'LoggerLayoutSimple'
- ),
- 'params' => array()
- )
- )
- );
-
- private $testPath;
-
- public function __construct() {
- $this->testPath = PHPUNIT_TEMP_DIR . '/TEST.txt';
- }
-
- public function setUp() {
- Logger::resetConfiguration();
- if(file_exists($this->testPath)) {
- unlink($this->testPath);
- }
- }
-
- public function tearDown() {
- Logger::resetConfiguration();
- if(file_exists($this->testPath)) {
- unlink($this->testPath);
- }
- }
-
- public function testRequiresLayout() {
- $appender = new LoggerAppenderFile();
- self::assertTrue($appender->requiresLayout());
- }
-
- public function testActivationDoesNotCreateTheFile() {
- $path = PHPUNIT_TEMP_DIR . "/doesnotexisthopefully.log";
- @unlink($path);
- $appender = new LoggerAppenderFile();
- $appender->setFile($path);
- $appender->activateOptions();
-
- self::assertFalse(file_exists($path));
-
- $event = LoggerTestHelper::getInfoEvent('bla');
- $appender->append($event);
-
- self::assertTrue(file_exists($path));
- }
-
- public function testSimpleLogging() {
- $config = $this->config1;
- $config['appenders']['default']['params']['file'] = $this->testPath;
-
- Logger::configure($config);
-
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- $expected = "INFO - This is a test" . PHP_EOL;
- $actual = file_get_contents($this->testPath);
- $this->assertSame($expected, $actual);
- }
-
- public function testAppendFlagTrue() {
- $config = $this->config1;
- $config['appenders']['default']['params']['file'] = $this->testPath;
- $config['appenders']['default']['params']['append'] = true;
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- $expected = "INFO - This is a test" . PHP_EOL . "INFO - This is a test" . PHP_EOL;
- $actual = file_get_contents($this->testPath);
- $this->assertSame($expected, $actual);
- }
-
- public function testAppendFlagFalse() {
- $config = $this->config1;
- $config['appenders']['default']['params']['file'] = $this->testPath;
- $config['appenders']['default']['params']['append'] = false;
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- Logger::configure($config);
- $logger = Logger::getRootLogger();
- $logger->info('This is a test');
-
- $expected = "INFO - This is a test" . PHP_EOL;
- $actual = file_get_contents($this->testPath);
- $this->assertSame($expected, $actual);
- }
-}
[22/43] LOG4PHP-121: Reorganized classes into namespaces
Posted by ih...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_null.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_null.properties b/src/examples/resources/appender_null.properties
deleted file mode 100644
index b5f4df8..0000000
--- a/src/examples/resources/appender_null.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderNull
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_pdo.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_pdo.properties b/src/examples/resources/appender_pdo.properties
deleted file mode 100644
index 8d3d778..0000000
--- a/src/examples/resources/appender_pdo.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.rootLogger = DEBUG, a1, a2, a3
-
-; The table is created if necessary and filled using prepared statements.
-log4php.appender.a1 = LoggerAppenderPDO
-log4php.appender.a1.dsn = "sqlite:target/appender_pdo.sqlite"
-
-; The following shows an appender with customized INSERT statment and table name.
-log4php.appender.a2 = LoggerAppenderPDO
-log4php.appender.a2.user = root
-log4php.appender.a2.password = secret
-log4php.appender.a2.dsn = "mysql:host=localhost;dbname=test"
-log4php.appender.a2.table = log2
-log4php.appender.a2.insertSql = "INSERT INTO log2 (timestamp, logger, level, message, thread, file, line) VALUES (?,?,?,?,?,?,?)"
-log4php.appender.a2.insertPattern = "%d,%c,%p,%m, %t,%F,%L"
-
-; DEPRECATED: Using old style LoggerPatternLayout is considered unsafe as %m can contain quotes that mess up the SQL!
-log4php.appender.a3 = LoggerAppenderPDO
-log4php.appender.a3.dsn = "sqlite:target/appender_pdo.sqlite"
-log4php.appender.a3.table = log3
-log4php.appender.a3.sql = "INSERT INTO log3 (timestamp, level, message) VALUES ('%t', '%p', '%m')"
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_php.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_php.properties b/src/examples/resources/appender_php.properties
deleted file mode 100644
index 00d0673..0000000
--- a/src/examples/resources/appender_php.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderPhp
-log4php.appender.default.layout = LoggerLayoutPattern
-log4php.appender.default.layout.conversionPattern = "%d{Y-m-d H:i:s.u} %-5p [%t] %c: %m%n"
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_rollingfile.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_rollingfile.properties b/src/examples/resources/appender_rollingfile.properties
deleted file mode 100644
index 87405c0..0000000
--- a/src/examples/resources/appender_rollingfile.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderRollingFile
-log4php.appender.default.layout = LoggerLayoutTTCC
-log4php.appender.default.file = target/examples/appender_rollingfile.log
-log4php.appender.default.MaxFileSize = 100
-log4php.appender.default.MaxBackupIndex = 3
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_socket.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_socket.properties b/src/examples/resources/appender_socket.properties
deleted file mode 100644
index 66cfce7..0000000
--- a/src/examples/resources/appender_socket.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderSocket
-log4php.appender.default.layout = LoggerLayoutSimple
-log4php.appender.default.remoteHost = localhost
-log4php.appender.default.port = 4242
-log4php.appender.default.useXml = true
-log4php.appender.default.locationInfo = false
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_socket_server.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_socket_server.properties b/src/examples/resources/appender_socket_server.properties
deleted file mode 100644
index 652b923..0000000
--- a/src/examples/resources/appender_socket_server.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.debug = true
-log4php.appender.file = LoggerAppenderFile
-log4php.appender.file.file = server.log
-log4php.appender.file.layout = LoggerLayoutTTCC
-log4php.appender.console = LoggerAppenderEcho
-log4php.appender.console.layout = LoggerLayoutSimple
-log4php.rootLogger = INFO, file, console
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/appender_syslog.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/appender_syslog.properties b/src/examples/resources/appender_syslog.properties
deleted file mode 100644
index 67c2352..0000000
--- a/src/examples/resources/appender_syslog.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderSyslog
-log4php.appender.default.layout = LoggerLayoutSimple
-log4php.appender.default.ident = log4php-test
-log4php.appender.default.facility = USER
-log4php.appender.default.option = "PID|CONS|NDELAY"
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/cache.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/cache.properties b/src/examples/resources/cache.properties
deleted file mode 100644
index ea2948f..0000000
--- a/src/examples/resources/cache.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutSimple
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/configurator_php.php
----------------------------------------------------------------------
diff --git a/src/examples/resources/configurator_php.php b/src/examples/resources/configurator_php.php
deleted file mode 100644
index 893f83a..0000000
--- a/src/examples/resources/configurator_php.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-return array(
- 'threshold' => 'ALL',
- 'rootLogger' => array(
- 'level' => 'INFO',
- 'appenders' => array('default'),
- ),
- 'loggers' => array(
- 'dev' => array(
- 'level' => 'DEBUG',
- 'appenders' => array('default'),
- ),
- ),
- 'appenders' => array(
- 'default' => array(
- 'class' => 'LoggerAppenderEcho',
- 'layout' => array(
- 'class' => 'LoggerLayoutPattern',
- 'conversionPattern' => "%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n",
- ),
- ),
- ),
- );
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/configurator_xml.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/configurator_xml.xml b/src/examples/resources/configurator_xml.xml
deleted file mode 100644
index 1e1c714..0000000
--- a/src/examples/resources/configurator_xml.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC" />
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</log4php:configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/filter_denyall.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/filter_denyall.xml b/src/examples/resources/filter_denyall.xml
deleted file mode 100644
index d1091da..0000000
--- a/src/examples/resources/filter_denyall.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC"/>
- <filter class="LoggerFilterDenyAll"/>
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</log4php:configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/filter_levelmatch.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/filter_levelmatch.xml b/src/examples/resources/filter_levelmatch.xml
deleted file mode 100644
index 0ebfe38..0000000
--- a/src/examples/resources/filter_levelmatch.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC" />
- <filter class="LoggerFilterLevelMatch">
- <param name="LevelToMatch" value="DEBUG" />
- <param name="AcceptOnMatch" value="false" />
- </filter>
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</log4php:configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/filter_levelrange.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/filter_levelrange.xml b/src/examples/resources/filter_levelrange.xml
deleted file mode 100644
index 6509c14..0000000
--- a/src/examples/resources/filter_levelrange.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC" />
- <filter class="LoggerFilterLevelRange">
- <param name="levelMin" value="ERROR" />
- <param name="levelMax" value="FATAL" />
- <param name="acceptOnMatch" value="false" />
- </filter>
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</log4php:configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/filter_stringmatch.xml
----------------------------------------------------------------------
diff --git a/src/examples/resources/filter_stringmatch.xml b/src/examples/resources/filter_stringmatch.xml
deleted file mode 100644
index 02fbbe9..0000000
--- a/src/examples/resources/filter_stringmatch.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
- <appender name="default" class="LoggerAppenderEcho">
- <layout class="LoggerLayoutTTCC" />
- <filter class="LoggerFilterStringMatch">
- <param name="StringToMatch" value="match" />
- <param name="AcceptOnMatch" value="false" />
- </filter>
- </appender>
- <root>
- <level value="DEBUG" />
- <appender_ref ref="default" />
- </root>
-</log4php:configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/layout_html.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/layout_html.properties b/src/examples/resources/layout_html.properties
deleted file mode 100644
index 2055122..0000000
--- a/src/examples/resources/layout_html.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutHtml
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/layout_pattern.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/layout_pattern.properties b/src/examples/resources/layout_pattern.properties
deleted file mode 100644
index e95d95b..0000000
--- a/src/examples/resources/layout_pattern.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutPattern
-log4php.appender.default.layout.ConversionPattern = "%d{ISO8601} [%p] %c: %m (at %F line %L)%n"
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/layout_simple.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/layout_simple.properties b/src/examples/resources/layout_simple.properties
deleted file mode 100644
index ea2948f..0000000
--- a/src/examples/resources/layout_simple.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutSimple
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/layout_ttcc.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/layout_ttcc.properties b/src/examples/resources/layout_ttcc.properties
deleted file mode 100644
index a7ae686..0000000
--- a/src/examples/resources/layout_ttcc.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutTTCC
-log4php.appender.default.layout.MicroSecondsPrinting = false
-log4php.appender.default.layout.categoryPrefixing = true
-log4php.appender.default.layout.dateFormat = "%H:%M"
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/layout_xml.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/layout_xml.properties b/src/examples/resources/layout_xml.properties
deleted file mode 100644
index 0fbd153..0000000
--- a/src/examples/resources/layout_xml.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutXml
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/mdc.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/mdc.properties b/src/examples/resources/mdc.properties
deleted file mode 100644
index fa2baa8..0000000
--- a/src/examples/resources/mdc.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutPattern
-log4php.appender.default.layout.conversionPattern="%d{Y-m-d H:i:s} %-5p %c %X{username}: %m in %F at %L%n"
-log4php.rootLogger = DEBUG, default
-
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/ndc.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/ndc.properties b/src/examples/resources/ndc.properties
deleted file mode 100644
index 4758589..0000000
--- a/src/examples/resources/ndc.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutPattern
-log4php.appender.default.layout.conversionPattern="%d{Y-m-d H:i:s} %-5p %c %x: %m in %F at %L%n"
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/renderer_default.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/renderer_default.properties b/src/examples/resources/renderer_default.properties
deleted file mode 100644
index ea2948f..0000000
--- a/src/examples/resources/renderer_default.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutSimple
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/examples/resources/renderer_map.properties
----------------------------------------------------------------------
diff --git a/src/examples/resources/renderer_map.properties b/src/examples/resources/renderer_map.properties
deleted file mode 100644
index 13a2d8a..0000000
--- a/src/examples/resources/renderer_map.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-;
-; Licensed to the Apache Software Foundation (ASF) under one or more
-; contributor license agreements. See the NOTICE file distributed with
-; this work for additional information regarding copyright ownership.
-; The ASF licenses this file to You under the Apache License, Version 2.0
-; (the "License"); you may not use this file except in compliance with
-; the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-; See the License for the specific language governing permissions and
-; limitations under the License.
-;
-; START SNIPPET: doxia
-log4php.renderer.Person = PersonRenderer
-
-log4php.appender.default = LoggerAppenderEcho
-log4php.appender.default.layout = LoggerLayoutSimple
-log4php.rootLogger = DEBUG, default
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/Logger.php
----------------------------------------------------------------------
diff --git a/src/main/php/Logger.php b/src/main/php/Logger.php
deleted file mode 100644
index 9751f59..0000000
--- a/src/main/php/Logger.php
+++ /dev/null
@@ -1,596 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-require dirname(__FILE__) . '/LoggerAutoloader.php';
-
-/**
- * This is the central class in the log4php package. All logging operations
- * are done through this class.
- *
- * The main logging methods are:
- * <ul>
- * <li>{@link trace()}</li>
- * <li>{@link debug()}</li>
- * <li>{@link info()}</li>
- * <li>{@link warn()}</li>
- * <li>{@link error()}</li>
- * <li>{@link fatal()}</li>
- * </ul>
- *
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version SVN: $Id$
- * @link http://logging.apache.org/log4php
- */
-class Logger {
-
- /**
- * Logger additivity. If set to true then child loggers will inherit
- * the appenders of their ancestors by default.
- * @var boolean
- */
- private $additive = true;
-
- /**
- * The Logger's fully qualified class name.
- * TODO: Determine if this is useful.
- */
- private $fqcn = 'Logger';
-
- /** The assigned Logger level. */
- private $level;
-
- /** The name of this Logger instance. */
- private $name;
-
- /** The parent logger. Set to null if this is the root logger. */
- private $parent;
-
- /** A collection of appenders linked to this logger. */
- private $appenders = array();
-
- /**
- * Constructor.
- * @param string $name Name of the logger.
- */
- public function __construct($name) {
- $this->name = $name;
- }
-
- /**
- * Returns the logger name.
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Returns the parent Logger. Can be null if this is the root logger.
- * @return Logger
- */
- public function getParent() {
- return $this->parent;
- }
-
- // ******************************************
- // *** Logging methods ***
- // ******************************************
-
- /**
- * Log a message object with the TRACE level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function trace($message, $throwable = null) {
- $this->log(LoggerLevel::getLevelTrace(), $message, $throwable);
- }
-
- /**
- * Log a message object with the DEBUG level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function debug($message, $throwable = null) {
- $this->log(LoggerLevel::getLevelDebug(), $message, $throwable);
- }
-
- /**
- * Log a message object with the INFO Level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function info($message, $throwable = null) {
- $this->log(LoggerLevel::getLevelInfo(), $message, $throwable);
- }
-
- /**
- * Log a message with the WARN level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function warn($message, $throwable = null) {
- $this->log(LoggerLevel::getLevelWarn(), $message, $throwable);
- }
-
- /**
- * Log a message object with the ERROR level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function error($message, $throwable = null) {
- $this->log(LoggerLevel::getLevelError(), $message, $throwable);
- }
-
- /**
- * Log a message object with the FATAL level.
- *
- * @param mixed $message message
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function fatal($message, $throwable = null) {
- $this->log(LoggerLevel::getLevelFatal(), $message, $throwable);
- }
-
- /**
- * Log a message using the provided logging level.
- *
- * @param LoggerLevel $level The logging level.
- * @param mixed $message Message to log.
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- */
- public function log(LoggerLevel $level, $message, $throwable = null) {
- if($this->isEnabledFor($level)) {
- $event = new LoggerLoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
- $this->callAppenders($event);
- }
-
- // Forward the event upstream if additivity is turned on
- if(isset($this->parent) && $this->getAdditivity()) {
-
- // Use the event if already created
- if (isset($event)) {
- $this->parent->logEvent($event);
- } else {
- $this->parent->log($level, $message, $throwable);
- }
- }
- }
-
- /**
- * Logs an already prepared logging event object.
- * @param LoggerLoggingEvent $event
- */
- public function logEvent(LoggerLoggingEvent $event) {
- if($this->isEnabledFor($event->getLevel())) {
- $this->callAppenders($event);
- }
-
- // Forward the event upstream if additivity is turned on
- if(isset($this->parent) && $this->getAdditivity()) {
- $this->parent->logEvent($event);
- }
- }
-
- /**
- * If assertion parameter evaluates as false, then logs the message
- * using the ERROR level.
- *
- * @param bool $assertion
- * @param string $msg message to log
- */
- public function assertLog($assertion = true, $msg = '') {
- if($assertion == false) {
- $this->error($msg);
- }
- }
-
- /**
- * This method creates a new logging event and logs the event without
- * further checks.
- *
- * It should not be called directly. Use {@link trace()}, {@link debug()},
- * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
- * wrappers.
- *
- * @param string $fqcn Fully qualified class name of the Logger
- * @param Exception $throwable Optional throwable information to include
- * in the logging event.
- * @param LoggerLevel $level log level
- * @param mixed $message message to log
- */
- public function forcedLog($fqcn, $throwable, LoggerLevel $level, $message) {
- $event = new LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable);
- $this->callAppenders($event);
-
- // Forward the event upstream if additivity is turned on
- if(isset($this->parent) && $this->getAdditivity()) {
- $this->parent->logEvent($event);
- }
- }
-
- /**
- * Forwards the given logging event to all linked appenders.
- * @param LoggerLoggingEvent $event
- */
- public function callAppenders($event) {
- foreach($this->appenders as $appender) {
- $appender->doAppend($event);
- }
- }
-
- // ******************************************
- // *** Checker methods ***
- // ******************************************
-
- /**
- * Check whether this Logger is enabled for a given Level passed as parameter.
- *
- * @param LoggerLevel level
- * @return boolean
- */
- public function isEnabledFor(LoggerLevel $level) {
- return $level->isGreaterOrEqual($this->getEffectiveLevel());
- }
-
- /**
- * Check whether this Logger is enabled for the TRACE Level.
- * @return boolean
- */
- public function isTraceEnabled() {
- return $this->isEnabledFor(LoggerLevel::getLevelTrace());
- }
-
- /**
- * Check whether this Logger is enabled for the DEBUG Level.
- * @return boolean
- */
- public function isDebugEnabled() {
- return $this->isEnabledFor(LoggerLevel::getLevelDebug());
- }
-
- /**
- * Check whether this Logger is enabled for the INFO Level.
- * @return boolean
- */
- public function isInfoEnabled() {
- return $this->isEnabledFor(LoggerLevel::getLevelInfo());
- }
-
- /**
- * Check whether this Logger is enabled for the WARN Level.
- * @return boolean
- */
- public function isWarnEnabled() {
- return $this->isEnabledFor(LoggerLevel::getLevelWarn());
- }
-
- /**
- * Check whether this Logger is enabled for the ERROR Level.
- * @return boolean
- */
- public function isErrorEnabled() {
- return $this->isEnabledFor(LoggerLevel::getLevelError());
- }
-
- /**
- * Check whether this Logger is enabled for the FATAL Level.
- * @return boolean
- */
- public function isFatalEnabled() {
- return $this->isEnabledFor(LoggerLevel::getLevelFatal());
- }
-
- // ******************************************
- // *** Configuration methods ***
- // ******************************************
-
- /**
- * Adds a new appender to the Logger.
- * @param LoggerAppender $appender The appender to add.
- */
- public function addAppender($appender) {
- $appenderName = $appender->getName();
- $this->appenders[$appenderName] = $appender;
- }
-
- /** Removes all appenders from the Logger. */
- public function removeAllAppenders() {
- foreach($this->appenders as $name => $appender) {
- $this->removeAppender($name);
- }
- }
-
- /**
- * Remove the appender passed as parameter form the Logger.
- * @param mixed $appender an appender name or a {@link LoggerAppender} instance.
- */
- public function removeAppender($appender) {
- if($appender instanceof LoggerAppender) {
- $appender->close();
- unset($this->appenders[$appender->getName()]);
- } else if (is_string($appender) and isset($this->appenders[$appender])) {
- $this->appenders[$appender]->close();
- unset($this->appenders[$appender]);
- }
- }
-
- /**
- * Returns the appenders linked to this logger as an array.
- * @return array collection of appender names
- */
- public function getAllAppenders() {
- return $this->appenders;
- }
-
- /**
- * Returns a linked appender by name.
- * @return LoggerAppender
- */
- public function getAppender($name) {
- return $this->appenders[$name];
- }
-
- /**
- * Sets the additivity flag.
- * @param boolean $additive
- */
- public function setAdditivity($additive) {
- $this->additive = (bool)$additive;
- }
-
- /**
- * Returns the additivity flag.
- * @return boolean
- */
- public function getAdditivity() {
- return $this->additive;
- }
-
- /**
- * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
- * @see LoggerLevel
- * @return LoggerLevel or null
- */
- public function getEffectiveLevel() {
- for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
- if($logger->getLevel() !== null) {
- return $logger->getLevel();
- }
- }
- }
-
- /**
- * Get the assigned Logger level.
- * @return LoggerLevel The assigned level or null if none is assigned.
- */
- public function getLevel() {
- return $this->level;
- }
-
- /**
- * Set the Logger level.
- *
- * Use LoggerLevel::getLevelXXX() methods to get a LoggerLevel object, e.g.
- * <code>$logger->setLevel(LoggerLevel::getLevelInfo());</code>
- *
- * @param LoggerLevel $level The level to set, or NULL to clear the logger level.
- */
- public function setLevel(LoggerLevel $level = null) {
- $this->level = $level;
- }
-
- /**
- * Checks whether an appender is attached to this logger instance.
- *
- * @param LoggerAppender $appender
- * @return boolean
- */
- public function isAttached(LoggerAppender $appender) {
- return isset($this->appenders[$appender->getName()]);
- }
-
- /**
- * Sets the parent logger.
- * @param Logger $logger
- */
- public function setParent(Logger $logger) {
- $this->parent = $logger;
- }
-
- // ******************************************
- // *** Static methods and properties ***
- // ******************************************
-
- /** The logger hierarchy used by log4php. */
- private static $hierarchy;
-
- /** Inidicates if log4php has been initialized */
- private static $initialized = false;
-
- /**
- * Returns the hierarchy used by this Logger.
- *
- * Caution: do not use this hierarchy unless you have called initialize().
- * To get Loggers, use the Logger::getLogger and Logger::getRootLogger
- * methods instead of operating on on the hierarchy directly.
- *
- * @return LoggerHierarchy
- */
- public static function getHierarchy() {
- if(!isset(self::$hierarchy)) {
- self::$hierarchy = new LoggerHierarchy(new LoggerRoot());
- }
- return self::$hierarchy;
- }
-
- /**
- * Returns a Logger by name. If it does not exist, it will be created.
- *
- * @param string $name The logger name
- * @return Logger
- */
- public static function getLogger($name) {
- if(!self::isInitialized()) {
- self::configure();
- }
- return self::getHierarchy()->getLogger($name);
- }
-
- /**
- * Returns the Root Logger.
- * @return LoggerRoot
- */
- public static function getRootLogger() {
- if(!self::isInitialized()) {
- self::configure();
- }
- return self::getHierarchy()->getRootLogger();
- }
-
- /**
- * Clears all Logger definitions from the logger hierarchy.
- * @return boolean
- */
- public static function clear() {
- return self::getHierarchy()->clear();
- }
-
- /**
- * Destroy configurations for logger definitions
- */
- public static function resetConfiguration() {
- self::getHierarchy()->resetConfiguration();
- self::getHierarchy()->clear(); // TODO: clear or not?
- self::$initialized = false;
- }
-
- /**
- * Safely close all appenders.
- * @deprecated This is no longer necessary due the appenders shutdown via
- * destructors.
- */
- public static function shutdown() {
- return self::getHierarchy()->shutdown();
- }
-
- /**
- * check if a given logger exists.
- *
- * @param string $name logger name
- * @return boolean
- */
- public static function exists($name) {
- return self::getHierarchy()->exists($name);
- }
-
- /**
- * Returns an array this whole Logger instances.
- * @see Logger
- * @return array
- */
- public static function getCurrentLoggers() {
- return self::getHierarchy()->getCurrentLoggers();
- }
-
- /**
- * Configures log4php.
- *
- * This method needs to be called before the first logging event has
- * occured. If this method is not called before then the default
- * configuration will be used.
- *
- * @param string|array $configuration Either a path to the configuration
- * file, or a configuration array.
- *
- * @param string|LoggerConfigurator $configurator A custom
- * configurator class: either a class name (string), or an object which
- * implements the LoggerConfigurator interface. If left empty, the default
- * configurator implementation will be used.
- */
- public static function configure($configuration = null, $configurator = null) {
- self::resetConfiguration();
- $configurator = self::getConfigurator($configurator);
- $configurator->configure(self::getHierarchy(), $configuration);
- self::$initialized = true;
- }
-
- /**
- * Creates a logger configurator instance based on the provided
- * configurator class. If no class is given, returns an instance of
- * the default configurator.
- *
- * @param string|LoggerConfigurator $configurator The configurator class
- * or LoggerConfigurator instance.
- */
- private static function getConfigurator($configurator = null) {
- if ($configurator === null) {
- return new LoggerConfiguratorDefault();
- }
-
- if (is_object($configurator)) {
- if ($configurator instanceof LoggerConfigurator) {
- return $configurator;
- } else {
- trigger_error("log4php: Given configurator object [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
- return new LoggerConfiguratorDefault();
- }
- }
-
- if (is_string($configurator)) {
- if (!class_exists($configurator)) {
- trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
- return new LoggerConfiguratorDefault();
- }
-
- $instance = new $configurator();
-
- if (!($instance instanceof LoggerConfigurator)) {
- trigger_error("log4php: Specified configurator class [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
- return new LoggerConfiguratorDefault();
- }
-
- return $instance;
- }
-
- trigger_error("log4php: Invalid configurator specified. Expected either a string or a LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING);
- return new LoggerConfiguratorDefault();
- }
-
- /**
- * Returns true if the log4php framework has been initialized.
- * @return boolean
- */
- private static function isInitialized() {
- return self::$initialized;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerAppender.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerAppender.php b/src/main/php/LoggerAppender.php
deleted file mode 100644
index bff9f54..0000000
--- a/src/main/php/LoggerAppender.php
+++ /dev/null
@@ -1,286 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Abstract class that defines output logs strategies.
- *
- * @version $Revision$
- * @package log4php
- */
-abstract class LoggerAppender extends LoggerConfigurable {
-
- /**
- * Set to true when the appender is closed. A closed appender will not
- * accept any logging requests.
- * @var boolean
- */
- protected $closed = false;
-
- /**
- * The first filter in the filter chain.
- * @var LoggerFilter
- */
- protected $filter;
-
- /**
- * The appender's layout. Can be null if the appender does not use
- * a layout.
- * @var LoggerLayout
- */
- protected $layout;
-
- /**
- * Appender name. Used by other components to identify this appender.
- * @var string
- */
- protected $name;
-
- /**
- * Appender threshold level. Events whose level is below the threshold
- * will not be logged.
- * @var LoggerLevel
- */
- protected $threshold;
-
- /**
- * Set to true if the appender requires a layout.
- *
- * True by default, appenders which do not use a layout should override
- * this property to false.
- *
- * @var boolean
- */
- protected $requiresLayout = true;
-
- /**
- * Default constructor.
- * @param string $name Appender name
- */
- public function __construct($name = '') {
- $this->name = $name;
-
- if ($this->requiresLayout) {
- $this->layout = $this->getDefaultLayout();
- }
- }
-
- public function __destruct() {
- $this->close();
- }
-
- /**
- * Returns the default layout for this appender. Can be overriden by
- * derived appenders.
- *
- * @return LoggerLayout
- */
- public function getDefaultLayout() {
- return new LoggerLayoutSimple();
- }
-
- /**
- * Adds a filter to the end of the filter chain.
- * @param LoggerFilter $filter add a new LoggerFilter
- */
- public function addFilter($filter) {
- if($this->filter === null) {
- $this->filter = $filter;
- } else {
- $this->filter->addNext($filter);
- }
- }
-
- /**
- * Clears the filter chain by removing all the filters in it.
- */
- public function clearFilters() {
- $this->filter = null;
- }
-
- /**
- * Returns the first filter in the filter chain.
- * The return value may be <i>null</i> if no is filter is set.
- * @return LoggerFilter
- */
- public function getFilter() {
- return $this->filter;
- }
-
- /**
- * Returns the first filter in the filter chain.
- * The return value may be <i>null</i> if no is filter is set.
- * @return LoggerFilter
- */
- public function getFirstFilter() {
- return $this->filter;
- }
-
- /**
- * Performs threshold checks and invokes filters before delegating logging
- * to the subclass' specific <i>append()</i> method.
- * @see LoggerAppender::append()
- * @param LoggerLoggingEvent $event
- */
- public function doAppend(LoggerLoggingEvent $event) {
- if($this->closed) {
- return;
- }
-
- if(!$this->isAsSevereAsThreshold($event->getLevel())) {
- return;
- }
-
- $filter = $this->getFirstFilter();
- while($filter !== null) {
- switch ($filter->decide($event)) {
- case LoggerFilter::DENY: return;
- case LoggerFilter::ACCEPT: return $this->append($event);
- case LoggerFilter::NEUTRAL: $filter = $filter->getNext();
- }
- }
- $this->append($event);
- }
-
- /**
- * Sets the appender layout.
- * @param LoggerLayout $layout
- */
- public function setLayout($layout) {
- if($this->requiresLayout()) {
- $this->layout = $layout;
- }
- }
-
- /**
- * Returns the appender layout.
- * @return LoggerLayout
- */
- public function getLayout() {
- return $this->layout;
- }
-
- /**
- * Configurators call this method to determine if the appender
- * requires a layout.
- *
- * <p>If this method returns <i>true</i>, meaning that layout is required,
- * then the configurator will configure a layout using the configuration
- * information at its disposal. If this method returns <i>false</i>,
- * meaning that a layout is not required, then layout configuration will be
- * skipped even if there is available layout configuration
- * information at the disposal of the configurator.</p>
- *
- * <p>In the rather exceptional case, where the appender
- * implementation admits a layout but can also work without it, then
- * the appender should return <i>true</i>.</p>
- *
- * @return boolean
- */
- public function requiresLayout() {
- return $this->requiresLayout;
- }
-
- /**
- * Retruns the appender name.
- * @return string
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Sets the appender name.
- * @param string $name
- */
- public function setName($name) {
- $this->name = $name;
- }
-
- /**
- * Returns the appender's threshold level.
- * @return LoggerLevel
- */
- public function getThreshold() {
- return $this->threshold;
- }
-
- /**
- * Sets the appender threshold.
- *
- * @param LoggerLevel|string $threshold Either a {@link LoggerLevel}
- * object or a string equivalent.
- * @see LoggerOptionConverter::toLevel()
- */
- public function setThreshold($threshold) {
- $this->setLevel('threshold', $threshold);
- }
-
- /**
- * Checks whether the message level is below the appender's threshold.
- *
- * If there is no threshold set, then the return value is always <i>true</i>.
- *
- * @param LoggerLevel $level
- * @return boolean Returns true if level is greater or equal than
- * threshold, or if the threshold is not set. Otherwise returns false.
- */
- public function isAsSevereAsThreshold($level) {
- if($this->threshold === null) {
- return true;
- }
- return $level->isGreaterOrEqual($this->getThreshold());
- }
-
- /**
- * Prepares the appender for logging.
- *
- * Derived appenders should override this method if option structure
- * requires it.
- */
- public function activateOptions() {
- $this->closed = false;
- }
-
- /**
- * Forwards the logging event to the destination.
- *
- * Derived appenders should implement this method to perform actual logging.
- *
- * @param LoggerLoggingEvent $event
- */
- abstract protected function append(LoggerLoggingEvent $event);
-
- /**
- * Releases any resources allocated by the appender.
- *
- * Derived appenders should override this method to perform proper closing
- * procedures.
- */
- public function close() {
- $this->closed = true;
- }
-
- /** Triggers a warning for this logger with the given message. */
- protected function warn($message) {
- $id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
- trigger_error("log4php: [$id]: $message", E_USER_WARNING);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerAppenderPool.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerAppenderPool.php b/src/main/php/LoggerAppenderPool.php
deleted file mode 100644
index 0092b41..0000000
--- a/src/main/php/LoggerAppenderPool.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Pool implmentation for LoggerAppender instances.
- *
- * The pool is used when configuring log4php. First all appender instances
- * are created in the pool. Afterward, they are linked to loggers, each
- * appender can be linked to multiple loggers. This makes sure duplicate
- * appenders are not created.
- *
- * @version $Revision$
- * @package log4php
- */
-class LoggerAppenderPool {
-
- /** Holds appenders indexed by their name */
- public static $appenders = array();
-
- /**
- * Adds an appender to the pool.
- * The appender must be named for this operation.
- * @param LoggerAppender $appender
- */
- public static function add(LoggerAppender $appender) {
- $name = $appender->getName();
-
- if(empty($name)) {
- trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING);
- return;
- }
-
- if (isset(self::$appenders[$name])) {
- trigger_error("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
- }
-
- self::$appenders[$name] = $appender;
- }
-
- /**
- * Retrieves an appender from the pool by name.
- * @param string $name Name of the appender to retrieve.
- * @return LoggerAppender The named appender or NULL if no such appender
- * exists in the pool.
- */
- public static function get($name) {
- return isset(self::$appenders[$name]) ? self::$appenders[$name] : null;
- }
-
- /**
- * Removes an appender from the pool by name.
- * @param string $name Name of the appender to remove.
- */
- public static function delete($name) {
- unset(self::$appenders[$name]);
- }
-
- /**
- * Returns all appenders from the pool.
- * @return array Array of LoggerAppender objects.
- */
- public static function getAppenders() {
- return self::$appenders;
- }
-
- /**
- * Checks whether an appender exists in the pool.
- * @param string $name Name of the appender to look for.
- * @return boolean TRUE if the appender with the given name exists.
- */
- public static function exists($name) {
- return isset(self::$appenders[$name]);
- }
-
- /**
- * Clears all appenders from the pool.
- */
- public static function clear() {
- self::$appenders = array();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerAutoloader.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerAutoloader.php b/src/main/php/LoggerAutoloader.php
deleted file mode 100644
index 87a87c7..0000000
--- a/src/main/php/LoggerAutoloader.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-if (function_exists('__autoload')) {
- trigger_error("log4php: It looks like your code is using an __autoload() function. log4php uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.", E_USER_WARNING);
-}
-
-spl_autoload_register(array('LoggerAutoloader', 'autoload'));
-
-/**
- * Class autoloader.
- *
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- */
-class LoggerAutoloader {
-
- /** Maps classnames to files containing the class. */
- private static $classes = array(
-
- // Base
- 'LoggerAppender' => '/LoggerAppender.php',
- 'LoggerAppenderPool' => '/LoggerAppenderPool.php',
- 'LoggerConfigurable' => '/LoggerConfigurable.php',
- 'LoggerConfigurator' => '/LoggerConfigurator.php',
- 'LoggerException' => '/LoggerException.php',
- 'LoggerFilter' => '/LoggerFilter.php',
- 'LoggerHierarchy' => '/LoggerHierarchy.php',
- 'LoggerLevel' => '/LoggerLevel.php',
- 'LoggerLocationInfo' => '/LoggerLocationInfo.php',
- 'LoggerLoggingEvent' => '/LoggerLoggingEvent.php',
- 'LoggerMDC' => '/LoggerMDC.php',
- 'LoggerNDC' => '/LoggerNDC.php',
- 'LoggerLayout' => '/LoggerLayout.php',
- 'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
- 'LoggerRoot' => '/LoggerRoot.php',
- 'LoggerThrowableInformation' => '/LoggerThrowableInformation.php',
-
- // Appenders
- 'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php',
- 'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php',
- 'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php',
- 'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php',
- 'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php',
- 'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
- 'LoggerAppenderMongoDB' => '/appenders/LoggerAppenderMongoDB.php',
- 'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
- 'LoggerAppenderFirePHP' => '/appenders/LoggerAppenderFirePHP.php',
- 'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php',
- 'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
- 'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
- 'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php',
- 'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php',
-
- // Configurators
- 'LoggerConfigurationAdapter' => '/configurators/LoggerConfigurationAdapter.php',
- 'LoggerConfigurationAdapterINI' => '/configurators/LoggerConfigurationAdapterINI.php',
- 'LoggerConfigurationAdapterPHP' => '/configurators/LoggerConfigurationAdapterPHP.php',
- 'LoggerConfigurationAdapterXML' => '/configurators/LoggerConfigurationAdapterXML.php',
- 'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
-
- // Filters
- 'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
- 'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
- 'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
- 'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php',
-
- // Helpers
- 'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
- 'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
- 'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
- 'LoggerUtils' => '/helpers/LoggerUtils.php',
-
- // Pattern converters
- 'LoggerPatternConverter' => '/pattern/LoggerPatternConverter.php',
- 'LoggerPatternConverterClass' => '/pattern/LoggerPatternConverterClass.php',
- 'LoggerPatternConverterCookie' => '/pattern/LoggerPatternConverterCookie.php',
- 'LoggerPatternConverterDate' => '/pattern/LoggerPatternConverterDate.php',
- 'LoggerPatternConverterEnvironment' => '/pattern/LoggerPatternConverterEnvironment.php',
- 'LoggerPatternConverterFile' => '/pattern/LoggerPatternConverterFile.php',
- 'LoggerPatternConverterLevel' => '/pattern/LoggerPatternConverterLevel.php',
- 'LoggerPatternConverterLine' => '/pattern/LoggerPatternConverterLine.php',
- 'LoggerPatternConverterLiteral' => '/pattern/LoggerPatternConverterLiteral.php',
- 'LoggerPatternConverterLocation' => '/pattern/LoggerPatternConverterLocation.php',
- 'LoggerPatternConverterLogger' => '/pattern/LoggerPatternConverterLogger.php',
- 'LoggerPatternConverterMDC' => '/pattern/LoggerPatternConverterMDC.php',
- 'LoggerPatternConverterMessage' => '/pattern/LoggerPatternConverterMessage.php',
- 'LoggerPatternConverterMethod' => '/pattern/LoggerPatternConverterMethod.php',
- 'LoggerPatternConverterNDC' => '/pattern/LoggerPatternConverterNDC.php',
- 'LoggerPatternConverterNewLine' => '/pattern/LoggerPatternConverterNewLine.php',
- 'LoggerPatternConverterProcess' => '/pattern/LoggerPatternConverterProcess.php',
- 'LoggerPatternConverterRelative' => '/pattern/LoggerPatternConverterRelative.php',
- 'LoggerPatternConverterRequest' => '/pattern/LoggerPatternConverterRequest.php',
- 'LoggerPatternConverterServer' => '/pattern/LoggerPatternConverterServer.php',
- 'LoggerPatternConverterSession' => '/pattern/LoggerPatternConverterSession.php',
- 'LoggerPatternConverterSessionID' => '/pattern/LoggerPatternConverterSessionID.php',
- 'LoggerPatternConverterSuperglobal' => '/pattern/LoggerPatternConverterSuperglobal.php',
- 'LoggerPatternConverterThrowable' => '/pattern/LoggerPatternConverterThrowable.php',
-
- // Layouts
- 'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
- 'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php',
- 'LoggerLayoutSerialized' => '/layouts/LoggerLayoutSerialized.php',
- 'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php',
- 'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php',
- 'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php',
-
- // Renderers
- 'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
- 'LoggerRendererException' => '/renderers/LoggerRendererException.php',
- 'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
- 'LoggerRenderer' => '/renderers/LoggerRenderer.php',
- );
-
- /**
- * Loads a class.
- * @param string $className The name of the class to load.
- */
- public static function autoload($className) {
- if(isset(self::$classes[$className])) {
- include dirname(__FILE__) . self::$classes[$className];
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerConfigurable.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerConfigurable.php b/src/main/php/LoggerConfigurable.php
deleted file mode 100644
index 675037f..0000000
--- a/src/main/php/LoggerConfigurable.php
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-/**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* @package log4php
-*/
-
-/**
- * A base class from which all classes which have configurable properties are
- * extended. Provides a generic setter with integrated validation.
- *
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision $
- * @since 2.2
- */
-abstract class LoggerConfigurable {
-
- /** Setter function for boolean type. */
- protected function setBoolean($property, $value) {
- try {
- $this->$property = LoggerOptionConverter::toBooleanEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
- }
- }
-
- /** Setter function for integer type. */
- protected function setInteger($property, $value) {
- try {
- $this->$property = LoggerOptionConverter::toIntegerEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed.");
- }
- }
-
- /** Setter function for LoggerLevel values. */
- protected function setLevel($property, $value) {
- try {
- $this->$property = LoggerOptionConverter::toLevelEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
- }
- }
-
- /** Setter function for integer type. */
- protected function setPositiveInteger($property, $value) {
- try {
- $this->$property = LoggerOptionConverter::toPositiveIntegerEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed.");
- }
- }
-
- /** Setter for file size. */
- protected function setFileSize($property, $value) {
- try {
- $this->$property = LoggerOptionConverter::toFileSizeEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
- }
- }
-
- /** Setter function for numeric type. */
- protected function setNumeric($property, $value) {
- try {
- $this->$property = LoggerOptionConverter::toNumericEx($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
- }
- }
-
- /** Setter function for string type. */
- protected function setString($property, $value, $nullable = false) {
- if ($value === null) {
- if($nullable) {
- $this->$property= null;
- } else {
- $this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
- }
- } else {
- try {
- $value = LoggerOptionConverter::toStringEx($value);
- $this->$property = LoggerOptionConverter::substConstants($value);
- } catch (Exception $ex) {
- $value = var_export($value, true);
- $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
- }
- }
- }
-
- /** Triggers a warning. */
- protected function warn($message) {
- $class = get_class($this);
- trigger_error("log4php: $class: $message", E_USER_WARNING);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerConfigurator.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerConfigurator.php b/src/main/php/LoggerConfigurator.php
deleted file mode 100644
index a01ec3e..0000000
--- a/src/main/php/LoggerConfigurator.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Interface for logger configurators.
- *
- * @package log4php
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
- * @since 2.2
- */
-interface LoggerConfigurator
-{
- /**
- * Configures log4php based on the given configuration.
- *
- * All configurators implementations must implement this interface.
- *
- * @param LoggerHierarchy $hierarchy The hierarchy on which to perform
- * the configuration.
- * @param mixed $input Either path to the config file or the
- * configuration as an array.
- */
- public function configure(LoggerHierarchy $hierarchy, $input = null);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerException.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerException.php b/src/main/php/LoggerException.php
deleted file mode 100644
index 6989aca..0000000
--- a/src/main/php/LoggerException.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * LoggerException class
- *
- * @version $Revision$
- * @package log4php
- */
-class LoggerException extends Exception {
-}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/79ed2d0d/src/main/php/LoggerFilter.php
----------------------------------------------------------------------
diff --git a/src/main/php/LoggerFilter.php b/src/main/php/LoggerFilter.php
deleted file mode 100644
index 5df5174..0000000
--- a/src/main/php/LoggerFilter.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @package log4php
- */
-
-/**
- * Users should extend this class to implement customized logging
- * event filtering. Note that {@link LoggerCategory} and {@link LoggerAppender},
- * the parent class of all standard
- * appenders, have built-in filtering rules. It is suggested that you
- * first use and understand the built-in rules before rushing to write
- * your own custom filters.
- *
- * <p>This abstract class assumes and also imposes that filters be
- * organized in a linear chain. The {@link #decide
- * decide(LoggerLoggingEvent)} method of each filter is called sequentially,
- * in the order of their addition to the chain.
- *
- * <p>The {@link decide()} method must return one
- * of the integer constants {@link LoggerFilter::DENY},
- * {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::ACCEPT}.
- *
- * <p>If the value {@link LoggerFilter::DENY} is returned, then the log event is
- * dropped immediately without consulting with the remaining
- * filters.
- *
- * <p>If the value {@link LoggerFilter::NEUTRAL} is returned, then the next filter
- * in the chain is consulted. If there are no more filters in the
- * chain, then the log event is logged. Thus, in the presence of no
- * filters, the default behaviour is to log all logging events.
- *
- * <p>If the value {@link LoggerFilter::ACCEPT} is returned, then the log
- * event is logged without consulting the remaining filters.
- *
- * <p>The philosophy of log4php filters is largely inspired from the
- * Linux ipchains.
- *
- * @version $Revision$
- * @package log4php
- */
-abstract class LoggerFilter extends LoggerConfigurable {
-
- /**
- * The log event must be logged immediately without consulting with
- * the remaining filters, if any, in the chain.
- */
- const ACCEPT = 1;
-
- /**
- * This filter is neutral with respect to the log event. The
- * remaining filters, if any, should be consulted for a final decision.
- */
- const NEUTRAL = 0;
-
- /**
- * The log event must be dropped immediately without consulting
- * with the remaining filters, if any, in the chain.
- */
- const DENY = -1;
-
- /**
- * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain.
- */
- protected $next;
-
- /**
- * Usually filters options become active when set. We provide a
- * default do-nothing implementation for convenience.
- */
- public function activateOptions() {
- }
-
- /**
- * Decide what to do.
- * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be
- * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next
- * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then
- * the event will be logged without consulting with other filters in
- * the chain.
- *
- * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
- * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT}
- */
- public function decide(LoggerLoggingEvent $event) {
- return self::NEUTRAL;
- }
-
- /**
- * Adds a new filter to the filter chain this filter is a part of.
- * If this filter has already and follow up filter, the param filter
- * is passed on until it is the last filter in chain.
- *
- * @param $filter - the filter to add to this chain
- */
- public function addNext($filter) {
- if($this->next !== null) {
- $this->next->addNext($filter);
- } else {
- $this->next = $filter;
- }
- }
-
- /**
- * Returns the next filter in this chain
- * @return the next filter
- */
- public function getNext() {
- return $this->next;
- }
-
-}
[43/43] git commit: Added missing 'use' statements for exception
classes
Posted by ih...@apache.org.
Added missing 'use' statements for exception classes
Signed-off-by: Ivan Habunek <iv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/logging-log4php/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4php/commit/75ec90ff
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4php/tree/75ec90ff
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4php/diff/75ec90ff
Branch: refs/heads/v3
Commit: 75ec90ff5dee237caabcd4124eb6fe70c0080131
Parents: 378ce1a
Author: Ivan Habunek <iv...@gmail.com>
Authored: Thu Nov 28 17:02:28 2013 +0100
Committer: Ivan Habunek <iv...@gmail.com>
Committed: Thu Nov 28 17:02:28 2013 +0100
----------------------------------------------------------------------
src/Appenders/MongoDBAppender.php | 4 +---
src/Appenders/RollingFileAppender.php | 2 ++
src/ReflectionUtils.php | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/75ec90ff/src/Appenders/MongoDBAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/MongoDBAppender.php b/src/Appenders/MongoDBAppender.php
index c07e6b8..6123f83 100644
--- a/src/Appenders/MongoDBAppender.php
+++ b/src/Appenders/MongoDBAppender.php
@@ -20,8 +20,6 @@ namespace Apache\Log4php\Appenders;
use Apache\Log4php\LoggingEvent;
-use Exception;
-
use Mongo;
use MongoCollection;
use MongoDate;
@@ -148,7 +146,7 @@ class MongoDBAppender extends AbstractAppender
} catch (\InvalidArgumentException $ex) {
$this->closed = true;
$this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
- } catch (\Exception $ex) {
+ } catch (Exception $ex) {
$this->closed = true;
$this->warn('Invalid credentials for mongo database authentication');
}
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/75ec90ff/src/Appenders/RollingFileAppender.php
----------------------------------------------------------------------
diff --git a/src/Appenders/RollingFileAppender.php b/src/Appenders/RollingFileAppender.php
index 35af51a..a85c6aa 100644
--- a/src/Appenders/RollingFileAppender.php
+++ b/src/Appenders/RollingFileAppender.php
@@ -18,6 +18,8 @@
namespace Apache\Log4php\Appenders;
+use Apache\Log4php\LoggerException;
+
/**
* RollingFileAppender writes logging events to a specified file. The
* file is rolled over after a specified size has been reached.
http://git-wip-us.apache.org/repos/asf/logging-log4php/blob/75ec90ff/src/ReflectionUtils.php
----------------------------------------------------------------------
diff --git a/src/ReflectionUtils.php b/src/ReflectionUtils.php
index d5e488f..9ccbd6a 100644
--- a/src/ReflectionUtils.php
+++ b/src/ReflectionUtils.php
@@ -65,7 +65,7 @@ class ReflectionUtils
* Example:
*
* $arr['xxxname'] = 'Joe';
- * $arr['xxxmale'] = true;
+ * $arr['xxxmale'] = true;
* and prefix xxx causes setName and setMale.
*
* @param array $properties An array containing keys and values.
@@ -116,7 +116,7 @@ class ReflectionUtils
if (!method_exists($this->obj, $method)) {
$class = get_class($this->obj);
- throw new Exception("Error setting log4php property $name to $value: no method $method in class $class.");
+ throw new \Exception("Error setting log4php property $name to $value: no method $method in class $class.");
} else {
return call_user_func(array($this->obj, $method), $value);
}