diff options
Diffstat (limited to 'modules/log.pl')
| -rw-r--r-- | modules/log.pl | 27 |
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; |
