I'd also go for Log::Log4perl. As you can see, leaving log statements in production code with logging disabled makes close to no impact on overall performance (it's actually faster in this benchmark :). Using the init_and_watch option, you can tune the log levels while the program is running (as noted by stiller). That is a property I value very much when arriving at a customer site and the system's symptoms are hard to interpret. Simply increase the log level for individual parts of the system, and see how it actually runs.
$ cat l4p_bench.pl #!/usr/bin/perl # Benchmark penalty of having disabled log4perl statements left in # production code. use strict; use warnings; use Log::Log4perl; use Benchmark qw(cmpthese); my $conf = q( log4perl.category.screen = WARN, Screen log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.layout = PatternLayout log4perl.appender.Screen.layout.ConversionPattern=[%p] %d %F:%L - ); Log::Log4perl::init( \$conf ); my $log = Log::Log4perl::get_logger("screen"); my @fibonacci = (0, 1); my $n = 1; my $sum = 0; # projecteuler.net - problem 2 # # Find the sum of all the even-valued terms in the Fibonacci sequence # which do not exceed four million. sub fib_no_log { while ($n < 1_000_000) { $n = $fibonacci[$#fibonacci] + $fibonacci[ $#fibonacci - 1 ]; push @fibonacci, $n; # append n to fibonacci list if (($n % 2) == 0) { $sum += $n; # add even number n to sum } } return $sum; } sub fib_log_1 { while ($n < 1_000_000) { $log->debug(qq{n:$n}) if $log->is_debug(); $n = $fibonacci[$#fibonacci] + $fibonacci[ $#fibonacci - 1 ]; push @fibonacci, $n; # append n to fibonacci list if (($n % 2) == 0) { $sum += $n; # add even number n to sum } } return $sum; } cmpthese( -5, { 'fib_no_log' => sub { fib_no_log() }, 'fib_log_1' => sub { fib_log_1() } } ); __END__
$ /usr/bin/perl l4p_bench.pl Rate fib_no_log fib_log_1 fib_no_log 997050/s -- -3% fib_log_1 1025993/s 3% --
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Re^2: Module implementing modified comment-style debugging. by andreas1234567
in thread Module implementing modified comment-style debugging. by Socrates

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.