Skip Menu |

This queue is for tickets about the Archive-Extract CPAN distribution.

Report information
The Basics
Id: 61734
Status: resolved
Priority: 0/
Queue: Archive-Extract

People
Owner: Nobody in particular
Requestors: bdfoy [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.42
Fixed in: (no value)



Subject: Add a subclassable debug method
In extract(), there is a series of print ... if $DEBUG. I want to capture that and send it into Log4perl with all of my other debugging output. So, I added a debug() method to Archive::Extract so I can subclass it then control that debugging output. The debug() is just doing the same thing as before and isn't trying to do anything fancy. From 21ded38fcda78776d56498284a1d6cfe5b8917f2 Mon Sep 17 00:00:00 2001 From: brian d foy <brian.d.foy@gmail.com> Date: Tue, 28 Sep 2010 14:54:19 -0500 Subject: [PATCH] * Add a subclassable debug() method, and use it --- lib/Archive/Extract.pm | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Archive/Extract.pm b/lib/Archive/Extract.pm index 538d8c3..ac175a9 100644 --- a/lib/Archive/Extract.pm +++ b/lib/Archive/Extract.pm @@ -402,22 +402,22 @@ sub extract { my($na, $fail); for my $method (@methods) { - print "# Extracting with ->$method\n" if $DEBUG; + $self->debug( "# Extracting with ->$method\n" ); my $rv = $self->$method; ### a positive extraction if( $rv and $rv ne METHOD_NA ) { - print "# Extraction succeeded\n" if $DEBUG; + $self->debug( "# Extraction succeeded\n" ); $self->_extractor($method); last; ### method is not available } elsif ( $rv and $rv eq METHOD_NA ) { - print "# Extraction method not available\n" if $DEBUG; + $self->debug( "# Extraction method not available\n" ); $na++; } else { - print "# Extraction method failed\n" if $DEBUG; + $self->debug( "# Extraction method failed\n" ); $fail++; } } @@ -1515,6 +1515,21 @@ sub error { return join $/, @$aref; } +=head2 debug( MESSAGE ) + +This method outputs MESSAGE to the default filehandle if C<$DEBUG> is +true. It's a small method, but it's here if you'd like to subclass it +so you can so something else with any debugging output. + +=cut + +### this is really a stub for subclassing +sub debug { + return unless $DEBUG; + + print $_[1]; +} + sub _no_buffer_files { my $self = shift; my $file = shift or return; -- 1.6.5.4