Date: Fri, 16 Jan 2004 02:11:45 -0500 From: Christopher Nehren <apeiron@comcast.net> To: FreeBSD Ports List <ports@freebsd.org> Subject: Small script for old gaim logging Message-ID: <20040116071145.GA27231@prophecy.dyndns.org>
next in thread | raw e-mail | index | archive | help
--opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Personally I don't like the new logging format that Gaim uses, so I wrote this Perl script to move logs kept in the new format to the old format. I know at least one other person who's interested in this, so I figured that other people might be interested as well. It's mostly easy to understand, and should work with anything that Gaim produces. If anyone has any problems with it, the way it's written, or anything about it, please do email me. =3D=3D=3D cut here =3D=3D=3D #!/usr/bin/perl use strict; use warnings; use File::Basename; use Tie::File; # Change this to where your Gaim log files are. The default should work if = you=20 # haven't changed anything. The trailing / is important for now, at least u= ntil # I teach this script how to handle not having one. This needs to be a full # path -- no ~ or similar expansions. Of course, Perl hackers know that # you can interpolate, so referring to one's own ~ doesn't need a ~. my $gaim_log_path =3D "$ENV{'HOME'}/.gaim/logs/"; # Set this to 1 if you want to unlink (rm) the log files as they're process= ed. # This script doesn't -- and won't ever -- have any way of telling whether = it # added some text to a log file. If it's set to 0, you'll have to remove the # files yourself, or you'll get duplicates upon each subsequent run. $unlink =3D 1; chdir $gaim_log_path; my @all_files =3D glob '**/**/**/**'; s#^/## for @all_files; for my $fullpath (@all_files) { my ($name, $path, undef) =3D fileparse($fullpath, '.txt'); my ($protocol, $source, $destination) =3D split(/\//, $path); tie my @newlog, 'Tie::File', $fullpath=20 or die "Can't tie $fullpath to \@newlog: $!"; chomp foreach @newlog; open OLDLOG, '>>', "${gaim_log_path}${destination}.log" or die "Can't open old log file $destination: $!"; print OLDLOG "$_\n" foreach @newlog; close OLDLOG or die "Can't close old log file $destination: $!"; untie @newlog; unlink $fullpath if $unlink; } =3D=3D=3D cut here =3D=3D=3D --=20 I abhor a system designed for the "user", if that word is a coded pejorative meaning "stupid and unsophisticated". -- Ken Thompson - Please CC me in all replies, even if I'm on the relevant list(s). --opJtzjQTFsWo+cga Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAB46xk/lo7zvzJioRAvQOAJ9eExp2zRPgusmiudre2I2N473qZwCguw96 St/6t52jy6gpEysrqCrBlLo= =tuUP -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040116071145.GA27231>