in reply to Re: Module implementing modified comment-style debugging.
in thread Module implementing modified comment-style debugging.

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]