diff options
| author | fukachan <fukachan> | 2003-08-23 07:24:40 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-08-23 07:24:40 +0000 |
| commit | 9723a7a408f11cf8beaf8f618d2863c2f3e28ddb (patch) | |
| tree | dd4b1e0ae8d32873a0a289d5ba2a7cf01a2cc3ad /fml/lib/FML/Process | |
| parent | 1757df2907216e1ab833c05ac8a2757f0b6a67e7 (diff) | |
| download | fml8-9723a7a408f11cf8beaf8f618d2863c2f3e28ddb.tar.gz fml8-9723a7a408f11cf8beaf8f618d2863c2f3e28ddb.tar.bz2 fml8-9723a7a408f11cf8beaf8f618d2863c2f3e28ddb.zip | |
define $curproc->log, logwarn, logerror and log_message() methods.
modified to use $curproc->log*() interface.
Diffstat (limited to 'fml/lib/FML/Process')
| -rw-r--r-- | fml/lib/FML/Process/Addr.pm | 18 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Alias.pm | 18 | ||||
| -rw-r--r-- | fml/lib/FML/Process/CGI/Kernel.pm | 10 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Command.pm | 106 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Configure.pm | 24 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Digest.pm | 24 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Distribute.pm | 58 | ||||
| -rw-r--r-- | fml/lib/FML/Process/DocViewer.pm | 18 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Error.pm | 36 | ||||
| -rw-r--r-- | fml/lib/FML/Process/HTMLify.pm | 18 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Kernel.pm | 216 | ||||
| -rw-r--r-- | fml/lib/FML/Process/QMail.pm | 10 | ||||
| -rw-r--r-- | fml/lib/FML/Process/QueueManager.pm | 10 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Utils.pm | 16 |
14 files changed, 337 insertions, 245 deletions
diff --git a/fml/lib/FML/Process/Addr.pm b/fml/lib/FML/Process/Addr.pm index f3f76a63..9de628a6 100644 --- a/fml/lib/FML/Process/Addr.pm +++ b/fml/lib/FML/Process/Addr.pm @@ -3,7 +3,7 @@ # Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Addr.pm,v 1.8 2003/08/23 04:35:37 fukachan Exp $ +# $FML: Addr.pm,v 1.9 2003/08/23 04:43:40 fukachan Exp $ # package FML::Process::Addr; @@ -78,14 +78,14 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmladdr_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $eval = $config->get_hook( 'fmladdr_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -102,7 +102,7 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmladdr_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } if (0) { print STDERR "Error: missing argument(s)\n"; @@ -111,7 +111,7 @@ sub verify_request } $eval = $config->get_hook( 'fmladdr_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -153,10 +153,10 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmladdr_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $eval = $config->get_hook( 'fmladdr_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -214,7 +214,7 @@ sub _fmladdr my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmladdr_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # show only accounts if -n option specified. my $mode = $args->{ options }->{ n } ? 'fmlonly' : 'all'; @@ -242,7 +242,7 @@ sub _fmladdr } $eval = $config->get_hook( 'fmladdr_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } diff --git a/fml/lib/FML/Process/Alias.pm b/fml/lib/FML/Process/Alias.pm index 99c4637d..5d242036 100644 --- a/fml/lib/FML/Process/Alias.pm +++ b/fml/lib/FML/Process/Alias.pm @@ -3,7 +3,7 @@ # Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Alias.pm,v 1.9 2003/08/23 04:35:37 fukachan Exp $ +# $FML: Alias.pm,v 1.10 2003/08/23 04:43:41 fukachan Exp $ # package FML::Process::Alias; @@ -74,14 +74,14 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlalias_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $eval = $config->get_hook( 'fmlalias_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -98,7 +98,7 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlalias_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } if (0) { print STDERR "Error: missing argument(s)\n"; @@ -107,7 +107,7 @@ sub verify_request } $eval = $config->get_hook( 'fmlalias_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -147,10 +147,10 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlalias_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $eval = $config->get_hook( 'fmlalias_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -212,7 +212,7 @@ sub _fmlalias my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlalias_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # show fmlonly aliases if -n option specified. my $mode = $args->{ options }->{ n } ? 'fmlonly' : 'all'; @@ -229,7 +229,7 @@ sub _fmlalias } $eval = $config->get_hook( 'fmlalias_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } diff --git a/fml/lib/FML/Process/CGI/Kernel.pm b/fml/lib/FML/Process/CGI/Kernel.pm index 032124e2..ee87a033 100644 --- a/fml/lib/FML/Process/CGI/Kernel.pm +++ b/fml/lib/FML/Process/CGI/Kernel.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Kernel.pm,v 1.49 2003/02/16 09:45:08 fukachan Exp $ +# $FML: Kernel.pm,v 1.50 2003/08/23 04:35:41 fukachan Exp $ # package FML::Process::CGI::Kernel; @@ -244,9 +244,9 @@ sub _error_string eval q{ use FML::Log qw(Log LogError); - LogError($r); + $curproc->logerror($r); my ($k, $v); - while (($k, $v) = each %ENV) { Log("$k => $v");} + while (($k, $v) = each %ENV) { $curproc->log("$k => $v");} }; } @@ -347,7 +347,7 @@ sub cgi_execute_command my $config = $curproc->config(); unless ($config->has_attribute("commands_for_admin_cgi", $comname)) { - LogError("cgi deny command: mode=$commode level=cgi"); + $curproc->logerror("cgi deny command: mode=$commode level=cgi"); # XXX-TODO: validate $comname (CSS). my $buf = $curproc->message_nl("cgi.deny", @@ -357,7 +357,7 @@ sub cgi_execute_command return; } else { - Log("run $comname mode=$commode level=cgi"); + $curproc->log("run $comname mode=$commode level=cgi"); } use FML::Command; diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm index f5895b1f..a4a7461f 100644 --- a/fml/lib/FML/Process/Command.pm +++ b/fml/lib/FML/Process/Command.pm @@ -3,7 +3,7 @@ # Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Command.pm,v 1.86 2003/05/14 12:02:01 fukachan Exp $ +# $FML: Command.pm,v 1.87 2003/08/23 04:35:38 fukachan Exp $ # package FML::Process::Command; @@ -78,7 +78,7 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'command_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); @@ -89,12 +89,12 @@ sub prepare $curproc->parse_incoming_message($args); } else { - LogError("use of command_mail_program prohibited"); + $curproc->logerror("use of command_mail_program prohibited"); exit(0); } $eval = $config->get_hook( 'command_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -115,7 +115,7 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'command_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->verify_sender_credential(); @@ -124,7 +124,7 @@ sub verify_request } $eval = $config->get_hook( 'command_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -149,19 +149,19 @@ sub _check_filter _arg_reason => $r, }; - Log("(debug) filter: inform rejection"); + $curproc->log("(debug) filter: inform rejection"); $filter->command_mail_filter_reject_notice($curproc,$msg_args); } else { - Log("filter: not inform rejection"); + $curproc->log("filter: not inform rejection"); } # we should stop this process ASAP. $curproc->stop_this_process(); - Log("rejected by filter due to $r"); + $curproc->log("rejected by filter due to $r"); } }; - Log($@) if $@; + $curproc->log($@) if $@; } @@ -190,7 +190,7 @@ sub run my $config = $curproc->{ config }; my $eval = $config->get_hook( 'command_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } unless ($curproc->is_refused()) { # permit_xxx() sets the error reason at "check_restriction" in pcb. @@ -222,14 +222,14 @@ sub run $curproc->reply_message_add_header_info(); unless (defined $reason) { $reason = 'unknown';} - Log("deny command. reason=$reason"); + $curproc->log("deny command. reason=$reason"); } } else { - LogError("ignore this request."); + $curproc->logerror("ignore this request."); } $eval = $config->get_hook( 'command_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -275,13 +275,13 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'command_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->inform_reply_messages(); $curproc->queue_flush(); $eval = $config->get_hook( 'command_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -329,7 +329,7 @@ sub _config_permit_command } else { if ($level eq 'admin' || $level eq 'user') { - Log("commands_for_$level has no $comname"); + $curproc->log("commands_for_$level has no $comname"); $curproc->reply_message("\n$prompt $command"); $curproc->reply_message_nl('command.not_command', "not command, ignored."); @@ -338,7 +338,7 @@ sub _config_permit_command ; # ignored. } else { - LogWarn("unknown level=$level"); + $curproc->logwarn("unknown level=$level"); } return 0; @@ -366,7 +366,7 @@ sub _is_safe_syntax } else { if ($level eq 'admin') { - LogError("insecure command: $command"); + $curproc->logerror("insecure command: $command"); $curproc->reply_message("\n$prompt $command"); $curproc->reply_message_nl('command.insecure', "insecure, so ignored."); @@ -375,7 +375,7 @@ sub _is_safe_syntax ; # ignored. } else { - LogWarn("unknown level=$level"); + $curproc->logwarn("unknown level=$level"); } return 0; @@ -455,20 +455,20 @@ sub _try_admin_auth # reject as soon as possible if ($is_auth eq '__LAST__') { - Log("admin: rejected by $rule"); + $curproc->log("admin: rejected by $rule"); return 0; } elsif ($is_auth) { - Log("admin: auth by $rule"); + $curproc->log("admin: auth by $rule"); return $is_auth; } else { - Log("admin: not match rule=$rule") if $debug; + $curproc->log("admin: not match rule=$rule") if $debug; } } } else { - LogError("fail to load FML::Command::Auth"); + $curproc->logerror("fail to load FML::Command::Auth"); return 0; } @@ -531,17 +531,17 @@ sub _get_command_mode } else { # no, we do not accept this command. - Log("invalid command: $command"); + $curproc->log("invalid command: $command"); return '__NEXT__'; } } # Case: "admin" command is exceptional. try priviledged mode. elsif ($command =~ /$admin_prefix\s+/) { if ($is_auth) { - Log("admin: auth-ed already. run <$command>") if $debug; + $curproc->log("admin: auth-ed already. run <$command>") if $debug; } else { # for the first time ? - Log("admin: try auth"); + $curproc->log("admin: try auth"); my $sender = $curproc->{'credential'}->{'sender'}; my $data = $command; @@ -553,7 +553,7 @@ sub _get_command_mode # XXX simple state machine: update $status->{ is_auth } $is_auth = $curproc->_try_admin_auth($args, $optargs); $status->{ is_auth } = $is_auth; - Log("admin: o.k. auth-ed as an ML admin") if $is_auth; + $curproc->log("admin: o.k. auth-ed as an ML admin") if $is_auth; } if ($is_admin && $is_auth) { @@ -571,7 +571,7 @@ sub _get_command_mode } else { # no, we do not accept this command. - Log("invalid command(priv mode): $command"); + $curproc->log("invalid command(priv mode): $command"); return '__NEXT__'; } } @@ -585,7 +585,7 @@ sub _get_command_mode elsif ((! $is_admin) && $is_auth) { $status->{ _stop_reason_key } = 'error.not_admin_member'; $status->{ _stop_reason_str } = "not admin member."; - LogError("not admin member"); + $curproc->logerror("not admin member"); } # other reasons else { @@ -593,14 +593,14 @@ sub _get_command_mode $status->{ _stop_reason_str } = "not authenticated."; } - LogError("admin command not authenticated"); + $curproc->logerror("admin command not authenticated"); return '__LAST__'; } } # ignore all requests except for confirm command # when we receive "confirm" command for better security. elsif ($is_confirm) { - Log("ignore(confirm stage): $command"); + $curproc->log("ignore(confirm stage): $command"); return '__NEXT__'; } # Case: use command (commands "a usual member" can use) @@ -613,7 +613,7 @@ sub _get_command_mode } else { # no, we do not accept this command. - Log("invalid command: $command"); + $curproc->log("invalid command: $command"); return '__NEXT__'; } } @@ -627,13 +627,13 @@ sub _get_command_mode # XXX invalid condition is satisfied. # XXX emergency stop if admin mode. if ($status->{ level } eq 'admin') { - LogError("command from not member."); - LogError("command processing stop."); + $curproc->logerror("command from not member."); + $curproc->logerror("command processing stop."); return '__LAST__'; } # XXX but just ignore this commnad unless admin mode. else { - Log("(debug) ignore $command") if $debug; + $curproc->log("(debug) ignore $command") if $debug; return '__NEXT__'; } } @@ -658,13 +658,13 @@ sub _config_allow_command my $config = $curproc->config(); my $level = $status->{ level }; - Log("(debug) mode=$mode level=$level") if $debug; + $curproc->log("(debug) mode=$mode level=$level") if $debug; if ($config->has_attribute("commands_for_${level}", $comname)) { - Log("(debug) $comname o.k. under mode=$mode level=$level") if $debug; + $curproc->log("(debug) $comname o.k. under mode=$mode level=$level") if $debug; } else { - Log("deny command: mode=$mode level=$level"); + $curproc->log("deny command: mode=$mode level=$level"); return 0; } @@ -795,7 +795,7 @@ sub _evaluate_command_lines my $eval = $config->get_hook( 'command_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # firstly, prompt (for politeness :) to show processing ... $curproc->reply_message("result for your command requests follows:"); @@ -811,7 +811,7 @@ sub _evaluate_command_lines $num_total++; # the total numer of non null lines - Log("(debug) input: $orig_command") if $debug; # log raw buffer + $curproc->log("(debug) input: $orig_command") if $debug; # log raw buffer # Example: if orig_command = "# help", comname = "help" $fixed_command = __clean_up($orig_command); @@ -824,7 +824,7 @@ sub _evaluate_command_lines next COMMAND; } elsif ($mode eq '__LAST__') { - LogError("command processing stop."); + $curproc->logerror("command processing stop."); $curproc->__stop_here($args, $status, $cominfo, $orig_command); last COMMAND; } @@ -837,7 +837,7 @@ sub _evaluate_command_lines # 1.3 valid mode unless ($mode eq 'user' || $mode eq 'admin') { - LogError("command processing stop."); + $curproc->logerror("command processing stop."); $curproc->__stop_here($args, $status, $cominfo, $orig_command); last COMMAND; } @@ -846,21 +846,21 @@ sub _evaluate_command_lines unless ($curproc->_config_allow_command($mode, $status, $cominfo)) { $curproc->reply_message_nl("command.deny", "\tyou cannot use this command."); - Log("(debug) ignore $fixed_command"); + $curproc->log("(debug) ignore $fixed_command"); $num_ignored++; next COMMAND; } # 3. simple syntax check unless ($curproc->_is_safe_syntax($args, $status, $cominfo)) { - LogError("invalid/unsafe syntax"); - Log("(debug) ignore $fixed_command"); + $curproc->logerror("invalid/unsafe syntax"); + $curproc->log("(debug) ignore $fixed_command"); $num_ignored++; next COMMAND; } # o.k. here we go to execute this command - Log("execute \"$fixed_command\"") if $debug; + $curproc->log("execute \"$fixed_command\"") if $debug; $num_processed++; use FML::Command; @@ -889,7 +889,7 @@ sub _evaluate_command_lines # reply buffer $curproc->reply_message("\n$prompt $orig_command", $msg_args); - Log($orig_command); + $curproc->log($orig_command); # execute command ($comname method) under eval(). # XXX $obj = FML::Command object NOT FML::Command::$mode::$command @@ -903,21 +903,21 @@ sub _evaluate_command_lines } else { # error trap my $reason = $@; - Log($reason); + $curproc->log($reason); $curproc->reply_message_nl('command.fail', "fail.", $msg_args); - LogError("command ${comname} fail"); + $curproc->logerror("command ${comname} fail"); if ($reason =~ /^(.*)\s+at\s+/) { my $reason = $1; - Log($reason); # pick up reason + $curproc->log($reason); # pick up reason } } } } # END OF FOR LOOP: for my $orig_command (@body) { ... } $eval = $config->get_hook( 'command_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # info $curproc->reply_message("\ncommand processing results:"); @@ -938,7 +938,7 @@ sub _evaluate_command_lines if (keys %cc_recipient) { for my $k (keys %cc_recipient) { my $ra_addr = $cc_recipient{ $k }; - Log("msg.cc: [ @$ra_addr ]"); + $curproc->log("msg.cc: [ @$ra_addr ]"); $curproc->reply_message( $msg , { recipient => $ra_addr }); } } diff --git a/fml/lib/FML/Process/Configure.pm b/fml/lib/FML/Process/Configure.pm index 00452d95..c8fa69fa 100644 --- a/fml/lib/FML/Process/Configure.pm +++ b/fml/lib/FML/Process/Configure.pm @@ -3,7 +3,7 @@ # Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Configure.pm,v 1.52 2003/08/23 04:35:38 fukachan Exp $ +# $FML: Configure.pm,v 1.53 2003/08/23 04:43:41 fukachan Exp $ # package FML::Process::Configure; @@ -75,7 +75,7 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'makefml_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->close_stderr_channel_if_quiet_option_specified(); $curproc->resolve_ml_specific_variables( $args ); @@ -83,7 +83,7 @@ sub prepare $curproc->fix_perl_include_path(); $eval = $config->get_hook( 'makefml_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -100,7 +100,7 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'makefml_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } if ($len <= 1) { $curproc->help(); @@ -108,7 +108,7 @@ sub verify_request } $eval = $config->get_hook( 'makefml_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -151,10 +151,10 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'makefml_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $eval = $config->get_hook( 'makefml_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -299,7 +299,7 @@ sub _makefml }; my $eval = $config->get_hook( 'makefml_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # here we go require FML::Command; @@ -315,18 +315,18 @@ sub _makefml } else { my $r = $@; - LogError("command $method fail"); - LogError($r); + $curproc->logerror("command $method fail"); + $curproc->logerror($r); if ($r =~ /^(.*)\s+at\s+/) { my $reason = $1; - Log($reason); # pick up reason + $curproc->log($reason); # pick up reason croak($reason); } } } $eval = $config->get_hook( 'makefml_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } diff --git a/fml/lib/FML/Process/Digest.pm b/fml/lib/FML/Process/Digest.pm index 357bab22..c6d7187d 100644 --- a/fml/lib/FML/Process/Digest.pm +++ b/fml/lib/FML/Process/Digest.pm @@ -3,7 +3,7 @@ # Copyright (C) 2002 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Digest.pm,v 1.7 2003/08/23 04:35:38 fukachan Exp $ +# $FML: Digest.pm,v 1.8 2003/08/23 04:43:41 fukachan Exp $ # package FML::Process::Digest; @@ -79,7 +79,7 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'digest_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); @@ -87,12 +87,12 @@ sub prepare $curproc->scheduler_init(); unless ($config->yes('use_digest_program')) { - LogError("use of digest_program prohibited"); + $curproc->logerror("use of digest_program prohibited"); exit(0); } $eval = $config->get_hook( 'digest_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -114,7 +114,7 @@ sub verify_request my $maintainer = $config->{ maintainer }; my $eval = $config->get_hook( 'digest_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # set sender against further errors my $cred = new FML::Credential $curproc; @@ -122,7 +122,7 @@ sub verify_request $curproc->{'credential'}->set( 'sender', $maintainer ); $eval = $config->get_hook( 'digest_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -153,19 +153,19 @@ sub run my $sender = $curproc->{'credential'}->{'sender'}; my $eval = $config->get_hook( 'digest_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->lock(); unless ($curproc->is_refused()) { $curproc->_digest($args); } else { - LogError("ignore this request."); + $curproc->logerror("ignore this request."); } $curproc->unlock(); $eval = $config->get_hook( 'digest_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -210,13 +210,13 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'digest_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->inform_reply_messages(); $curproc->queue_flush(); $eval = $config->get_hook( 'digest_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -248,7 +248,7 @@ sub _digest $digest->set_digest_id($aid); } else { - Log("no articles to send as digest"); + $curproc->log("no articles to send as digest"); } } diff --git a/fml/lib/FML/Process/Distribute.pm b/fml/lib/FML/Process/Distribute.pm index cfe8f121..7c0cdcb2 100644 --- a/fml/lib/FML/Process/Distribute.pm +++ b/fml/lib/FML/Process/Distribute.pm @@ -3,7 +3,7 @@ # Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Distribute.pm,v 1.122 2003/08/23 04:35:39 fukachan Exp $ +# $FML: Distribute.pm,v 1.123 2003/08/23 04:43:41 fukachan Exp $ # package FML::Process::Distribute; @@ -78,7 +78,7 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'distribute_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); @@ -89,12 +89,12 @@ sub prepare $curproc->parse_incoming_message($args); } else { - LogError("use of distribute_program prohibited"); + $curproc->logerror("use of distribute_program prohibited"); exit(0); } $eval = $config->get_hook( 'distribute_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -118,7 +118,7 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'distribute_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->verify_sender_credential(); @@ -131,7 +131,7 @@ sub verify_request } $eval = $config->get_hook( 'distribute_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -156,19 +156,19 @@ sub _check_filter _arg_reason => $r, }; - Log("(debug) filter: inform rejection"); + $curproc->log("(debug) filter: inform rejection"); $filter->article_filter_reject_notice($curproc, $msg_args); } else { - Log("filter: not inform rejection"); + $curproc->log("filter: not inform rejection"); } # we should stop this process ASAP. $curproc->stop_this_process(); - Log("rejected by filter due to $r"); + $curproc->log("rejected by filter due to $r"); } }; - Log($@) if $@; + $curproc->log($@) if $@; } @@ -207,7 +207,7 @@ sub run }; my $eval = $config->get_hook( 'distribute_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # $curproc->lock(); unless ($curproc->is_refused()) { @@ -217,7 +217,7 @@ sub run else { my $pcb = $curproc->{ pcb }; - Log("deny article submission"); + $curproc->log("deny article submission"); my $rule = $pcb->get("check_restrictions", "deny_reason"); if ($rule eq 'reject_system_accounts') { @@ -270,13 +270,13 @@ sub run } } else { - LogError("ignore this request."); + $curproc->logerror("ignore this request."); } # $curproc->unlock(); $eval = $config->get_hook( 'distribute_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -321,13 +321,13 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'distribute_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->inform_reply_messages(); $curproc->queue_flush(); $eval = $config->get_hook( 'distribute_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -363,7 +363,7 @@ sub _distribute # XXX debug, remove here in the future if ($debug) { my $ha_msg = $curproc->{ article }->{ body }->data_type_list; - for my $msg (@$ha_msg) { Log("debug: $msg");} + for my $msg (@$ha_msg) { $curproc->log("debug: $msg");} } # thread system checks the message before header rewritings. @@ -390,7 +390,7 @@ sub _distribute $curproc->_deliver_article($args); if ($config->yes('use_html_archive')) { - Log("htmlify article $id"); + $curproc->log("htmlify article $id"); $curproc->_htmlify($args); } } @@ -427,7 +427,7 @@ sub _header_rewrite my $id = $args->{ id }; for my $rule (@$rules) { - Log("_header_rewrite( $rule )") if $config->yes('debug'); + $curproc->log("_header_rewrite( $rule )") if $config->yes('debug'); if ($header->can($rule)) { # See FML::Header and FML::Header::* $header->$rule($config, { # for methods themself @@ -436,7 +436,7 @@ sub _header_rewrite }); } else { - LogError("header->$rule is undefined"); + $curproc->logerror("header->$rule is undefined"); } } } @@ -456,18 +456,18 @@ sub _deliver_article my $body = $curproc->article_message_body(); # Mail::Message object unless ( $config->yes( 'use_article_delivery' ) ) { - Log("not delivery (\$use_article_delivery = no)"); + $curproc->log("not delivery (\$use_article_delivery = no)"); return; } # SMTP-FROM is a must! unless ( $config->{'maintainer'} ) { - Log("not delivery for undefined \$maintainer"); + $curproc->log("not delivery for undefined \$maintainer"); return; } # distribute article - my $fp = sub { Log(@_);}; # pointer to the log function + my $fp = sub { $curproc->log(@_);}; # pointer to the log function my $sfp = sub { my ($s) = @_; print $s; print "\n" if $s !~ /\n$/o;}; my $handle = undef; @@ -490,7 +490,7 @@ sub _deliver_article }; croak($@) if $@; - if ($service->error) { Log($service->error); return;} + if ($service->error) { $curproc->log($service->error); return;} # XXX_LOCK_CHANNEL: recipient_map_modify my $lock_channel = "recipient_map_modify"; @@ -509,7 +509,7 @@ sub _deliver_article }); $curproc->unlock($lock_channel); - if ($service->error) { Log($service->error); return;} + if ($service->error) { $curproc->log($service->error); return;} } @@ -548,7 +548,7 @@ sub _old_thread_check my $thread = new Mail::ThreadTrack $ttargs; $thread->analyze($msg); }; - Log($@) if $@; + $curproc->log($@) if $@; } @@ -609,17 +609,17 @@ sub _htmlify unless ($@) { unless (-d $html_dir) { $curproc->mkdir($html_dir, "mode=public"); - LogError("fail to mkdir $html_dir") unless -d $html_dir; + $curproc->logerror("fail to mkdir $html_dir") unless -d $html_dir; } eval q{ my $obj = new Mail::Message::ToHTML $_tdb_args; $obj->htmlify_file($article_file, $_tdb_args); }; - LogError($@) if $@; + $curproc->logerror($@) if $@; } else { - LogError($@) if $@; + $curproc->logerror($@) if $@; } $curproc->reset_umask(); diff --git a/fml/lib/FML/Process/DocViewer.pm b/fml/lib/FML/Process/DocViewer.pm index 9ead6935..910f7c1d 100644 --- a/fml/lib/FML/Process/DocViewer.pm +++ b/fml/lib/FML/Process/DocViewer.pm @@ -3,7 +3,7 @@ # Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: DocViewer.pm,v 1.23 2003/01/11 16:05:17 fukachan Exp $ +# $FML: DocViewer.pm,v 1.24 2003/08/23 04:35:39 fukachan Exp $ # package FML::Process::DocViewer; @@ -78,14 +78,14 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmldoc_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $eval = $config->get_hook( 'fmldoc_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -101,7 +101,7 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmldoc_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } if (length(@$argv) == 0) { $curproc->help(); @@ -109,7 +109,7 @@ sub verify_request } $eval = $config->get_hook( 'fmldoc_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -149,7 +149,7 @@ sub _fmldoc my $argv = $curproc->command_line_argv(); my $eval = $config->get_hook( 'fmldoc_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } my (@opts); push(@opts, '-v') if $args->{ options }->{ v }; @@ -167,7 +167,7 @@ sub _fmldoc croak($@); $eval = $config->get_hook( 'fmldoc_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -219,10 +219,10 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmldoc_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $eval = $config->get_hook( 'fmldoc_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } diff --git a/fml/lib/FML/Process/Error.pm b/fml/lib/FML/Process/Error.pm index 855a9012..d71a32da 100644 --- a/fml/lib/FML/Process/Error.pm +++ b/fml/lib/FML/Process/Error.pm @@ -3,7 +3,7 @@ # Copyright (C) 2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: Error.pm,v 1.31 2003/05/03 03:23:43 fukachan Exp $ +# $FML: Error.pm,v 1.32 2003/08/23 04:35:39 fukachan Exp $ # package FML::Process::Error; @@ -74,7 +74,7 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'error_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); @@ -89,7 +89,7 @@ sub prepare } $eval = $config->get_hook( 'error_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -111,7 +111,7 @@ sub verify_request my $maintainer = $config->{ maintainer }; my $eval = $config->get_hook( 'error_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # set dummy sender to avoid unexpected error use FML::Credential; @@ -120,7 +120,7 @@ sub verify_request $curproc->{'credential'}->set( 'sender', $maintainer ); $eval = $config->get_hook( 'error_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -151,7 +151,7 @@ sub run my $msg = $curproc->incoming_message(); my $eval = $config->get_hook( 'error_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->_forward_error_message(); @@ -170,9 +170,9 @@ sub run my $reason = $bouncer->reason( $address ); if ($address) { - Log("bounced: address=<$address>"); - Log("bounced: status=$status"); - Log("bounced: reason=\"$reason\""); + $curproc->log("bounced: address=<$address>"); + $curproc->log("bounced: status=$status"); + $curproc->log("bounced: reason=\"$reason\""); $error->add({ address => $address, @@ -186,7 +186,7 @@ sub run $error->db_close(); }; - LogError($@) if $@; + $curproc->logerror($@) if $@; if ($found) { $pcb->set("error", "found", 1); @@ -195,7 +195,7 @@ sub run } $eval = $config->get_hook( 'error_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -210,7 +210,7 @@ sub _clean_up_bouncers my $channel = 'erroranalyzer'; if ($curproc->is_event_timeout($channel)) { - Log("(debug) event timeout"); + $curproc->log("(debug) event timeout"); eval q{ use FML::Error; @@ -218,12 +218,12 @@ sub _clean_up_bouncers $error->analyze(); $error->remove_bouncers(); }; - LogError($@) if $@; + $curproc->logerror($@) if $@; $curproc->set_event_timeout($channel, time + 3600); } else { - Log("(debug) event not timeout"); + $curproc->log("(debug) event not timeout"); } } @@ -271,21 +271,21 @@ sub finish my $pcb = $curproc->{ pcb }; my $eval = $config->get_hook( 'error_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } if ($pcb->get("error", "found")) { - Log("error message found"); + $curproc->log("error message found"); # inform ? } else { - Log("error message not found"); + $curproc->log("error message not found"); } $curproc->inform_reply_messages(); $curproc->queue_flush(); $eval = $config->get_hook( 'error_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } diff --git a/fml/lib/FML/Process/HTMLify.pm b/fml/lib/FML/Process/HTMLify.pm index 5c8b83fd..53c280c9 100644 --- a/fml/lib/FML/Process/HTMLify.pm +++ b/fml/lib/FML/Process/HTMLify.pm @@ -3,7 +3,7 @@ # Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: HTMLify.pm,v 1.27 2003/01/11 16:05:19 fukachan Exp $ +# $FML: HTMLify.pm,v 1.28 2003/08/23 04:35:39 fukachan Exp $ # package FML::Process::HTMLify; @@ -69,14 +69,14 @@ sub prepare my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlhtmlify_prepare_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $eval = $config->get_hook( 'fmlhtmlify_prepare_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -90,10 +90,10 @@ sub verify_request my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlhtmlify_verify_request_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $eval = $config->get_hook( 'fmlhtmlify_verify_request_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -120,7 +120,7 @@ sub run print STDERR "htmlify\n\t$src_dir =>\n\t$dst_dir\n" if $debug; my $eval = $config->get_hook( 'fmlhtmlify_run_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } # prepend $opt_I as @INC if (defined $options->{ I }) { @@ -136,7 +136,7 @@ sub run }); $eval = $config->get_hook( 'fmlhtmlify_run_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } @@ -171,10 +171,10 @@ sub finish my $config = $curproc->{ config }; my $eval = $config->get_hook( 'fmlhtmlify_finish_start_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } $eval = $config->get_hook( 'fmlhtmlify_finish_end_hook' ); - if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; } + if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } } diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm index bde2e54a..ff4d3193 100644 --- a/fml/lib/FML/Process/Kernel.pm +++ b/fml/lib/FML/Process/Kernel.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Kernel.pm,v 1.173 2003/08/23 04:35:39 fukachan Exp $ +# $FML: Kernel.pm,v 1.174 2003/08/23 05:29:01 fukachan Exp $ # package FML::Process::Kernel; @@ -175,7 +175,7 @@ sub _signal_init $SIG{'ALRM'} = $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = sub { my ($signal) = @_; - Log("SIG$signal trapped"); + $curproc->log("SIG$signal trapped"); sleep 1; croak("SIG$signal trapped"); }; @@ -272,7 +272,7 @@ sub lock if (defined $LockInfo{ $channel } && $LockInfo{ $channel }) { my @c = caller; - LogWarn( "channel=$channel already locked ($c[0] $c[1])" ); + $curproc->logwarn( "channel=$channel already locked ($c[0] $c[1])" ); return; } @@ -286,15 +286,15 @@ sub lock if ($r) { my $t = time - $time_in; if ($t > 1) { - Log("lock requires $t sec."); + $curproc->log("lock requires $t sec."); } $pcb->set('lock', $channel, $lockobj); $LockInfo{ $channel } = 1; - Log("lock channel=$channel"); + $curproc->log("lock channel=$channel"); } else { - LogError("cannot lock"); + $curproc->logerror("cannot lock"); croak("Error: cannot lock"); } } @@ -321,19 +321,19 @@ sub unlock if ($r) { my $t = time - $time_in; if ($t > 1) { - Log("unlock requires $t sec."); + $curproc->log("unlock requires $t sec."); } delete $LockInfo{ $channel }; - Log("unlock channel=$channel"); + $curproc->log("unlock channel=$channel"); } else { - LogError("cannot unlock"); + $curproc->logerror("cannot unlock"); croak("Error: cannot unlock"); } } else { - LogError("object undefined, cannot unlock"); + $curproc->logerror("object undefined, cannot unlock"); croak("Error: object undefined, cannot unlock"); } } @@ -401,7 +401,7 @@ sub is_event_timeout return (time > $t) ? 1 : 0; } else { - LogWarn("visit timeout channel=$channel at the first time"); + $curproc->logwarn("visit timeout channel=$channel at the first time"); return 1; } } @@ -508,23 +508,23 @@ sub verify_sender_credential } else { $curproc->stop_this_process("cannot extract From:"); - LogError("cannot extract From:"); + $curproc->logerror("cannot extract From:"); } # XXX "@addrs must be empty" is valid since From: is unique. if (@addrs) { - LogWarn("invalid From: duplicated addresses"); - LogWarn("use $from as the sender"); + $curproc->logwarn("invalid From: duplicated addresses"); + $curproc->logwarn("use $from as the sender"); my $i = 0; for my $a ($addr, @addrs) { my $s = $a->address; ++$i; - LogWarn("From[$i] $s"); + $curproc->logwarn("From[$i] $s"); } } if ($from) { - Log("sender: $from"); + $curproc->log("sender: $from"); # check $from should match safe address regexp. use FML::Restriction::Base; @@ -538,12 +538,12 @@ sub verify_sender_credential } else { $curproc->stop_this_process(); - LogError("unsafe From: $from"); + $curproc->logerror("unsafe From: $from"); } } else { $curproc->stop_this_process(); - LogError("no valid From:"); + $curproc->logerror("no valid From:"); } } @@ -575,7 +575,7 @@ sub simple_loop_check $match = $header->$rule($config, $args) ? $rule : 0; } else { - Log("header->${rule}() is undefined"); + $curproc->log("header->${rule}() is undefined"); } last RULE if $match; @@ -584,7 +584,7 @@ sub simple_loop_check if ($match) { # we should stop this process ASAP. $curproc->stop_this_process(); - LogError("mail loop detected for $match"); + $curproc->logerror("mail loop detected for $match"); } } @@ -721,7 +721,7 @@ sub resolve_ml_specific_variables # parse the argument such as "fml.pl /var/spool/ml/elena ..." unless ($ml_name) { - Log("(debug) parse @ARGV"); + $curproc->log("(debug) parse @ARGV"); ARGS: for my $arg (@ARGV) { @@ -740,7 +740,7 @@ sub resolve_ml_specific_variables $config->set( 'ml_domain', $default_domain ); $config->set( 'ml_home_dir', $arg ); - Log("(debug) ml_name=$ml_name ml_home_dir=$ml_home_dir"); + $curproc->log("(debug) ml_name=$ml_name ml_home_dir=$ml_home_dir"); } } } @@ -768,11 +768,11 @@ sub __debug_ml_xxx my $config = $curproc->{ config }; if (defined $config->{ log_file } && (-w $config->{ log_file })) { - for my $buf (@delayed_buffer) { Log( $buf ); } + for my $buf (@delayed_buffer) { $curproc->log( $buf ); } @delayed_buffer = (); for my $var (qw(ml_name ml_domain ml_home_prefix ml_home_dir)) { - Log(sprintf("%-25s = %s", '(debug)'.$str. $var, + $curproc->log(sprintf("%-25s = %s", '(debug)'.$str. $var, (defined $config->{ $var } ? $config->{ $var } : ''))); } } @@ -873,7 +873,7 @@ sub load_config_files use FML::Credential; my $cred = new FML::Credential $curproc; if ($cred->is_same_address($maintainer, $ml_address)) { - LogError("invalid configuration: \$maintainer == \$address_for_post"); + $curproc->logerror("invalid configuration: \$maintainer == \$address_for_post"); $curproc->stop_this_process("configuration error"); } } @@ -1021,11 +1021,11 @@ sub _check_restrictions } else { ($match, $result) = (0, undef); - LogWarn("unknown rule=$rule"); + $curproc->logwarn("unknown rule=$rule"); } if ($match) { - Log("match rule=$rule sender=$sender"); + $curproc->log("match rule=$rule sender=$sender"); return($result eq "permit" ? 1 : 0); } } @@ -1109,6 +1109,98 @@ sub close_stderr_channel_if_quiet_option_specified =head1 MESSAGE HANDLING +=head2 log_message($msg, $msg_args) + +? + log(STR) log_message(STR, { level => "ok" }) + logwarn(STR) log_message(STR, { level => "warning" }) + logerror(STR) log_message(STR, { level => "error" }) + +=head2 log($msg, $msg_args) + +=head2 logwarn($msg, $msg_args) + +=head2 logerror($msg, $msg_args) + +=cut + + +# Descriptions: log message +# Arguments: OBJ($curproc) STR($msg) HASH_REF($msg_args) +# Side Effects: none +# Return Value: none +sub log_message +{ + my ($curproc, $msg, $msg_args) = @_; + my $_msg_args = $msg_args->{ msg_args }; + my $level = $msg_args->{ level }; + my $at_package = $msg_args->{ caller }->[ 0 ]; + my $at_function = $msg_args->{ caller }->[ 1 ]; + my $at_line = $msg_args->{ caller }->[ 2 ]; + + if ($level eq 'ok') { + Log($msg); + } + elsif ($level eq 'warning') { + LogWarn($msg); + } + elsif ($level eq 'error') { + LogError($msg); + } +} + + +# Descriptions: log message +# Arguments: OBJ($curproc) STR($msg) HASH_REF($msg_args) +# Side Effects: none +# Return Value: none +sub log +{ + my ($curproc, $msg, $msg_args) = @_; + my (@c) = caller; + + $curproc->log_message($msg, { + msg_args => $msg_args, + level => 'ok', + caller => \@c, + }); +} + + +# Descriptions: log message as warning. +# Arguments: OBJ($curproc) STR($msg) HASH_REF($msg_args) +# Side Effects: none +# Return Value: none +sub logwarn +{ + my ($curproc, $msg, $msg_args) = @_; + my (@c) = caller; + + $curproc->log_message($msg, { + msg_args => $msg_args, + level => 'warning', + caller => \@c, + }); +} + + +# Descriptions: log message as error. +# Arguments: OBJ($curproc) STR($msg) HASH_REF($msg_args) +# Side Effects: none +# Return Value: none +sub logerror +{ + my ($curproc, $msg, $msg_args) = @_; + my (@c) = caller; + + $curproc->log_message($msg, { + msg_args => $msg_args, + level => 'error', + caller => \@c, + }); +} + + =head2 reply_message($msg) C<reply_message($msg)> holds message C<$msg> sent back to the mail @@ -1159,7 +1251,7 @@ sub reply_message if ($myname eq 'makefml' || $myname eq 'fml' || $myname =~ /\.cgi$/) { - LogWarn("(debug) $myname disables reply_message()"); + $curproc->logwarn("(debug) $myname disables reply_message()"); return; } @@ -1191,7 +1283,7 @@ sub reply_message } if (_array_is_different($sent, $recipient)) { - Log("cc: [ @$recipient ]"); + $curproc->log("cc: [ @$recipient ]"); $curproc->_append_message_into_queue($msg, $args, $recipient, $recipient_maps, $hdr); @@ -1221,7 +1313,7 @@ sub _analyze_recipients $recipient = [ $rcpt ] if $rcpt; } else { - LogError("reply_message: wrong type recipient"); + $curproc->logerror("reply_message: wrong type recipient"); } } @@ -1230,7 +1322,7 @@ sub _analyze_recipients $recipient_maps = [ $map ] if $map; } else { - LogError("reply_message: wrong type recipient_map"); + $curproc->logerror("reply_message: wrong type recipient_map"); } } @@ -1239,7 +1331,7 @@ sub _analyze_recipients $recipient_maps = $maps if @$maps; } else { - LogError("reply_message: wrong type recipient_maps"); + $curproc->logerror("reply_message: wrong type recipient_maps"); } } @@ -1374,7 +1466,7 @@ sub _reply_message_recipient_keys $rcptlist = $m->{ recipient }; $rcptmaps = $m->{ recipient_maps }; $type = ref($m->{ message }); - $key = _gen_recipient_key( $rcptlist, $rcptmaps ); + $key = $curproc->_gen_recipient_key( $rcptlist, $rcptmaps ); $rcptattr{ $key }->{ $type }++; $rcptlist{ $key } = $rcptlist; $rcptmaps{ $key } = $rcptmaps; @@ -1392,7 +1484,7 @@ sub _reply_message_recipient_keys # Return Value: STR sub _gen_recipient_key { - my ($rarray, $rmaps) = @_; + my ($curproc, $rarray, $rmaps) = @_; my (@c) = caller; my $key = ''; @@ -1403,7 +1495,7 @@ sub _gen_recipient_key } } else { - LogError("wrong \$rarray"); + $curproc->logerror("wrong \$rarray"); } } @@ -1414,7 +1506,7 @@ sub _gen_recipient_key } } else { - LogError("wrong \$rmaps"); + $curproc->logerror("wrong \$rmaps"); } } @@ -1462,7 +1554,7 @@ sub reply_message_nl my $obj = new Mail::Message::Encode; $curproc->reply_message( $obj->convert( $buf, 'jis-jp' ), $args); }; - LogError($@) if $@; + $curproc->logerror($@) if $@; } else { $curproc->reply_message($default_msg, $args); @@ -1519,7 +1611,7 @@ sub message_nl } } else { - LogWarn("no such file: $file"); + $curproc->logwarn("no such file: $file"); } return $buf; @@ -1533,7 +1625,7 @@ sub message_nl sub caller_info { my ($curproc, $msg, $pkg, $fn, $line) = @_; - Log("msg='$msg' $fn $line"); + $curproc->log("msg='$msg' $fn $line"); } @@ -1670,10 +1762,10 @@ sub queue_in } - Log("debug: queue_in: sender=$sender"); - Log("debug: queue_in: recipient=$rcptkey"); - Log("debug: queue_in: rcptlist=[ @$rcptlist ]"); - Log("debug: queue_in: is_multipart=$is_multipart"); + $curproc->log("debug: queue_in: sender=$sender"); + $curproc->log("debug: queue_in: recipient=$rcptkey"); + $curproc->log("debug: queue_in: rcptlist=[ @$rcptlist ]"); + $curproc->log("debug: queue_in: is_multipart=$is_multipart"); ############################################################### @@ -1706,8 +1798,8 @@ sub queue_in for my $m ( @$mesg_queue ) { my $q = $m->{ message }; my $t = $m->{ type }; - my $r = _gen_recipient_key($m->{ recipient }, - $m->{ recipient_maps } ); + my $r = $curproc->_gen_recipient_key($m->{ recipient }, + $m->{ recipient_maps } ); # pick up only messages returned to specified $rcptkey next QUEUE unless $r eq $rcptkey; @@ -1730,8 +1822,8 @@ sub queue_in for my $m ( @$mesg_queue ) { my $q = $m->{ message }; my $t = $m->{ type }; - my $r = _gen_recipient_key($m->{ recipient }, - $m->{ recipient_maps } ); + my $r = $curproc->_gen_recipient_key($m->{ recipient }, + $m->{ recipient_maps } ); next QUEUE unless $r eq $rcptkey; @@ -1746,8 +1838,8 @@ sub queue_in Disposition => $q->{ disposition }); } else { - # Log("queue_in: type=<$t> aggregated") if $t eq 'text'; - Log("queue_in: unknown type=<$t>") unless $t eq 'text'; + # $curproc->log("queue_in: type=<$t> aggregated") if $t eq 'text'; + $curproc->log("queue_in: unknown type=<$t>") unless $t eq 'text'; } } } @@ -1762,8 +1854,8 @@ sub queue_in for my $m ( @$mesg_queue ) { my $q = $m->{ message }; my $t = $m->{ type }; - my $r = _gen_recipient_key($m->{ recipient }, - $m->{ recipient_maps }); + my $r = $curproc->_gen_recipient_key($m->{ recipient }, + $m->{ recipient_maps }); next QUEUE unless $r eq $rcptkey; @@ -1775,7 +1867,7 @@ sub queue_in $s .= $q; } else { - Log("queue_in: unknown typ $t"); + $curproc->log("queue_in: unknown typ $t"); } } } @@ -1820,12 +1912,12 @@ sub queue_in $queue->set('recipient_maps', $rcptmaps); } - $queue->in( $msg ) && Log("queue=$qid in"); + $queue->in( $msg ) && $curproc->log("queue=$qid in"); if ($queue->setrunnable()) { - Log("queue=$qid runnable"); + $curproc->log("queue=$qid runnable"); } else { - Log("queue=$qid broken"); + $curproc->log("queue=$qid broken"); } # return queue object @@ -1853,7 +1945,7 @@ sub _append_rfc822_message $wh->close; } else { - LogError("_append_rfc822_message: cannot create \$tmpfile"); + $curproc->logerror("_append_rfc822_message: cannot create \$tmpfile"); } if (-f $tmpfile) { @@ -1866,13 +1958,13 @@ sub _append_rfc822_message $rh->close; } else { - LogError("_append_rfc822_message: cannot open \$tmpfile"); + $curproc->logerror("_append_rfc822_message: cannot open \$tmpfile"); } $curproc->add_into_clean_up_queue( $tmpfile ); } else { - LogError("_append_rfc822_message: \$tmpfile not found"); + $curproc->logerror("_append_rfc822_message: \$tmpfile not found"); } } @@ -1906,7 +1998,7 @@ sub clean_up_tmpfiles if (defined $queue) { for my $q (@$queue) { - Log("unlink $q") if $debug; + $curproc->log("unlink $q") if $debug; unlink $q; } } @@ -2041,7 +2133,7 @@ sub prepare_file_to_return } } else { - LogError("Mail::Message::Encode object undef"); + $curproc->logerror("Mail::Message::Encode object undef"); } close($wh); @@ -2158,13 +2250,13 @@ sub finalize my $debug = $curproc->debug_level(); if ($debug > 100) { - Log("debug: dump curproc structure"); + $curproc->log("debug: dump curproc structure"); eval q{ use FML::Process::Debug; my $obj = new FML::Process::Debug; $obj->dump_curproc($curproc); }; - LogError($@) if $@; + $curproc->logerror($@) if $@; } } diff --git a/fml/lib/FML/Process/QMail.pm b/fml/lib/FML/Process/QMail.pm index 89e0e50f..2d839638 100644 --- a/fml/lib/FML/Process/QMail.pm +++ b/fml/lib/FML/Process/QMail.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: QMail.pm,v 1.14 2002/09/22 14:56:53 fukachan Exp $ +# $FML: QMail.pm,v 1.15 2002/12/18 04:43:52 fukachan Exp $ # package FML::Process::QMail; @@ -73,11 +73,11 @@ sub DotQmailExt my $ext = $ENV{'EXT'}; unless ($ext) { - Log("no extension address"); + $curproc->log("no extension address"); return; } - &Log("dot-qmail-ext[0]: $ext"); + &$curproc->log("dot-qmail-ext[0]: $ext"); my ($key) = (split(/\@/, $config->{ address_for_post }))[0]; my ($keyctl) = (split(/\@/, $config->{ address_for_command }))[0]; @@ -88,12 +88,12 @@ sub DotQmailExt return ''; } - &Log("dot-qmail-ext: $ext"); + &$curproc->log("dot-qmail-ext: $ext"); $ext =~ s/^$key//i; $ext =~ s/\-\-/\@/i; # since @ cannot be used $ext =~ s/\-/ /g; $ext =~ s/\@/-/g; - &Log("\$ext -> $ext"); + &$curproc->log("\$ext -> $ext"); # XXX: "# command" is internal represention return sprintf("# %s", $ext); diff --git a/fml/lib/FML/Process/QueueManager.pm b/fml/lib/FML/Process/QueueManager.pm index 21e75149..65fe87df 100644 --- a/fml/lib/FML/Process/QueueManager.pm +++ b/fml/lib/FML/Process/QueueManager.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: QueueManager.pm,v 1.12 2003/03/18 10:38:33 fukachan Exp $ +# $FML: QueueManager.pm,v 1.13 2003/08/23 04:35:40 fukachan Exp $ # package FML::Process::QueueManager; @@ -94,12 +94,12 @@ sub send } else { # XXX-TODO: $q->remove() if invalid queue ? - Log("$qid is invalid"); + $curproc->log("$qid is invalid"); } $q->unlock(); } else { - Log("$qid is locked. retry"); + $curproc->log("$qid is locked. retry"); } } } @@ -132,10 +132,10 @@ sub _send }); if ($r) { - Log("queue=$qid status=sent"); + $curproc->log("queue=$qid status=sent"); } else { - Log("queue=$qid status=fail"); + $curproc->log("queue=$qid status=fail"); } return $r; diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm index 3a5c50b3..20c73b2c 100644 --- a/fml/lib/FML/Process/Utils.pm +++ b/fml/lib/FML/Process/Utils.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Utils.pm,v 1.70 2003/08/14 13:43:08 tmu Exp $ +# $FML: Utils.pm,v 1.71 2003/08/20 23:40:29 fukachan Exp $ # package FML::Process::Utils; @@ -213,7 +213,7 @@ sub article_message_header return $curproc->{ article }->{ header }; } else { - LogError("\$curproc->{ article }->{ header } not defined"); + $curproc->logerror("\$curproc->{ article }->{ header } not defined"); return undef; } } @@ -231,7 +231,7 @@ sub article_message_body return $curproc->{ article }->{ body }; } else { - LogError("\$curproc->{ article }->{ body } not defined"); + $curproc->logerror("\$curproc->{ article }->{ body } not defined"); return undef; } } @@ -249,7 +249,7 @@ sub article_message return $curproc->{ article }->{ message }; } else { - LogError("\$curproc->{ article }->{ message } not defined"); + $curproc->logerror("\$curproc->{ article }->{ message } not defined"); return undef; } } @@ -294,18 +294,18 @@ sub mkdir _mkpath_str($dir, $config->{ $xmode }); } else { - LogError("mkdir: invalid mode"); + $curproc->logerror("mkdir: invalid mode"); } } else { - LogError("mkdir: invalid mode"); + $curproc->logerror("mkdir: invalid mode"); } } elsif ($dirmode =~ /^\d+$/) { # STR 0700 _mkpath_str($dir, $dirmode); } else { - LogError("mkdir: invalid mode"); + $curproc->logerror("mkdir: invalid mode"); } } @@ -1130,7 +1130,7 @@ sub convert_to_mail_address push(@$result, $sender); } else { - LogError("unknown recipient type $rcpt"); + $curproc->logerror("unknown recipient type $rcpt"); } } |
