summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-01-01 08:43:32 +0000
committerfukachan <fukachan>2004-01-01 08:43:32 +0000
commita087923f9f568d39f47415027aa775e5a3dcdb68 (patch)
tree7bda7b0a08e8683981931544e7a4bddc9353adf5 /fml/lib
parent33628571d7e1ba9434deb08387eb6969af2c9537 (diff)
downloadfml8-a087923f9f568d39f47415027aa775e5a3dcdb68.tar.gz
fml8-a087923f9f568d39f47415027aa775e5a3dcdb68.tar.bz2
fml8-a087923f9f568d39f47415027aa775e5a3dcdb68.zip
clean up.
use more proper variable names. change _show_log() to take $curproc as argv.
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Command/Admin/log.pm39
1 files changed, 17 insertions, 22 deletions
diff --git a/fml/lib/FML/Command/Admin/log.pm b/fml/lib/FML/Command/Admin/log.pm
index 89580351..1a26e81d 100644
--- a/fml/lib/FML/Command/Admin/log.pm
+++ b/fml/lib/FML/Command/Admin/log.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: log.pm,v 1.20 2003/10/15 08:16:24 fukachan Exp $
+# $FML: log.pm,v 1.21 2003/10/18 06:50:29 fukachan Exp $
#
package FML::Command::Admin::log;
@@ -61,15 +61,10 @@ sub process
my ($self, $curproc, $command_args) = @_;
my $config = $curproc->config();
my $log_file = $config->{ log_file };
- my $options = $command_args->{ options };
- my $address = $command_args->{ command_data } || $options->[ 0 ];
-
- # XXX-TODO: we should provide $curproc->util->get_print_style() ?
- my $style = $curproc->get_print_style();
if (-f $log_file) {
- $self->{ _curproc } = $curproc;
- $self->_show_log($log_file, { printing_style => $style });
+ my $style = $curproc->get_print_style();
+ $self->_show_log($curproc, $log_file, { printing_style => $style });
}
}
@@ -84,43 +79,43 @@ sub cgi_menu
my ($self, $curproc, $args, $command_args) = @_;
my $config = $curproc->config();
my $log_file = $config->{ log_file };
- my $style = $curproc->get_print_style();
if (-f $log_file) {
- $self->{ _curproc } = $curproc;
- $self->_show_log($log_file, { printing_style => $style });
+ my $style = $curproc->get_print_style();
+ $self->_show_log($curproc, $log_file, { printing_style => $style });
}
}
# Descriptions: show log file.
-# Arguments: OBJ($self) STR($log_file) HASH_REF($args)
+# Arguments: OBJ($self) OBJ($curproc) STR($log_file) HASH_REF($sl_args)
# Side Effects: none
# Return Value: none
sub _show_log
{
- my ($self, $log_file, $args) = @_;
- my $is_cgi = 1 if $args->{ printing_style } eq 'html';
+ my ($self, $curproc, $log_file, $sl_args) = @_;
+ my $is_cgi = 1 if $sl_args->{ printing_style } eq 'html';
+
+ # XXX-TODO: $last_n_lines should be customizable.
my $last_n_lines = 30;
- my $linecount = 0;
- my $maxline = 0;
- my $curproc = $self->{ _curproc };
+ my $line_count = 0;
+ my $line_max = 0;
my $charset = $curproc->get_charset($is_cgi ? "cgi" : "log_file");
use Mail::Message::Encode;
- my $obj = new Mail::Message::Encode;
+ my $encode = new Mail::Message::Encode;
use FileHandle;
my $fh = new FileHandle $log_file;
my $wh = \*STDOUT;
if (defined $fh) {
- while (<$fh>) { $maxline++;}
+ while (<$fh>) { $line_max++;}
$fh->close();
$fh = new FileHandle $log_file;
my $s = '';
- $maxline -= $last_n_lines;
+ $line_max -= $last_n_lines;
if ($is_cgi) { print $wh "<pre>\n";}
@@ -128,9 +123,9 @@ sub _show_log
my $buf;
LINE:
while ($buf = <$fh>) {
- next LINE if $linecount++ < $maxline;
+ next LINE if $line_count++ < $line_max;
- $s = $obj->convert( $buf, $charset );
+ $s = $encode->convert( $buf, $charset );
if ($is_cgi) {
print $wh (_html_to_text($s));