summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-04-17 13:24:35 +0000
committerfukachan <fukachan>2004-04-17 13:24:35 +0000
commit66f2d77b8f45ccba28fd8714ae120342954a34c8 (patch)
tree2b76e5949a9256f580d3fd888b7fba7c66509999
parent56860ca34c06c52b4cb4553a0cc5857321011ebb (diff)
downloadfml8-66f2d77b8f45ccba28fd8714ae120342954a34c8.tar.gz
fml8-66f2d77b8f45ccba28fd8714ae120342954a34c8.tar.bz2
fml8-66f2d77b8f45ccba28fd8714ae120342954a34c8.zip
implement log_rorate()
-rw-r--r--fml/lib/FML/Process/Utils.pm48
1 files changed, 47 insertions, 1 deletions
diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm
index 9c72826e..35b49005 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.111 2004/04/02 11:51:32 fukachan Exp $
+# $FML: Utils.pm,v 1.112 2004/04/10 12:41:30 fukachan Exp $
#
package FML::Process::Utils;
@@ -1933,6 +1933,52 @@ sub command_specific_recipient
}
+=head1 LOG ROTATION
+
+=head2 log_rorate()
+
+rotate log files.
+
+=cut
+
+
+# Descriptions: rotate log files.
+# Arguments: OBJ($curproc)
+# Side Effects: none
+# Return Value: none
+sub log_rorate
+{
+ my ($curproc) = @_;
+ my $config = $curproc->config();
+ my $log = undef;
+
+ if ($config->yes('use_log_rotate')) {
+ eval q{
+ use FML::File::Rotate;
+ $log = new FML::File::Rotate $curproc;
+ };
+ my $r = $@;
+
+ if (defined $log) {
+ my $log_file = $config->{ log_file };
+ my $size = $config->{ log_rotate_size };
+ my $num = $config->{ log_rotate_num_backlog };
+
+ $log->set_max_size($size);
+ $log->set_num_backlog($num);
+ if ($log->is_time_to_rotate($log_file)) {
+ $log->rotate($log_file);
+ $curproc->log("log rotated.");
+ }
+ }
+ else {
+ $curproc->logerror("cannot attach log rotate object");
+ $curproc->logerror($r);
+ }
+ }
+}
+
+
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.