Skip Menu |
 

This queue is for tickets about the libnet CPAN distribution.

Report information
The Basics
Id: 80846
Status: open
Priority: 0/
Queue: libnet

People
Owner: Nobody in particular
Requestors: tlhackque [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Net::Cmd produces cybercrud in debug messages; doesn't allow message capture from rawdatasend
Download (untitled) / with headers
text/plain 1.5k
My version of Net::CMD reports 2.29 - not in the selectbox here. Net::Cmd prints GLOB{0x...} as the command name when debug is enabled. This is really annoying as we often turn on debug to deal with user issues, and explaining that this cybercrud is OK takes time. Cause is that debug_print gets an object reference, but simply stringifies it when writing to STDERR. It knows it's an object reference, since it uses the ref to call debug_text. Here is sample: Net::SMTP=GLOB(0x2585e48)<<< 250-ENHANCEDSTATUSCODES Net::SMTP=GLOB(0x2585e48)<<< 250-PIPELINING Net::SMTP=GLOB(0x2585e48)<<< 250-8BITMIME Net::SMTP=GLOB(0x2585e48)<<< 250-SIZE 10000000 Net::SMTP=GLOB(0x2585e48)<<< 250-DSN And here is the fix: --- /usr/share/perl5/Net/Cmd.pm~ 2012-09-14 08:07:41.000000000 - 0400 +++ /usr/share/perl5/Net/Cmd.pm 2012-11-08 12:32:30.595254831 -0500 @@ -158,11 +158,12 @@ sub debug_text { $_[2] } sub debug_print { my ($cmd, $out, $text) = @_; - print STDERR $cmd, ($out ? '>>> ' : '<<< '), $cmd->debug_text($out, $text); + my $cmdName = ref( $cmd ) || $cmd; + print STDERR $cmdName, ($out ? ' >>> ' : ' <<< '), $cmd->debug_text ($out, $text); } Which produces: Net::SMTP <<< 250-ENHANCEDSTATUSCODES Net::SMTP <<< 250-PIPELINING Net::SMTP <<< 250-8BITMIME Net::SMTP <<< 250-SIZE 10000000 Net::SMTP <<< 250-DSN Note that I added a space before the direction indicators; that seems cleaner to me, but isn't essential. Related issue: rawdatasend() doesn't call debug_print, or even debug_text, but should to enable output capture without redirecting STDERR.
Subject: Re: [rt.cpan.org #80846] Net::Cmd produces cybercrud in debug messages; doesn't allow message capture from rawdatasend
Date: Thu, 8 Nov 2012 11:51:43 -0600
To: bug-libnet [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
Showing the GLOB is deliberate. If you have multiple objects you can see which is which. Graham.
From: tlhackque [...] yahoo.com
Download (untitled) / with headers
text/plain 1.1k
Thanks for the extremely speedy reply!! On Thu Nov 08 12:51:56 2012, gbarr@pobox.com wrote: Show quoted text
> Showing the GLOB is deliberate. If you have multiple objects you can > see which is which. > > Graham. >
With a hex address? That varies from run to run? That an end-user will have to report? I think we can do better: Why not do something more friendly, like change the debug argument to: debug => 'Object 47', That's still a "true" value, and the output routine can use the old method if debug has the old value of 1... ($cmd->{debug} eq '1' ? $cmd : ->{debug}) Or since a GLOB ref is really only useful to someone debugging code (vs. an ISP mail or other end-user issue), I'd prefer: my $cmdName = ref( $cmd ) || $cmd; ($cmd->{debug} eq '1' ? $cmdName : ->{debug}) The code debugger can easily set his debug argument to a label -- or even "$cmd" when that's important. Or if you don't want to overload the debug argument, one could add debuglabel => "Object 47", and do the obvious ($cmd->{debuglabel}? $cmd->{debuglabel} : $cmdName) Please consider whether one of these alternatives would meet all requirements... Thanks again.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.