A rewrite of LoggerConfiguratorXML
----------------------------------

                 Key: LOG4PHP-116
                 URL: https://issues.apache.org/jira/browse/LOG4PHP-116
             Project: Log4php
          Issue Type: Improvement
          Components: Code
            Reporter: Ivan Habunek


As discussed on the mailing list, it was decided that the LoggerConfiguratorXML 
would benefit from a rewrite. This is a full rewrite of the class using PHP's 
SimpleXML extension for parsing XML. 
(http://www.php.net/manual/en/book.simplexml.php)

The new implementation gives the following benefits compared to the current 
implementation:
* The code is cleaner and much more readable.
* The code executes in a more linear fashion, instead of an "infinite loop"
* The elements in the XML configuration are not parsed in the order they are 
written, therefore the order of elements is no longer important. Well, this is 
not entirely true, the order of parameters might be important for for some 
appenders or other components, but this is not a Configurator issue and has to 
be solved in the said components.
* Implemented internal error logging and debugging. Makes it easier for end 
user to diagnose problems with the configuration.

LoggerLog class was reinstated to facilitate internal logging. It is very 
simple, it has 3 logging methods: debug(), error() and warn(). These methods 
use the PHP function trigger_error for logging (with appropreate error types: 
E_USER_NOTICE for debug, E_USER_WARNING for warn and E_USER_ERROR for error 
messages). Error and warning level messages are enabled by default. Debug level 
are disabled by default, but can be enabled by:
* calling LoggerLog::setInternalDebugging(true)
* specifying debug="true" in root element of XML config file
* setting the environment variable log4php.debug=true

Additionally, the following changes were made to complement the above changes:
* LoggerOptionConverter::getSystemProperty was modified to check getenv($key) 
as well as $_ENV[$key], because $_ENV global array is sometimes not populated 
depending on the settings in php.ini (see variables_order directive in 
http://php.net/manual/en/ini.core.php).
* Implemented the __toString method in LoggerLevel. This allows for easier 
logging of levels, e.g. debug("Setting level to $level") where $level is an 
instance of LoggerLevel.

Note that the debug mode is quite verbose, I tried to show the order in which 
settings are parsed, and state if any setting was ignored and why.

Please try out and state your opinion. :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to