[ https://issues.apache.org/jira/browse/LOG4PHP-178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284331#comment-13284331 ]
Ivan Habunek commented on LOG4PHP-178: -------------------------------------- It seems this was not a good change. After reviewing the code, I remembered that Logger level can be set to null. This means that it inherits the parent's level. Of course, the root logger's level must not be set to null. When we added the type hint, we removed the possibility of doing: $logger->setLevel(null); Therefore, I suggest that we revert this change, and add some code which will check that the provided object is indeed LoggerLevel. Also we can allow usage of level constants (LoggerLevel::WARN, etc.). This might make things a bit easier for the developer. Regards, Ivan > Avoid usage errors by adding Type Hints > --------------------------------------- > > Key: LOG4PHP-178 > URL: https://issues.apache.org/jira/browse/LOG4PHP-178 > Project: Log4php > Issue Type: Improvement > Affects Versions: 2.2.1 > Reporter: Christian Hammers > Assignee: Ivan Habunek > Priority: Minor > Labels: patch > > It's tempting to write: > $this->log = Logger::getRootLogger(); > $this->log->setLevel(LoggerLevel::WARN); > which at first succeedes but throws an exception when first using this Logger. > It would be more obvious to the user when he gets an immediate compiler error > due to type hints. > --- Logger.php.orig 2012-05-25 16:55:35.000000000 +0200 > > +++ Logger.php 2012-05-25 17:02:04.000000000 +0200 > > @@ -376,9 +376,11 @@ > > /** > > * Set the Logger level. > * > + * Use LoggerLevel::getLevelWarn() etc. to get a LoggerLevel object. > + * > * @param LoggerLevel $level the level to set > */ > - public function setLevel($level) { > + public function setLevel(LoggerLevel $level) { > $this->level = $level; > } > -- 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