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 Dominic Lüchinger <d....@snowgarden.ch> on 2010/09/14 10:11:36 UTC

Easily extend Appender and LogLevel

Hello Dev-Mailinglist

I recently used log4php in a project. I often use FirePHP for debugging 
output. Unfortunately log4php does not support an FirePHP Appender. 
Someone in the log4php submitted recently a patch to support FirePHP. 
Inspired by this I wrote my one Appender with the support of 
Zend_Wildfire_Plugin_FirePhp. This was really straight forward. The 
problem now is the mapping of the Log-Levels of log4php and FirePHP. 
FirePHP has a LogLevel 'trace', to do a stacktrace and 'table' to ouput 
a table. I tried to create a new LoggerLevel by extending the 
LoggerLevel class. But there is a problem with the LoggerLevel class, 
that all the member variables are declared as private and not as 
protected. For that I had to copy paste and rewrite (scope access 
problem) methods like 'isGreaterOrEqual' and 'toString' to make my 
LoggerLevel work. Is there an other way to do the mapping?

Also it would be nice if I could register this new Appender together 
with the LoggerLevel to do something like:

$logger->trace("Trace starts here");

I could not found a way to register new appenders and LoggerLevels.

Thank you for your suggestions.

Dominic

Re: Easily extend Appender and LogLevel

Posted by Christian Grobmeier <gr...@gmail.com>.
>> http://svn.apache.org/repos/asf/logging/log4php/trunk/src/main/php/Logger.php
>> (search for trace)
>
> I only checked the newest stable version. That's perfect, that trace is
> included in the trunk. Any plans for the release date of 2.1? (I know the
> problem about guessing dates) :-)

haha ok that explains :-) Yes its definitley time for a release and
would like to step forward with this now. Hopefully in only a few
weeks? Depends on how much help i get from my fellows :-)

>> But I will check out the suggested patch and then hopefully understand
>> more about FirePHP.
>
> There is a core library from the FirePHP project it self. I don't know if
> it's a good idea to have external dependencies.

Depends on the dependencies license I daresay. Guess its GPL? Will check it out

>
> Dominic
>
>
>
>

Re: Easily extend Appender and LogLevel

Posted by Dominic Lüchinger <d....@snowgarden.ch>.
> But trace() is implemented - does it not do what you want?
> http://svn.apache.org/repos/asf/logging/log4php/trunk/src/main/php/Logger.php
> (search for trace)

I only checked the newest stable version. That's perfect, that trace is 
included in the trunk. Any plans for the release date of 2.1? (I know 
the problem about guessing dates) :-)

> But I will check out the suggested patch and then hopefully understand
> more about FirePHP.

There is a core library from the FirePHP project it self. I don't know 
if it's a good idea to have external dependencies.

Dominic




Re: Easily extend Appender and LogLevel

Posted by Christian Grobmeier <gr...@gmail.com>.
> The patch I was talking about can you find under:
> http://mail-archives.apache.org/mod_mbox/logging-log4php-dev/201007.mbox/%3CAANLkTimyKLh5e1uLDczYZiWDFDG54t9r-6HJr6tgXRZH@mail.gmail.com%3E

Thanks! I forgot it! Will try to include this into Jira.


> I've done the mapping in the Appender it self. The problem is, that the
> Logger itself not support register a new method like $logger->trace(). This
> can be done with a dynamic method (__call).

But trace() is implemented - does it not do what you want?
http://svn.apache.org/repos/asf/logging/log4php/trunk/src/main/php/Logger.php
(search for trace)


> Trace is IHMO not implemented in log4php. I see a difference in output a
> stacktrace to an exception, than stacktrace the path to the log message.

Trace is there (see above).
But I will check out the suggested patch and then hopefully understand
more about FirePHP.

> PS: I will contribute my changes. But at the moment there is a other
> discussion going on with additional appenders.

Cool thanks!
Christian

Re: Easily extend Appender and LogLevel

Posted by Dominic Lüchinger <d....@snowgarden.ch>.
Hello Christian

 > can you tell me which issue are you referring? You said someone
 > already submitted a patch for FirePHP. I would like to review this one
 > - it seems useful to me.

The patch I was talking about can you find under: 
http://mail-archives.apache.org/mod_mbox/logging-log4php-dev/201007.mbox/%3CAANLkTimyKLh5e1uLDczYZiWDFDG54t9r-6HJr6tgXRZH@mail.gmail.com%3E

 > On your problem, shouldn't the mapping happen in the Appender itself?

I've done the mapping in the Appender it self. The problem is, that the 
Logger itself not support register a new method like $logger->trace(). 
This can be done with a dynamic method (__call).

 > What new loggerlevels do you actually need? I think trace is already
 > implemented.

Trace is IHMO not implemented in log4php. I see a difference in output a 
stacktrace to an exception, than stacktrace the path to the log message.

PS: I will contribute my changes. But at the moment there is a other 
discussion going on with additional appenders.

Greets Dominic

Re: Easily extend Appender and LogLevel

Posted by Christian Grobmeier <gr...@gmail.com>.
Hello Dominic,

can you tell me which issue are you referring? You said someone
already submitted a patch for FirePHP. I would like to review this one
- it seems useful to me.

On your problem, shouldn't the mapping happen in the Appender itself?
The "registration" should happen when the class has been loaded (maybe
in the autoload section, but can be done on every other position in
your script. It will be used when you configure the appender in the
configuration (you use the classname to do this).

What new loggerlevels do you actually need? I think trace is already
implemented.

Anyway, FirePHP contributions are welcome :-) I have not done to much
on log4php the past weeks but have now time again and would like to
include this one if you are willing to contribute it :-)

Cheers,
Christian


On Tue, Sep 14, 2010 at 10:11 AM, Dominic Lüchinger
<d....@snowgarden.ch> wrote:
> Hello Dev-Mailinglist
>
> I recently used log4php in a project. I often use FirePHP for debugging
> output. Unfortunately log4php does not support an FirePHP Appender. Someone
> in the log4php submitted recently a patch to support FirePHP. Inspired by
> this I wrote my one Appender with the support of
> Zend_Wildfire_Plugin_FirePhp. This was really straight forward. The problem
> now is the mapping of the Log-Levels of log4php and FirePHP. FirePHP has a
> LogLevel 'trace', to do a stacktrace and 'table' to ouput a table. I tried
> to create a new LoggerLevel by extending the LoggerLevel class. But there is
> a problem with the LoggerLevel class, that all the member variables are
> declared as private and not as protected. For that I had to copy paste and
> rewrite (scope access problem) methods like 'isGreaterOrEqual' and
> 'toString' to make my LoggerLevel work. Is there an other way to do the
> mapping?
>
> Also it would be nice if I could register this new Appender together with
> the LoggerLevel to do something like:
>
> $logger->trace("Trace starts here");
>
> I could not found a way to register new appenders and LoggerLevels.
>
> Thank you for your suggestions.
>
> Dominic
>