diff options
| author | fukachan <fukachan> | 2003-11-29 10:24:25 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-11-29 10:24:25 +0000 |
| commit | a517d42e33120b4c11981a75b4b57fc9432c8f3f (patch) | |
| tree | 3e05f29969ddebe94fa5c67fee2c3a198284e3f8 /fml/lib/FML/Process | |
| parent | 356b1008cdfe81d2345aca1ee51a3b3132c98086 (diff) | |
| download | fml8-a517d42e33120b4c11981a75b4b57fc9432c8f3f.tar.gz fml8-a517d42e33120b4c11981a75b4b57fc9432c8f3f.tar.bz2 fml8-a517d42e33120b4c11981a75b4b57fc9432c8f3f.zip | |
define $use_computer_output.
modify FML::Process::* to use it.
FML::Process::Kernel supports customization by $computer_output_engine
definition.
$curproc->log_message_init() is called within prepare() method of each
program.
Diffstat (limited to 'fml/lib/FML/Process')
| -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 |
5 files changed, 44 insertions, 31 deletions
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(); } |
