You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Ivan Habunek (Created) (JIRA)" <ji...@apache.org> on 2011/11/06 10:24:51 UTC
[jira] [Created] (LOG4PHP-161) All configurable components should
report errors when given invalid values
All configurable components should report errors when given invalid values
--------------------------------------------------------------------------
Key: LOG4PHP-161
URL: https://issues.apache.org/jira/browse/LOG4PHP-161
Project: Log4php
Issue Type: Improvement
Components: Code
Affects Versions: 2.1
Reporter: Ivan Habunek
Fix For: 2.2
This includes: appenders, layouts, renderers, filters (and any future ones).
This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
This is a mockup:
http://pastebin.com/0h4M35Br
I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LOG4PHP-161) All configurable components should
report errors when given invalid values
Posted by "Ivan Habunek (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13146825#comment-13146825 ]
Ivan Habunek commented on LOG4PHP-161:
--------------------------------------
Here's a modified example where LoggerOptionConverter handles all the conversion, and the base class does the logging.
http://pastebin.com/AyGWwqSN
What do you think?
> All configurable components should report errors when given invalid values
> --------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LOG4PHP-161) All configurable components should
report errors when given invalid values
Posted by "Florian Semm (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145043#comment-13145043 ]
Florian Semm commented on LOG4PHP-161:
--------------------------------------
1. it's right that a object knows its parameters and the type of this parameters, but the validation isn't a job for a object
2. this point is absolutly correct. i haven't considered this case.
the base class solution is the way to solve the problem, but the validation should do a helper class. the LoggerOptionConverter class is a good candidate for this.
> All configurable components should report errors when given invalid values
> --------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LOG4PHP-161) All configurable components should
report errors when given invalid values
Posted by "Ivan Habunek (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13146863#comment-13146863 ]
Ivan Habunek commented on LOG4PHP-161:
--------------------------------------
Actually, after trying to convert a couple of appenders to use the base class, it seems much simpler to remove the generic set() method and just use the actual setter methods - setString(), setInteger() etc.
This also removes a lot of the code from the base class, here's another mockup:
http://pastebin.com/2yMsU9st
It might be possible to go to a higher level of abstraction with the setter methods, since a lot of the code is repeated. But that might be going a bit too far.
> All configurable components should report errors when given invalid values
> --------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (LOG4PHP-161) All configurable components should
trigger warnings when given invalid values
Posted by "Ivan Habunek (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ivan Habunek resolved LOG4PHP-161.
----------------------------------
Resolution: Fixed
Assignee: Ivan Habunek
Done. That was a big scary commit... Hopefully nothing is broken. :-) All tests pass.
> All configurable components should trigger warnings when given invalid values
> -----------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Assignee: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LOG4PHP-161) All configurable components should
report errors when given invalid values
Posted by "Ivan Habunek (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145023#comment-13145023 ]
Ivan Habunek commented on LOG4PHP-161:
--------------------------------------
I can see two problems with the above ideas:
1. In both cases, the configurator would have to know how to validate parameters. Currently, this is not the case, and I would like to keep it that way. The object which is being configured (appender/filter/whatever) is the only one which knows how to validate it's own parameters.
2. If one was to programatically configure log4php (without using the configurator), the parameters should still be validated. For example, if I was to do this:
$appender = new LoggerAppenderFile();
$appender->setAppend("not a boolean");
I would like the appender to throw a warning, since the "append" property is boolean.
The only other solution I can see is to do this individually in each setter as it is done at the moment (in places where it is implemented at all). And this means a LOT of code recycling.
I'm not a big fan of the base class solution, but it seems as the most economical one. Why do you think it's such a bad idea?
> All configurable components should report errors when given invalid values
> --------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (LOG4PHP-161) All configurable components should
trigger warnings when given invalid values
Posted by "Ivan Habunek (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ivan Habunek updated LOG4PHP-161:
---------------------------------
Summary: All configurable components should trigger warnings when given invalid values (was: All configurable components should report errors when given invalid values)
> All configurable components should trigger warnings when given invalid values
> -----------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LOG4PHP-161) All configurable components should
report errors when given invalid values
Posted by "Florian Semm (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145018#comment-13145018 ]
Florian Semm commented on LOG4PHP-161:
--------------------------------------
It's a good idea to implement one "configurator", but I wouldn't do this with a god-logger class.
I think there are two solutions:
1. do it like the symfony2-framework
Define the configuration in a class and validate the input with the configuration-class. See https://github.com/floriansemm/Log4PhpBundle/blob/master/DependencyInjection/Configuration/Configuration.php
This happens before you setup the appenders/filters/what ever
2. The LoggerAppender-class has a reference to a configuration class
When you setup the appender the configuration class "validate" this config-property. The man problem is here: you have to declare the possible config-parameters for the appender
Maybe it isn't the easiest way, but to create another "BaseClass" isn't a good idea. A mixed solution of your idea and my is also possible! :)
> All configurable components should report errors when given invalid values
> --------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LOG4PHP-161) All configurable components should
report errors when given invalid values
Posted by "Florian Semm (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LOG4PHP-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13147526#comment-13147526 ]
Florian Semm commented on LOG4PHP-161:
--------------------------------------
I like the last version very much. It's a very clean solution.
Is it possible to rename this class to 'Configurable'. This classname says more about the work. A appender and a filter could inherit from this class.
> All configurable components should report errors when given invalid values
> --------------------------------------------------------------------------
>
> Key: LOG4PHP-161
> URL: https://issues.apache.org/jira/browse/LOG4PHP-161
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Affects Versions: 2.1
> Reporter: Ivan Habunek
> Labels: configuration, validation
> Fix For: 2.2
>
>
> This includes: appenders, layouts, renderers, filters (and any future ones).
> This is usually implemented in the property setter (sometime in activateOptions()). The problem is that the code for checking if something is an integer/boolean/string/whatever, and reporting an error is relatively long (cca 5-10 lines). We do not want to recycle this code for each and every setter.
> The proposed solution is to make a base class from which all configurable classes will inherit. This class will provide generic setters which include validation and error reporting.
> This is a mockup:
> http://pastebin.com/0h4M35Br
> I believe a solution to this issue should be included in 2.2 to complement the new configurator.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira