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 <iv...@gmail.com> on 2012/01/13 10:22:24 UTC

Backslash as a logger name delimiter

Hi!

Currently loggers are placed into a hierarchy by dividing the logger name
by dots, e.g. a logger named "foo.bar.Baz" will be the child of "foo.bar",
and grandchild of "foo". The dot is used because it's a delimiter for
namespaces in Java (and as such was ported from log4j).

Since the PHP namespace notation uses backslash as a delimiter, I propose
to use backspace as a delimiter for logger names as well (of course we
would also leave dot delimiter for backward compatibility).

In this case logger named "foo\bar\Baz" would be child of "foo\bar", etc.

This would make nice things like this possible:

namespace org\apache\log4php;
class MyClass {
    function log() {
        $log = Logger::getLogger(__CLASS__);
        $log->info('bla');
    }
}

In this example, __CLASS__ would resolve into "org\apache\log4php\MyClass"
which would correctly be placed in logger hierarchy.

Any objections?

Ivan

Re: Backslash as a logger name delimiter

Posted by Vladimír Gorej <go...@codescale.net>.
No objections, great idea Ivan

Vladimír Gorej | CodeScale s.r.o.
email: gorej@codescale.net
tel: +421 948 023 011
web: http://www.codescale.net


On 01/13/2012 10:22 AM, Ivan Habunek wrote:
> Hi!
>
> Currently loggers are placed into a hierarchy by dividing the logger 
> name by dots, e.g. a logger named "foo.bar.Baz" will be the child of 
> "foo.bar", and grandchild of "foo". The dot is used because it's a 
> delimiter for namespaces in Java (and as such was ported from log4j).
>
> Since the PHP namespace notation uses backslash as a delimiter, I 
> propose to use backspace as a delimiter for logger names as well (of 
> course we would also leave dot delimiter for backward compatibility).
>
> In this case logger named "foo\bar\Baz" would be child of "foo\bar", etc.
>
> This would make nice things like this possible:
>
> namespace org\apache\log4php;
> class MyClass {
>     function log() {
>         $log = Logger::getLogger(__CLASS__);
>         $log->info('bla');
>     }
> }
>
> In this example, __CLASS__ would resolve into 
> "org\apache\log4php\MyClass" which would correctly be placed in logger 
> hierarchy.
>
> Any objections?
>
> Ivan