diff options
| author | 2016-01-12 15:54:14 -0700 | |
|---|---|---|
| committer | 2016-01-12 15:54:14 -0700 | |
| commit | 5805d3c2ba935ffb3d6fa0dc53ba5debe2536eda (patch) | |
| tree | 483968d4e91099f8ef0e8d126e2cbb837a423722 | |
| parent | 3f75fd1d9273dd744e3d0ec98968401db7e3ae1a (diff) | |
Added the ability to do connection debugging in Net::IRC without doing full-blown debugging, and made use of that feature in meta.pl. Also fixed the debugging output of Net::IRC to print to STDERR regardless of what debug method is used
| -rw-r--r-- | lib/Net/IRC.pm | 12 | ||||
| -rw-r--r-- | lib/Net/IRC/Connection.pm | 17 | ||||
| -rwxr-xr-x | meta.pl | 9 |
3 files changed, 35 insertions, 3 deletions
diff --git a/lib/Net/IRC.pm b/lib/Net/IRC.pm index d46ae9e..4b93fe1 100644 --- a/lib/Net/IRC.pm +++ b/lib/Net/IRC.pm @@ -43,6 +43,7 @@ sub new { '_connhash' => {}, '_error' => IO::Select->new(), '_debug' => 0, + '_debugsock' => 0, '_schedulequeue' => new Net::IRC::EventQueue(), '_outputqueue' => new Net::IRC::EventQueue(), '_read' => IO::Select->new(), @@ -115,6 +116,17 @@ sub debug { return $self->{_debug}; } +# Sets or returns the socket debugging flag for this object. +# Takes 1 optional arg: a new boolean value for the flag. +sub debugsock { + my $self = shift; + + if (@_) { + $self->{_debugsock} = $_[0]; + } + return $self->{_debugsock}; +} + # Goes through one iteration of the main event loop. Useful for integrating # other event-based systems (Tk, etc.) with Net::IRC. # Takes no args. diff --git a/lib/Net/IRC/Connection.pm b/lib/Net/IRC/Connection.pm index f17bc68..65af574 100644 --- a/lib/Net/IRC/Connection.pm +++ b/lib/Net/IRC/Connection.pm @@ -63,6 +63,7 @@ sub new { my $self = { # obvious defaults go here, rest are user-set _debug => $_[0]->{_debug}, + _debugsock => $_[0]->{_debugsock}, _port => 6667, # Evals are for non-UNIX machines, just to make sure. _username => eval { scalar getpwuid($>) } || $ENV{USER} || $ENV{LOGNAME} || "japh", @@ -377,6 +378,16 @@ sub debug { return $self->{_debug}; } +# Sets or returns the socket debugging flag for this object. +# Takes 1 optional arg: a new boolean value for the flag. +sub debugsock { + my $self = shift; + if (@_) { + $self->{_debugsock} = $_[0]; + } + return $self->{_debugsock}; +} + # Dequotes CTCP messages according to ctcp.spec. Nothing special. # Then it breaks them into their component parts in a flexible, ircII- @@ -868,7 +879,7 @@ sub parse { $line =~ s/[\012\015]+$//; next unless $line; - print STDERR "<<< $line\n" if $self->{_debug}; + print STDERR "<<< $line\n" if ($self->{_debug} || $self->{_debugsock}); $::lastline = $line; #this is so __WARN__ can print the last line received on IRC. # Like the RFC says: "respond as quickly as possible..." @@ -1396,8 +1407,8 @@ sub sl_real { } ### DEBUG DEBUG DEBUG - if ($self->{_debug}) { - print ">>> $line\n"; + if ($self->{_debug} || $self->{_debugsock}) { + print STDERR ">>> $line\n"; } # RFC compliance can be kinda nice... @@ -96,6 +96,9 @@ sub init { 'pass|p=s' => \$::pass, 'config|c=s' => \$::cset ); + if (-e "debugmode") { + $::debug = 1; + } if ($::cset eq '') { $::cset = 'config-default'; } else { $::cset = "config-$::cset"; } ASM::XML->readXML(); @@ -106,6 +109,9 @@ sub init { $host = ${$::settings->{server}}[rand @{$::settings->{server}}]; ASM::Util->dprint( "Connecting to $host", "startup"); $irc->debug($::debug); + if (-e "debugsock") { + $irc->debugsock(1); + } if (!$::mysql->{disable}) { $::db = ASM::DB->new($::mysql->{db}, $::mysql->{host}, $::mysql->{port}, $::mysql->{user}, $::mysql->{pass}, $::mysql->{table}, @@ -120,6 +126,9 @@ sub init { Password => $::settings->{pass}, Pacing => 0 ); $conn->debug($::debug); + if (-e "debugsock") { + $conn->debugsock(1); + } $::inspector = ASM::Inspect->new(); $::services = ASM::Services->new(); $::commander = ASM::Commander->new(); |
