|
From: Armaity.Bilimoria <Arm...@ta...> - 2003-12-08 14:38:10
|
Mike,
=20
Sounds good, we could use the customized caller() function.
=20
Thank you,
Armaity
-----Original Message-----
From: Mike Schilli [mailto:msc...@ao...]=20
Sent: Sunday, December 07, 2003 1:52 AM
To: Armaity.Bilimoria
Cc: m...@pe...; log4perl-devel
Subject: RE: Log::Log4perl::Layout::PatternLayout
=09
=09
=09
Armaity.Bilimoria wrote on 12/3/2003, 7:32 AM:=20
=09
=09
We have two levels of sub classing - A.pm is a subclass
of Log::Log4perl::Layout::PatternLayout and in this module we have
specified different layouts we need to work with. These layouts include
%d, %F, %L, %M and many other placeholders and are used for all our logs
and A.pm has been doing just fine for almost a year now.
=09
=20
=09
This is the first time we are creating logs from the
Database and we want to leverage the code in A.pm, so we thought of
creating a subclass of A.pm named B.pm where we could use the same
layouts but=20
=09
=20
=09
=09
1. pass the %d placeholder the time from the database
instead of the default current_time it picks up.
We got that one fixed. One down, two to go.
=09
=09
=20
=09
2. pass '' for %F %L %M and other placeholders we do not
have information for in the database.=20
=09
=20
=09
=09
3. pass a constant value to MDC only for the set of logs
from the database.
=20
=09
Unfortunately the only way we thought we could
accomplish that was by overriding what gets passed to these placeholders
current_time() for %d, curly_action() for %X{progname} and render() for
other placeholders, in this new Module.
I think overriding %X{progname} wasn't necessary, setting the
MDC in your program reading out the database records should have
accomplished what you needed.
=09
Overriding render() is a bit problematic, because in order to do
so you must have copied a chunk of code. Hmm, so what to do about %F and
%L ... you could set the Log::Log4perl::caller_depth to a high value and
get [undef] for all of them, but that's just awful. Another option would
be for PatternLayout to allow a customized caller() function. How's
that?
=09
--=20
-- Mike
Mike Schilli
m...@pe...=20
|