From: Mike S. <msc...@ao...> - 2003-12-07 07:51:41
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <font face="Arial,sans-serif"><font size="2"><br> <span type="cite">Armaity.Bilimoria wrote on 12/3/2003, 7:32 AM:</span> </font></font> <p><font face="Arial,sans-serif" size="2"></font></p> <blockquote type="cite" ><font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">We have two levels of sub classing - <font color="#000000">A.pm</font> 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 <font color="#000000">A.pm</font> has been doing just fine for almost a year now.</span></font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"></span></font><font face="Arial,sans-serif" size="2"> </font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">This is the first time we are creating logs from the Database and we want to leverage the code in <font color="#000000">A.pm</font>, so we thought of creating a subclass of <font color="#000000">A.pm</font> named <font color="#000000">B.pm</font> where we could</span></font><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"> use the same layouts but </span></font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"></span></font><font face="Arial,sans-serif" size="2"> </font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">1. pass the %d placeholder the time from the database instead of the default current_time it picks up.</span></font></div> </span></font></div> </blockquote> <font size="2"><font face="Arial,sans-serif">We got that one fixed. One down, two to go.</font></font><br> <blockquote type="cite" > <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"></span></font> </div> </span></font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">2. pass '' for %F %L %M and other placeholders we do not have information for in the database. </span></font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"></span></font><font face="Arial,sans-serif" size="2"> </font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">3. pass a constant value to MDC only for the set of logs from the database.</span></font></div> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003"></span></font> </div> </span></font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">Unfortunately the only way we thought we could accomplish that was by overriding what gets passed to these placeholders <font color="#000000">current_time()</font> for %d, <font color="#000000">curly_action()</font> for %X{progname} and <font color="#000000">render()</font> for other placeholders, in this new Module.</span></font></div> </blockquote> <font size="2"><font face="Arial,sans-serif">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.<br> <br> 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?<br> <br> </font></font><font face="Arial,sans-serif"><font size="2"><span id="x-photon-sig-84411393">-- <br> -- Mike<br> Mike Schilli<br> <a class="moz-txt-link-abbreviated" href="mailto:m...@pe...">m...@pe...</a></span></font></font> </body> </html> |
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 |