Subject: | Net::SIP::Leg incorrect debug level for packets |
Date: | Mon, 24 Jul 2017 11:19:21 +0000 |
To: | "bug-Net-SIP [...] rt.cpan.org" <bug-Net-SIP [...] rt.cpan.org> |
From: | Richard Carver <richard.carver [...] cloudmont.co.uk> |
Net::SIP::Leg outputs the received and delivered packets when the level is 2 or more. It is supposed to output a short version if the level is 2 and a longer version if the level is 3 or more. However this second check uses the global default debug level and not the package-specific debug level to work this out.
As a result when debug is initialised as: default=30 and Net::SIP::Leg=2 the entire packet is output when only the summary should be shown.
My fix is as follows. I don't understand why I had to put brackets around DEBUG_LEVEL in Leg.pm, but without it didn't subtract the 2:
--- Debug.pm.orig 2017-07-24 11:11:58.404793721 +0000
+++ Debug.pm 2017-07-24 11:11:41.096385946 +0000
@@ -6,7 +6,7 @@
use Time::HiRes 'gettimeofday';
use Scalar::Util 'looks_like_number';
use base 'Exporter';
-our @EXPORT = qw( DEBUG DEBUG_DUMP LEAK_TRACK $DEBUG );
+our @EXPORT = qw( DEBUG DEBUG_DUMP DEBUG_LEVEL LEAK_TRACK $DEBUG );
our @EXPORT_OK = qw( debug stacktrace );
@@ -104,6 +104,7 @@
}
return $level
}
+sub DEBUG_LEVEL { __PACKAGE__->level }
################################################################
# set prefix
--- Leg.pm.orig 2017-07-24 11:10:02.488062798 +0000
+++ Leg.pm 2017-07-24 11:08:34.278984649 +0000
@@ -429,7 +429,7 @@
$self->{proto},
ip_parts2string($self->{src}),
ip_parts2string($dst),
- $packet->dump( Net::SIP::Debug->level -2 ) );
+ $packet->dump( (DEBUG_LEVEL) -2 ) );
return $self->sendto($packet,$dst,$callback);
}
@@ -470,7 +470,7 @@
$DEBUG && DEBUG( 2,"received packet on %s from %s:\n%s",
sip_sockinfo2uri($self->{proto},@{$self->{src}}{qw(addr port family)}),
sip_sockinfo2uri(@{$from}{qw(proto addr port family)}),
- $packet->dump( Net::SIP::Debug->level -2 )
+ $packet->dump( (DEBUG_LEVEL) - 2 )
);
return ($packet,$from);
}