summaryrefslogtreecommitdiffstats
path: root/scripts/logcompress_perl.pl
blob: 37395b5087c963efb3aa07a7dbd5c4b594f7aca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use warnings;
use Irssi;
use IO::Compress::Gzip qw(gzip $GzipError);
use vars qw($VERSION %IRSSI);

$VERSION = "0.01";
%IRSSI = (
    authors	=> 'vague',
    contact	=> 'vague!#irssi@fgreenode',
    name	=> "logcompress_perl",
    description	=> "compress logfiles then they're rotated, modified from original logcompress.pl to use perl modules instead",
    license	=> "Public Domain",
    url		=> "http://irssi.org/",
    changed	=> "2016-01-31T01:45+0100"
);

sub sig_rotate {
    my $input = $_[0]->{real_fname};
    gzip $input => "$input.gz" or Irssi::print(MSGLEVEL_CLIENTERROR, "gzip failed: $GzipError\n");
    unlink $input if -e "$input.gz";
}

Irssi::signal_add('log rotated', 'sig_rotate');