logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject [27/43] git commit: LOG4PHP-121: Reorganized classes into namespaces
Date Thu, 28 Nov 2013 16:03:57 GMT
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 <ivan.habunek@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 <ivan.habunek@gmail.com>
Authored: Thu Nov 28 13:48:45 2013 +0100
Committer: Ivan Habunek <ivan.habunek@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);
+	}
+}


Mime
View raw message