From: Mike S. <msc...@ao...> - 2003-12-07 07:08:53
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <font face="Arial,sans-serif"><font size="2"><span id="x-photon-sig-150995977"></span><br> </font></font> <div type="cite"><font face="Arial,sans-serif" size="2"><br> </font> <div><font face="Arial" color="#0000ff" size="2"><span class="505504314-03122003">Hi Mike,</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">Thank you for your quick response.</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">Yes, you could send out the qns on the list, that will be very helpful.</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">Sorry I should have explained in more detail. Here it goes:</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">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> <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> <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">So when our program runs it creates two sets of logs, one set using <font color="#000000">A.pm </font>with all %d %F %L placeholders populated correctly and the other set using <font color="#000000">B.pm</font> for logs from 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" color="#0000ff" size="2"><span class="505504314-03122003"></span></font><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">Any suggestions on how else we could accomplish the same will be very welcome.</span></font></div> <font face="Arial,sans-serif" size="2"></font> <div><font face="Arial,sans-serif" size="2"> </font></div> <font face="Arial,sans-serif" size="2"></font> <div align="left"><font face="Arial" color="#0000ff" size="2">Thank you,</font></div> <font face="Arial,sans-serif" size="2"></font> <div align="left"><font face="Arial" color="#0000ff" size="2">Armaity</font></div> <font face="Arial,sans-serif" size="2"></font> <blockquote><font face="Arial,sans-serif" size="2"> </font><font face="Arial,sans-serif" size="2"> </font> <div class="OutlookMessageHeader" lang="en-us" dir="ltr" align="left"><font face="Tahoma" size="2">-----Original Message-----<br> <b>From:</b> Mike Schilli [<a class="moz-txt-link-freetext" href="mailto:msc...@ao...">mailto:msc...@ao...</a>] <br> <b>Sent:</b> Tuesday, December 02, 2003 10:19 PM<br> <b>To:</b> Armaity.Bilimoria<br> <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:m...@pe...">m...@pe...</a><br> <b>Subject:</b> Re: Log::Log4perl::Layout::PatternLayout<br> <br> </font></div> <font face="Arial,sans-serif" size="2"><font size="2"><span type="cite">Armaity.Bilimoria wrote on 12/2/2003, 8:36 AM:</span> </font> </font><font face="Arial,sans-serif" size="2"> </font> <blockquote type="cite"><font face="Arial,sans-serif" size="2"> </font> <div><font face="Arial,sans-serif" size="2"><span class="012060216-02122003"> <div><span class="786062115-02122003"><font face="Arial"><font size="2"><span class="012060216-02122003">1. pass the date that was stored in the database instead of the letting it pick up the default current_time. We had to overload <font color="#0000ff">current_time()</font></span></font></font></span></div> </span></font></div> </blockquote> <font size="2" face="Arial,sans-serif"><font face="Arial,sans-serif">Hi </font></font><font face="Arial,sans-serif" size="2"><font size="2"><span type="cite">Armaity,</span><br> <br> </font></font><font size="2" face="Arial,sans-serif"><font face="Arial,sans-serif">I've added changes (scheduled for 0.41) that'll let you pass in an optional array to the PatternLayout constructor, enabling you to specify your own timing function:<br> <br> my $layout = Log::Log4perl::Layout::PatternLayout->new( { time_function => \& my_time_function }, "%m%n" );<br> <br> Will this work for you?<br> </font></font><font face="Arial,sans-serif" size="2"> </font> <blockquote type="cite"><font face="Arial,sans-serif" size="2"> </font> <div><font face="Arial,sans-serif" size="2"><span class="012060216-02122003"> <div><span class="786062115-02122003"><font face="Arial" size="2"><span class="012060216-02122003">2. we do not have information in the database table regarding the filename, line number, the pid, the method where the logging request was issue, etc., and so had to subclass <font color="#0000ff">render()</font> to make sure those values were set to '' and not pass information about the perl daemon doing the transfer.</span></font></span></div> </span></font></div> </blockquote> <font size="2" face="Arial,sans-serif"><font face="Arial,sans-serif">Hmm ... why aren't you just specifying a layout format that doesn't have %F, %L, etc. placeholders but constants?</font></font><font face="Arial,sans-serif" size="2"><br> </font> <blockquote type="cite"><font face="Arial,sans-serif" size="2"> </font> <div><font face="Arial,sans-serif" size="2"><span class="012060216-02122003"> <div><span class="786062115-02122003"><font face="Arial"><font size="2"><span class="012060216-02122003">3. we need to also override <font color="#0000ff">curly_action()</font> to assign a constant value to <font size="3"><font size="2">%X{progname}, used in our layout, </font></font>and set other options to ''.</span></font></font></span></div> </span></font></div> </blockquote> <font size="2" face="Arial,sans-serif"><font face="Arial,sans-serif">Wouldn't setting the MDC get you the desired result?</font></font><font face="Arial,sans-serif" size="2"><br> </font> <blockquote type="cite"><font face="Arial,sans-serif" size="2"> </font> <div><font face="Arial,sans-serif" size="2"><span class="012060216-02122003"> <div><span class="786062115-02122003"><font face="Arial"><font size="2"><span class="012060216-02122003"></span></font></font></span><span class="786062115-02122003"><font size="+0"><span class="012060216-02122003"></span><font face="Arial"><font size="2"><span class="012060216-02122003">We are now faced with the </span>difficult<span class="012060216-02122003">y that</span> subclassing <span class="012060216-02122003">provide</span><span class="012060216-02122003">s, constant comparison required <span class="012060216-02122003">by our team </span>for future releases of this Module and possible changes in our code to support newer releases.</span></font></font></font></span></div> </span></font></div> </blockquote> <font size="2" face="Arial,sans-serif"><font face="Arial,sans-serif">It's unlikely that we're gonna change these parts, but you're certainly correct, overriding non-public methods is a gamble :).</font></font><font face="Arial,sans-serif" size="2"><br> </font><font size="2" face="Arial,sans-serif"><font face="Arial"><br> Let me know what you think of my comments above, we'll see what we can do to accomodate your needs. <br> <br> Is it ok with you if I forward your question to the mailing list? Chances are someone else will find it helpful.<br> <br> </font></font><font face="Arial,sans-serif" size="2"><font size="2"><span id="x-photon-sig-17303305">-- <br> -- Mike<br> Mike Schilli<br> <a class="moz-txt-link-abbreviated" href="mailto:m...@pe...">m...@pe...</a></span></font> </font></blockquote> </div> </body> </html> |