summaryrefslogtreecommitdiffstats
path: root/modules/log.pl
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2007-07-04 02:00:24 +0000
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2007-07-04 02:00:24 +0000
commit2e39d5b2b95c2e705fd962c9752070f816c1dfec (patch)
tree64d6fde2a4cd488d7add12ca4897daee216777ae /modules/log.pl
parent6fe4d3ecbdc3196c7c62b9b7e00d5063bd0dbee9 (diff)
critical bug fix + code optimizations
Diffstat (limited to 'modules/log.pl')
-rw-r--r--modules/log.pl27
1 files changed, 12 insertions, 15 deletions
diff --git a/modules/log.pl b/modules/log.pl
index 759a3ea..e8a178a 100644
--- a/modules/log.pl
+++ b/modules/log.pl
@@ -1,12 +1,10 @@
+package ASM::Log;
+
use warnings;
use strict;
-package ASM::Log;
-
-#use String::Interpolate qw(interpolate);
-use IO::All;
+#use IO::All;
use POSIX qw(strftime);
-use Data::Dumper;
sub new
{
@@ -14,7 +12,6 @@ sub new
my $config = shift;
my $self = {};
$self->{CONFIG} = $config;
- $self->{MD} = {};
bless($self);
return $self;
}
@@ -30,11 +27,8 @@ sub logg
foreach my $chan ( @chans )
{
$chan = lc $chan;
- unless (defined($self->{MD}->{$chan}) && ($self->{MD}->{$chan} == 1)) {
- io($cfg->{dir} . $chan)->mkpath;
- $self->{MD}->{$chan} = 1;
- }
- $_='';
+ my $path = ">>$cfg->{dir}${chan}/${chan}" . strftime($cfg->{filefmt}, @time);
+ $_ = '';
$_ = "<$event->{nick}> $event->{args}->[0]" if $event->{type} eq 'public';
$_ = "*** $event->{nick} has joined $chan" if $event->{type} eq 'join';
$_ = "*** $event->{nick} has left $chan" if $event->{type} eq 'part';
@@ -45,10 +39,13 @@ sub logg
$_ = "-$event->{nick}- $event->{args}->[0]" if $event->{type} eq 'notice';
$_ = "*** $event->{nick} sets mode: " . join(" ",@{$event->{args}}) if $event->{type} eq 'mode';
$_ = "*** $event->{nick} changes topic to \"$event->{args}->[0]\"" if $event->{type} eq 'topic';
- print Dumper($event) if ($_ eq '');
- $_ = strftime($cfg->{timefmt}, @time) . $_ . "\n" unless $_ eq '';
- $_ >> io($cfg->{dir} . $chan . '/' . $chan . strftime($cfg->{filefmt}, @time)) unless ($_ eq '');
+ $_ = strftime($cfg->{timefmt}, @time) . $_ . "\n";
+ my $line = $_;
+ open(FH, $path) or die "Can't open $path: $!";
+ print FH $line;
+ close(FH);
+# $_ >> io($path);
}
}
-return 1;
+1;