Hello all,

I am working on developing a Moose based logging Module. Yes I have reviewed the currently popular logging modules and while I used Log4perl for a while I still was looking for incremental functionality. I would like to ask the monastery for assistance in minimizing the impact of logging statements left in code.

I am a largely a solo coder. Meaning I don't have a lot of code infrastructure at $work. While I acknowledge the long term value of all the test infrastructure that is best practice I sometimes don't have the time to implement it while getting stuff done. My solution is to leave the debug statements from development in my production code so that if I break some old code with a new piece of code I can trace it through the old stuff as well as the new stuff. The obvious issue with this is that the debug stuff costs some production overhead.

I initially messed around with Smart::Comments since the production impact of these statements are near 0. However, I lost all of the goodness associated with logging namespaces and control from it. What is the best way to minimize the impact of deselected logging statements and deselected logging parameter evaluation in the following scenario?

package Logger; use Moose; sub log{ my ( $self, $string ) = @_; print $string . "<--- Logged information\n"; } package main; my $Logger = Logger->new; print "Some normal action here\n"; my $debug = "Sometimes I want this"; $Logger->log( $debug );

Points for a Moose based answer!

I already share some of my code on CPAN but I know that if I don't minimize the debug stuff that I leave in my code that most people will find it unusable. In a perfect world my logging config file would even be able to turn off parameter evaluation of some logging statements without having to wrap them in an if_error() block. Is that even possible? (Without source code filtering)


In reply to Moose based logging question by jandrew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.