From: Quinn W. <qu...@fa...> - 2007-07-03 23:28:20
|
So, the POD for Log::Log4perl::Appender describes the warp_message property, and gives some examples. It seems I should be able to return an array, which should be join'ed and used as the basis for my message. But it doesn't work; I get ARRAY(0xa19c948) and the like in my messages. I suspect the reason is that my particular appender type doesn't support warp_message. The POD mentions that Log::Dispatch-based appenders don't work. But Log::Log4perl::Appender::Screen doesn't work either. So... which appenders support it, and which don't? The POD should be more specific, methinks. Thanks for any elucidation you can lend. # from my log4perl.conf: log4perl.appender.screenAppender = Log::Log4perl::Appender::Screen log4perl.appender.screenAppender.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.screenAppender.layout.ConversionPattern \ = %d{MMM dd HH:mm:ss} %H: process %8P: client %X{ip}: %X{uri}: %5p: %m%n log4perl.appender.screenAppender.warp_message = sub { return @_ } Thanks, -- Quinn Weaver, independent contractor | President, San Francisco Perl Mongers http://fairpath.com/quinn/resume/ | http://sf.pm.org/ 510-520-5217 |
From: Mike S. <m...@pe...> - 2007-07-04 05:43:41
|
On Tue, 3 Jul 2007, Quinn Weaver wrote: > So, the POD for Log::Log4perl::Appender describes the warp_message property, > and gives some examples. It seems I should be able to return an array, which > should be join'ed and used as the basis for my message. > > But it doesn't work; I get ARRAY(0xa19c948) and the like in my messages. > > I suspect the reason is that my particular appender type doesn't support > warp_message. The POD mentions that Log::Dispatch-based appenders don't work. > But Log::Log4perl::Appender::Screen doesn't work either. The warp_message option is only for appenders which can handle an array ref instead of a message string. The DBI appender is the only example in the L4p distribution. Or, you can write your own appender (if you look at the screen appender or the FAQ, you'll see that this is trivial). This raises the question: What are you trying to do? Why do you need warp_message? I don't see how you could use it in a meaningful way with the default screen appender. -- Mike Mike Schilli m...@pe... > > So... which appenders support it, and which don't? The POD should be > more specific, methinks. Thanks for any elucidation you can lend. > > # from my log4perl.conf: > log4perl.appender.screenAppender = Log::Log4perl::Appender::Screen > log4perl.appender.screenAppender.layout = Log::Log4perl::Layout::PatternLayout > log4perl.appender.screenAppender.layout.ConversionPattern \ > = %d{MMM dd HH:mm:ss} %H: process %8P: client %X{ip}: %X{uri}: %5p: %m%n > log4perl.appender.screenAppender.warp_message = sub { return @_ } > > Thanks, > > -- > Quinn Weaver, independent contractor | President, San Francisco Perl Mongers > http://fairpath.com/quinn/resume/ | http://sf.pm.org/ > 510-520-5217 > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |
From: Quinn W. <qu...@fa...> - 2007-07-04 16:57:25
|
On Tue, Jul 03, 2007 at 10:43:30PM -0700, Mike Schilli wrote: > The warp_message option is only for appenders which can handle an array > ref instead of a message string. The DBI appender is the only example in > the L4p distribution. Or, you can write your own appender (if you look > at the screen appender or the FAQ, you'll see that this is trivial). Thanks. I may decide to go this route. > This raises the question: What are you trying to do? Why do you need > warp_message? I don't see how you could use it in a meaningful way with > the default screen appender. I am trying to graft several fancy features onto log4perl. Notes: I think I could do 1 using warp_message. I suspect I _couldn't_ do 2 and 3, because the stack trace (%T) is not part of the @_ passed to the warp_message sub... but I hadn't gotten that far when I realized that Log::Log4perl::Appender::Screen doesn't support warp_message. Features: 1) Automagically use Data::Dumper on any references passed. E.g. if I do debug( 'The hash was ', \%hash, ' and the array was ', $array_ref ); I want log4perl to dump those refs for me. Laziness. :) 2) Limit stack traces by number of stack frames, not by number of characters. Actually, I think this would be a nice feature to add to log4perl sometime. What do you think? I see l4p uses Carp::longmess; if it used Devel::StackTrace, this would be easier. For now, I was just trying to kludge it in by doing a regex substitution on the whole longmess. 3) Filter out Catalyst internals from stack traces. This would also be easier with Devel::StackTrace, because it provides an ignore_package option (see http://search.cpan.org/~drolsky/Devel-StackTrace-1.15/lib/Devel/StackTrace.pm ). For now, I was planning to, again, regex-massage the stack trace. But, again, I'm not sure I even get access to the stack trace in the warp_message sub. Anyway... since warp_message doesn't seem to DWIM, I will probably implement these features by hacking or subclassing Catalyst::Log::Log4perl. It defines versions of debug, info, et cetera that enqueue your messages; then later its _flush method gets called and sends them on to log4perl. So I can hack the enqueueing methods to "warp" my message as I desire. I hope this message was interesting to someone. :) -- Quinn Weaver, independent contractor | President, San Francisco Perl Mongers http://fairpath.com/quinn/resume/ | http://sf.pm.org/ 510-520-5217 |