diff options
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/etc/src/config.cf.ja/log.cf | 20 | ||||
| -rw-r--r-- | fml/lib/FML/Log/Print/Simple.pm | 101 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Command.pm | 3 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Configure.pm | 3 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Distribute.pm | 3 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Error.pm | 3 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Kernel.pm | 63 |
7 files changed, 165 insertions, 31 deletions
diff --git a/fml/etc/src/config.cf.ja/log.cf b/fml/etc/src/config.cf.ja/log.cf index 238aa447..d3f00abd 100644 --- a/fml/etc/src/config.cf.ja/log.cf +++ b/fml/etc/src/config.cf.ja/log.cf @@ -70,3 +70,23 @@ log_file_charset_en = us-ascii # Value: filename # Examples: /var/spool/ml/@log@ domain_local_log_file = $domain_local_dir/@log@ + + +=head2 makefml や fml で詳細なログを STDERR などへ出力したい場合 + + +# Descriptions: 機会処理にやさしいフォーマットでログを出力する。 +# コマンドラインオプションで --computer-output を指定すると +# use_computer_output = yes と同じ意味になる。 +# History: none +# Value: yes | no +# Examples: no +use_computer_output = no + + +# Descriptions: 機会処理にやさしいフォーマットを出力する際の出力エンジン。 +# perl module を指定する。 +# History: none +# Value: CLASS +# Examples: FML::Log::Print::Simple +computer_output_engine = FML::Log::Print::Simple diff --git a/fml/lib/FML/Log/Print/Simple.pm b/fml/lib/FML/Log/Print/Simple.pm new file mode 100644 index 00000000..9d5ff9b1 --- /dev/null +++ b/fml/lib/FML/Log/Print/Simple.pm @@ -0,0 +1,101 @@ +#-*- perl -*- +# +# Copyright (C) 2003 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $FML: @template.pm,v 1.7 2003/01/01 02:06:22 fukachan Exp $ +# + +package FML::Log::Print::Simple; +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); +use Carp; + +=head1 NAME + +FML::Log::Print::Simple - simplest engine + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=head2 C<new()> + +=cut + + +# Descriptions: constructor. +# Arguments: OBJ($self) HASH_REF($args) +# Side Effects: none +# Return Value: OBJ +sub new +{ + my ($self) = @_; + my ($type) = ref($self) || $self; + my $me = {}; + + use FML::IPC::Queue; + $me->{ _queue } = new FML::IPC::Queue; + + return bless $me, $type; +} + + +# Descriptions: add message to message queue +# Arguments: OBJ($self) OBJ($msg) +# Side Effects: none +# Return Value: none +sub add +{ + my ($self, $msg) = @_; + my $queue = $self->{ _queue }; + $queue->append($msg); +} + + +# Descriptions: output +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: none +sub print +{ + my ($self) = @_; + my $queue = $self->{ _queue }; + my $msg_list = $queue->list(); + my ($buf); + + for my $m (@$msg_list) { + $buf = $m->{ buf } || ''; + $buf =~ s/\n/ /g; + printf "%10d %5s %s\n", $m->{ time }, $m->{ level }, $buf; + } +} + + +=head1 CODING STYLE + +See C<http://www.fml.org/software/FNF/> on fml coding style guide. + +=head1 AUTHOR + +__YOUR_NAME__ + +=head1 COPYRIGHT + +Copyright (C) 2003 __YOUR_NAME__ + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +FML::Log::Print::Simple appeared in fml8 mailing list driver package. +See C<http://www.fml.org/> for more details. + +=cut + + +1; diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm index c7a70506..55633cd7 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.89 2003/08/29 15:34:06 fukachan Exp $ +# $FML: Command.pm,v 1.90 2003/10/17 14:00:51 fukachan Exp $ # package FML::Process::Command; @@ -84,6 +84,7 @@ sub prepare $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $curproc->scheduler_init(); + $curproc->log_message_init(); if ($config->yes('use_command_mail_program')) { $curproc->parse_incoming_message($args); diff --git a/fml/lib/FML/Process/Configure.pm b/fml/lib/FML/Process/Configure.pm index 6bae5807..f641df41 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.56 2003/09/13 13:01:40 fukachan Exp $ +# $FML: Configure.pm,v 1.57 2003/11/16 12:23:48 fukachan Exp $ # package FML::Process::Configure; @@ -80,6 +80,7 @@ sub prepare $curproc->resolve_ml_specific_variables( $args ); $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); + $curproc->log_message_init(); $eval = $config->get_hook( 'makefml_prepare_end_hook' ); if ($eval) { eval qq{ $eval; }; $curproc->logwarn($@) if $@; } diff --git a/fml/lib/FML/Process/Distribute.pm b/fml/lib/FML/Process/Distribute.pm index 22fe7f44..3a1d7295 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.127 2003/10/06 10:42:18 fukachan Exp $ +# $FML: Distribute.pm,v 1.128 2003/10/15 01:03:33 fukachan Exp $ # package FML::Process::Distribute; @@ -84,6 +84,7 @@ sub prepare $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $curproc->scheduler_init(); + $curproc->log_message_init(); if ($config->yes('use_distribute_program')) { $curproc->parse_incoming_message($args); diff --git a/fml/lib/FML/Process/Error.pm b/fml/lib/FML/Process/Error.pm index aae15a2e..c65e7b24 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.33 2003/08/23 07:24:47 fukachan Exp $ +# $FML: Error.pm,v 1.34 2003/08/29 15:34:08 fukachan Exp $ # package FML::Process::Error; @@ -80,6 +80,7 @@ sub prepare $curproc->load_config_files( $args->{ cf_list } ); $curproc->fix_perl_include_path(); $curproc->scheduler_init(); + $curproc->log_message_init(); if ($config->yes('use_error_analyzer_program')) { $curproc->parse_incoming_message($args); diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm index 203e1137..25a826f3 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.192 2003/11/05 03:37:52 fukachan Exp $ +# $FML: Kernel.pm,v 1.193 2003/11/29 08:18:20 fukachan Exp $ # package FML::Process::Kernel; @@ -106,8 +106,8 @@ sub new primary_ml_home_prefix_map ml_home_prefix_maps default_config_cf - site_default_config_cf - + site_default_config_cf + )) { if (defined $args->{ main_cf }->{ $main_cf_var }) { my $key = sprintf("fml_%s", $main_cf_var); @@ -117,7 +117,7 @@ sub new # 1.3 import $fml_version if (defined $args->{ fml_version }) { - $cfargs->{ fml_version } = + $cfargs->{ fml_version } = sprintf("fml-devel %s", $args->{ fml_version }); } @@ -154,8 +154,8 @@ sub new # 3.6 default printing style $curproc->_print_init; - # 3.7 set up message queue for logging. - $curproc->_log_message_init(); + # 3.7 set up message queue for logging. (moved to each program) + # $curproc->_log_message_init(); # 4.1 debug. XXX remove this in the future ! $curproc->__debug_ml_xxx('loaded:'); @@ -1129,7 +1129,11 @@ sub is_refused } -=head1 MESSAGE HANDLING +=head1 LOG MESSAGE HANDLING + +=head2 log_message_init() + +initialize log message queue. =cut @@ -1138,13 +1142,25 @@ sub is_refused # Arguments: OBJ($curproc) # Side Effects: set up $curproc->{ log_message_queue }. # Return Value: none -sub _log_message_init +sub log_message_init { my ($curproc) = @_; + my $config = $curproc->config(); + my $module = $config->{ computer_output_engine }; + my $obj = undef; - use FML::IPC::Queue; - my $queue = new FML::IPC::Queue; - $curproc->{ log_message_queue } = $queue; + eval qq{ + use $module; + \$obj = new $module; + }; + $curproc->logerror($@) if $@; + + if (defined $obj) { + $curproc->{ log_message_queue } = $obj; + } + else { + $curproc->logerror("fail to create computer_output_engine object"); + } } @@ -1152,13 +1168,12 @@ sub _log_message_init # Arguments: OBJ($curproc) HASH_REF($msg) # Side Effects: update message queue. # Return Value: none -sub _msg_queue_append +sub _log_message_queue_append { my ($curproc, $msg) = @_; my $msg_queue = $curproc->{ log_message_queue }; - $msg->{ time } = time; - $msg_queue->append($msg); + $msg_queue->add($msg); } @@ -1170,14 +1185,7 @@ sub _log_message_print { my ($curproc) = @_; my $msg_queue = $curproc->{ log_message_queue }; - my $msg_list = $msg_queue->list(); - my ($buf); - - for my $m (@$msg_list) { - $buf = $m->{ buf } || ''; - $buf =~ s/\n/ /g; - printf "%10d %5s %s\n", $m->{ time }, $m->{ level }, $buf; - } + $msg_queue->print(); } @@ -1221,7 +1229,7 @@ sub log_message } # update message queue - $curproc->_msg_queue_append({ + $curproc->_log_message_queue_append({ buf => $msg, level => $level, hints => { @@ -2357,7 +2365,7 @@ sub _reopen_stderr_channel $curproc->is_under_mta_process() || defined $option->{ quiet } || defined $option->{ q } || $config->yes('use_log_dup') || $option->{ 'log-dup' } || - $option->{ 'computer-output' } ) { + $config->yes('use_computer_output') || $option->{'computer-output'}) { my $tmpfile = $curproc->temp_file_path(); my $pcb = $curproc->pcb(); $pcb->set("stderr", "logfile", $tmpfile); @@ -2391,7 +2399,8 @@ sub _finalize_stderr_channel $curproc->is_under_mta_process() || defined $option->{ quiet } || defined $option->{ q } || $config->yes('use_log_dup') || $option->{ 'log-dup' } || - $option->{ 'computer-output' } ) { + $config->yes('use_computer_output') || + $option->{'computer-output'}) { close(STDERR); open(STDERR, ">&STDOUT"); @@ -2467,7 +2476,7 @@ sub be_quiet $curproc->is_under_mta_process() || defined $option->{ quiet } || defined $option->{ q } || $config->yes('use_log_dup') || $option->{ 'log-dup' } || - $option->{ 'computer-output' } ) { + $config->yes('use_computer_output') || $option->{'computer-output'}) { return 1; } else { @@ -2488,7 +2497,7 @@ sub finalize my $option = $curproc->command_line_options(); if ($config->yes('use_log_dup') || $option->{ 'log-dup' } || - $option->{ 'computer-output' } ) { + $config->yes('use_computer_output') || $option->{'computer-output'}) { $curproc->_finalize_stderr_channel(); $curproc->_log_message_print(); } |
