Hi,
This patch series removes some unused functions from
installer::logger, and merges two very similar functions. Plus
general cleanup.
Kind regards,
--
Tim Retout <tim@retout.co.uk>
From 35b6a2c9ae816cbb99dbe4e79cae7115fdd26137 Mon Sep 17 00:00:00 2001
From: Tim Retout <tim@retout.co.uk>
Date: Thu, 16 Feb 2012 19:46:12 +0000
Subject: [PATCH 1/5] Remove unreferenced subroutines from installer::logger
---
solenv/bin/modules/installer/logger.pm | 44 --------------------------------
1 files changed, 0 insertions(+), 44 deletions(-)
diff --git a/solenv/bin/modules/installer/logger.pm b/solenv/bin/modules/installer/logger.pm
index 0130369..f86c4df 100644
--- a/solenv/bin/modules/installer/logger.pm
+++ b/solenv/bin/modules/installer/logger.pm
@@ -247,19 +247,6 @@ sub get_time_string
}
###############################################################
-# Returning the age of a file (in seconds)
-###############################################################
-
-sub get_file_age
-{
- my ( $filename ) = @_;
-
- my $filetime = (stat($filename))[9];
- my $timediff = time() - $filetime;
- return $timediff;
-}
-
-###############################################################
# Stopping the time
###############################################################
@@ -270,29 +257,6 @@ sub stoptime
}
###############################################################
-# Set date string, format: yymmdd
-###############################################################
-
-sub set_installation_date
-{
- my $datestring = "";
-
- my @timearray = localtime(time);
-
- my $day = $timearray[3];
- my $month = $timearray[4] + 1;
- my $year = $timearray[5] - 100;
-
- if ( $year < 10 ) { $year = "0" . $year; }
- if ( $month < 10 ) { $month = "0" . $month; }
- if ( $day < 10 ) { $day = "0" . $day; }
-
- $datestring = $year . $month . $day;
-
- return $datestring;
-}
-
-###############################################################
# Console output: messages
###############################################################
@@ -305,14 +269,6 @@ sub print_message
return;
}
-sub print_message_without_newline
-{
- my $message = shift;
- chomp $message;
- print "$message" if ( ! $installer::globals::quiet );
- return;
-}
-
###############################################################
# Console output: warnings
###############################################################
--
1.7.8.3
From 29f1b00bc2c97684ade08de6b238e761e66aad51 Mon Sep 17 00:00:00 2001
From: Tim Retout <tim@retout.co.uk>
Date: Thu, 16 Feb 2012 20:22:42 +0000
Subject: [PATCH 2/5] Use Exporter in installer::logger.
Also rename private subroutines to start with an underscore.
---
solenv/bin/modules/installer/logger.pm | 34 ++++++++++++++++++++++++-------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/solenv/bin/modules/installer/logger.pm b/solenv/bin/modules/installer/logger.pm
index f86c4df..2ec0360 100644
--- a/solenv/bin/modules/installer/logger.pm
+++ b/solenv/bin/modules/installer/logger.pm
@@ -30,9 +30,27 @@ package installer::logger;
use strict;
use warnings;
+use base 'Exporter';
+
use installer::files;
use installer::globals;
+our @EXPORT_OK = qw(
+ include_header_into_logfile
+ include_header_into_globallogfile
+ include_timestamp_into_logfile
+ log_hashref
+ globallog
+ copy_globalinfo_into_logfile
+ debuginfo
+ savedebug
+ starttime
+ stoptime
+ print_message
+ print_warning
+ print_error
+);
+
####################################################
# Including header files into the logfile
####################################################
@@ -43,7 +61,7 @@ sub include_header_into_logfile
my $infoline;
- $infoline = "\n" . get_time_string();
+ $infoline = "\n" . _get_time_string();
push( @installer::globals::logfileinfo, $infoline);
$infoline = "######################################################\n";
@@ -67,7 +85,7 @@ sub include_header_into_globallogfile
my $infoline;
- $infoline = "\n" . get_time_string();
+ $infoline = "\n" . _get_time_string();
push( @installer::globals::globallogfileinfo, $infoline);
$infoline = "######################################################\n";
@@ -90,7 +108,7 @@ sub include_timestamp_into_logfile
my ($message) = @_;
my $infoline;
- my $timestring = get_time_string();
+ my $timestring = _get_time_string();
$infoline = "$message\t$timestring";
push( @installer::globals::logfileinfo, $infoline);
}
@@ -131,7 +149,7 @@ sub globallog
my $infoline;
- $infoline = "\n" . get_time_string();
+ $infoline = "\n" . _get_time_string();
push( @installer::globals::globallogfileinfo, $infoline);
$infoline = "################################################################\n";
@@ -196,7 +214,7 @@ sub starttime
# Convert time string
###############################################################
-sub convert_timestring
+sub _convert_timestring
{
my ($secondstring) = @_;
@@ -237,11 +255,11 @@ sub convert_timestring
# Returning time string for logging
###############################################################
-sub get_time_string
+sub _get_time_string
{
my $currenttime = time();
$currenttime = $currenttime - $installer::globals::starttime;
- $currenttime = convert_timestring($currenttime);
+ $currenttime = _convert_timestring($currenttime);
$currenttime = localtime() . " \(" . $currenttime . "\)\n";
return $currenttime;
}
@@ -252,7 +270,7 @@ sub get_time_string
sub stoptime
{
- my $infoline = get_time_string();
+ my $infoline = _get_time_string();
print_message( "$infoline" );
}
--
1.7.8.3
From fcf87b130314e801a68524635c061bb5ecb7cdeb Mon Sep 17 00:00:00 2001
From: Tim Retout <tim@retout.co.uk>
Date: Thu, 16 Feb 2012 20:52:10 +0000
Subject: [PATCH 3/5] installer::logger: Remove temporary variable.
---
solenv/bin/modules/installer/logger.pm | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/solenv/bin/modules/installer/logger.pm b/solenv/bin/modules/installer/logger.pm
index 2ec0360..681c3d1f 100644
--- a/solenv/bin/modules/installer/logger.pm
+++ b/solenv/bin/modules/installer/logger.pm
@@ -270,8 +270,7 @@ sub _get_time_string
sub stoptime
{
- my $infoline = _get_time_string();
- print_message( "$infoline" );
+ print_message( _get_time_string() );
}
###############################################################
--
1.7.8.3
From 8751abe9893843ec827e909d4a4d7a970ebb69ea Mon Sep 17 00:00:00 2001
From: Tim Retout <tim@retout.co.uk>
Date: Thu, 16 Feb 2012 20:54:19 +0000
Subject: [PATCH 4/5] Move global starttime into installer::logger
---
solenv/bin/modules/installer/globals.pm | 2 --
solenv/bin/modules/installer/logger.pm | 6 ++++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/solenv/bin/modules/installer/globals.pm b/solenv/bin/modules/installer/globals.pm
index 33d6e0a..f066c34 100644
--- a/solenv/bin/modules/installer/globals.pm
+++ b/solenv/bin/modules/installer/globals.pm
@@ -431,8 +431,6 @@ BEGIN
$postprocess_standardepm = 0;
$mergemodules_analyzed = 0;
- $starttime = "";
-
@solarispatchscripts = ("checkinstall", "copyright", "patch_checkinstall",
"patch_postinstall", "postinstall", "preinstall", "i.none");
@solarispatchscriptsforextensions = ("checkinstall", "copyright", "patch_checkinstall",
"patch_postinstall_extensions", "postinstall_extensions", "preinstall", "i.none");
@solarispatchfiles = (".diPatch", "patchinfo");
diff --git a/solenv/bin/modules/installer/logger.pm b/solenv/bin/modules/installer/logger.pm
index 681c3d1f..f98d34c 100644
--- a/solenv/bin/modules/installer/logger.pm
+++ b/solenv/bin/modules/installer/logger.pm
@@ -51,6 +51,8 @@ our @EXPORT_OK = qw(
print_error
);
+my $starttime;
+
####################################################
# Including header files into the logfile
####################################################
@@ -207,7 +209,7 @@ sub savedebug
sub starttime
{
- $installer::globals::starttime = time();
+ $starttime = time();
}
###############################################################
@@ -258,7 +260,7 @@ sub _convert_timestring
sub _get_time_string
{
my $currenttime = time();
- $currenttime = $currenttime - $installer::globals::starttime;
+ $currenttime = $currenttime - $starttime;
$currenttime = _convert_timestring($currenttime);
$currenttime = localtime() . " \(" . $currenttime . "\)\n";
return $currenttime;
--
1.7.8.3
From cbdab345276b081fcf4b0e25b789b4f7322908f9 Mon Sep 17 00:00:00 2001
From: Tim Retout <tim@retout.co.uk>
Date: Thu, 16 Feb 2012 22:33:46 +0000
Subject: [PATCH 5/5] Replace
installer::logger::include_header_into_globallogfile.
---
solenv/bin/modules/installer/logger.pm | 29 +-------------------------
solenv/bin/modules/installer/setupscript.pm | 6 ++--
2 files changed, 5 insertions(+), 30 deletions(-)
diff --git a/solenv/bin/modules/installer/logger.pm b/solenv/bin/modules/installer/logger.pm
index f98d34c..dba0ea0 100644
--- a/solenv/bin/modules/installer/logger.pm
+++ b/solenv/bin/modules/installer/logger.pm
@@ -37,7 +37,6 @@ use installer::globals;
our @EXPORT_OK = qw(
include_header_into_logfile
- include_header_into_globallogfile
include_timestamp_into_logfile
log_hashref
globallog
@@ -78,30 +77,6 @@ sub include_header_into_logfile
}
####################################################
-# Including header files into the logfile
-####################################################
-
-sub include_header_into_globallogfile
-{
- my ($message) = @_;
-
- my $infoline;
-
- $infoline = "\n" . _get_time_string();
- push( @installer::globals::globallogfileinfo, $infoline);
-
- $infoline = "######################################################\n";
- push( @installer::globals::globallogfileinfo, $infoline);
-
- $infoline = "$message\n";
- push( @installer::globals::globallogfileinfo, $infoline);
-
-
- $infoline = "######################################################\n";
- push( @installer::globals::globallogfileinfo, $infoline);
-}
-
-####################################################
# Write timestamp into log file
####################################################
@@ -154,13 +129,13 @@ sub globallog
$infoline = "\n" . _get_time_string();
push( @installer::globals::globallogfileinfo, $infoline);
- $infoline = "################################################################\n";
+ $infoline = "######################################################\n";
push( @installer::globals::globallogfileinfo, $infoline);
$infoline = "$message\n";
push( @installer::globals::globallogfileinfo, $infoline);
- $infoline = "################################################################\n";
+ $infoline = "######################################################\n";
push( @installer::globals::globallogfileinfo, $infoline);
}
diff --git a/solenv/bin/modules/installer/setupscript.pm
b/solenv/bin/modules/installer/setupscript.pm
index 3018bb3..7d590c5 100644
--- a/solenv/bin/modules/installer/setupscript.pm
+++ b/solenv/bin/modules/installer/setupscript.pm
@@ -30,7 +30,7 @@ package installer::setupscript;
use installer::existence;
use installer::exiter;
use installer::globals;
-use installer::logger;
+use installer::logger qw(globallog);
use installer::remover;
use installer::scriptitems;
use installer::ziplist;
@@ -241,7 +241,7 @@ sub replace_all_setupscriptvariables_in_script
{
my ( $scriptref, $variablesref ) = @_;
- installer::logger::include_header_into_globallogfile("Replacing variables in setup script
(start)");
+ globallog("Replacing variables in setup script (start)");
# make hash of variables to be substituted if they appear in the script
my %subs;
@@ -282,7 +282,7 @@ sub replace_all_setupscriptvariables_in_script
}
}
- installer::logger::include_header_into_globallogfile("Replacing variables in setup script
(end)");
+ globallog("Replacing variables in setup script (end)");
return $scriptref;
}
--
1.7.8.3
Context
- [PATCH] Initial cleanup of installer::logger · Tim Retout
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.