diff options
| author | Paul Buetow <paul@buetow.org> | 2011-03-17 08:02:27 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-03-17 08:02:27 +0000 |
| commit | c0c2d506b4151a38178321e94276836dde52d169 (patch) | |
| tree | 0e867b0edf54b0950fd7ac05b61d276ad305c458 /Logger.pm | |
| parent | ee5e8bcb9b436c38f826304d49debf9d770bc877 (diff) | |
./lib and ./conf added.
Diffstat (limited to 'Logger.pm')
| -rw-r--r-- | Logger.pm | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/Logger.pm b/Logger.pm deleted file mode 100644 index f6c16e8..0000000 --- a/Logger.pm +++ /dev/null @@ -1,40 +0,0 @@ -package Logger; - -use Shell qw(mv); -use POSIX qw(strftime); - -$| = 1; - -sub new ($$) { - my ($class, $conf) = @_; - return bless { conf => $conf }, $class; -} - -sub logmsg ($$) { - my ($self, $msg) = @_; - my $conf = $self->{conf}; - my $logfile = $conf->{'daemon.logfile'}; - - open my $fh, ">>$logfile" or die "Can't write logfile $logfile: $!\n"; - print $fh localtime()." (PID $$): $msg\n"; - close $fh; -} - -sub err ($$) { - my ($self, $msg) = @_; - $self->logmsg($msg); - die "$msg\n"; -} - -sub rotatelog ($) { - my $self = shift; - my $conf = $self->{conf}; - my $logfile = $conf->{'daemon.logfile'}; - - $self->logmsg('Rotating logfile'); - - my $timestr = strftime "%Y%m%d-%H%M%S", localtime(); - mv($logfile, "$logfile.$timestr"); -} - -1; |
