From f46e990efedb3d5d8ef94e833e0fa676047da1fe Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 14 Jan 2003 05:25:35 +0000 Subject: First go at sane logging --- Echolot/Thesaurus.pm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'Echolot/Thesaurus.pm') diff --git a/Echolot/Thesaurus.pm b/Echolot/Thesaurus.pm index b32dd80..afce0d9 100644 --- a/Echolot/Thesaurus.pm +++ b/Echolot/Thesaurus.pm @@ -1,7 +1,7 @@ package Echolot::Thesaurus; # (c) 2002 Peter Palfrader -# $Id: Thesaurus.pm,v 1.13 2002/12/03 02:59:13 weasel Exp $ +# $Id: Thesaurus.pm,v 1.14 2003/01/14 05:25:35 weasel Exp $ # =pod @@ -17,8 +17,8 @@ This package provides necessary functions for the thesaurus. =cut use strict; -use Carp qw{cluck}; use English; +use Echolot::Log; sub save_thesaurus($$$) { @@ -27,13 +27,13 @@ sub save_thesaurus($$$) { return 1 unless Echolot::Config::get()->{'thesaurus'}; my ($type) = $otype =~ /^([a-z-]+)$/; - cluck("type '$otype' is not clean in save_thesaurus"), return 0 unless defined $type; + Echolot::Log::cluck("type '$otype' is not clean in save_thesaurus."), return 0 unless defined $type; my ($id) = $oid =~ /^([0-9]+)$/; - cluck("id '$oid' is not clean in save_thesaurus"), return 0 unless defined $id; + Echolot::Log::cluck("id '$oid' is not clean in save_thesaurus."), return 0 unless defined $id; my $file = Echolot::Config::get()->{'thesaurusdir'}.'/'.$id.'.'.$type; open (F, ">$file") or - cluck ("Cannot open '$file': $!"), + Echolot::Log::warn ("Cannot open '$file': $!."), return 0; print F $data; close (F); @@ -46,7 +46,7 @@ sub build_thesaurus() { my $dir = Echolot::Config::get()->{'thesaurusdir'}; opendir(DIR, $dir) or - cluck ("Cannot open '$dir': $!"), + Echolot::Log::warn ("Cannot open '$dir': $!."), return 0; my @files = grep { ! /^\./ } readdir(DIR); closedir(DIR); @@ -69,9 +69,8 @@ sub build_thesaurus() { if ($mtime < $expire_date) { unlink ($dir.'/'.$filename) or - cluck("Cannot unlink expired $filename"); - print ("Expired thesaurus file $filename\n") if - Echolot::Config::get()->{'verbose'}; + Echolot::Log::warn("Cannot unlink expired $filename."); + Echolot::Log::info("Expired thesaurus file $filename."); next; }; -- cgit v1.2.3