ldap/admin/src/scripts/DSUtil.pm.in | 13 +++++++++++--
ldap/admin/src/scripts/Migration.pm.in | 1 +
ldap/admin/src/scripts/Setup.pm.in | 1 +
ldap/admin/src/scripts/SetupLog.pm | 8 ++++++++
4 files changed, 21 insertions(+), 2 deletions(-)
New commits:
commit f399247c9e72d1765d1b9b83d7c939bfd517f606
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Tue Mar 1 19:53:01 2011 -0700
Bug 514190 - setup-ds-admin.pl --debug does not log to file
https://bugzilla.redhat.com/show_bug.cgi?id=514190
Resolves: bug 514190
Bug Description: setup-ds-admin.pl --debug does not log to file
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.2.8
Fix Description: Added a logDebug() method to the SetupLog class, used
for logging debug messages. At startup time, the log used by the
Setup or Migration object registers its log with the DSUtil code. When
the DSUtil::debug() method is called, it will also call the logDebug()
method of the DSUtil::log object if specified.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 6580a9942e945699819570596977b60cd82d65ec)
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index e65f7e0..22f25dc 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -49,12 +49,12 @@ require Exporter;
process_maptbl check_and_add_entry getMappedEntries addErr
getHashedPassword debug createInfFromConfig shellEscape
isValidServerID isValidUser isValidGroup makePaths getLogin getGroup
- remove_tree remove_pidfile);
+ remove_tree remove_pidfile setDebugLog);
@EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
process_maptbl check_and_add_entry getMappedEntries addErr
getHashedPassword debug createInfFromConfig shellEscape
isValidServerID isValidUser isValidGroup makePaths getLogin getGroup
- remove_tree remove_pidfile);
+ remove_tree remove_pidfile setDebugLog);
use strict;
@@ -67,6 +67,8 @@ use File::Path qw(rmtree);
use Carp;
$DSUtil::debuglevel = 0;
+$DSUtil::log = 0;
+
# use like this:
# debug(3, "message");
# this will only print "message" if $debuglevel is 3 or higher (-ddd on the
command line)
@@ -74,9 +76,16 @@ sub debug {
my ($level, @rest) = @_;
if ($level <= $DSUtil::debuglevel) {
print STDERR "+" x $level, @rest;
+ if ($DSUtil::log) {
+ $DSUtil::log->logDebug(@rest);
+ }
}
}
+sub setDebugLog {
+ $DSUtil::log = shift;
+}
+
# return true if the given port number is available, false otherwise
sub portAvailable {
my $port = shift;
diff --git a/ldap/admin/src/scripts/Migration.pm.in
b/ldap/admin/src/scripts/Migration.pm.in
index 66618c8..42a92c1 100644
--- a/ldap/admin/src/scripts/Migration.pm.in
+++ b/ldap/admin/src/scripts/Migration.pm.in
@@ -210,6 +210,7 @@ sub init {
$self->{logfile} = $logfile;
$self->{crossplatform} = $crossplatform;
$self->{log} = new SetupLog($self->{logfile}, "migrate");
+ DSUtil::setDebugLog($self->{log});
$self->{start_servers} = 1; # start servers as soon as they are migrated
# if user supplied inf file, use that to initialize
if (defined($inffile)) {
diff --git a/ldap/admin/src/scripts/Setup.pm.in b/ldap/admin/src/scripts/Setup.pm.in
index 753062d..e154367 100644
--- a/ldap/admin/src/scripts/Setup.pm.in
+++ b/ldap/admin/src/scripts/Setup.pm.in
@@ -142,6 +142,7 @@ sub init {
$self->{force} = $force;
$self->{logfile} = $logfile;
$self->{log} = new SetupLog($self->{logfile});
+ DSUtil::setDebugLog($self->{log});
# if user supplied inf file, use that to initialize
if (defined($inffile)) {
$self->{inf} = new Inf($inffile);
diff --git a/ldap/admin/src/scripts/SetupLog.pm b/ldap/admin/src/scripts/SetupLog.pm
index 9ff3c32..fc06d29 100644
--- a/ldap/admin/src/scripts/SetupLog.pm
+++ b/ldap/admin/src/scripts/SetupLog.pm
@@ -92,6 +92,14 @@ sub logMessage {
print { $self->{fh} } $string;
}
+sub logDebug {
+ my ($self, @msg) = @_;
+ if (!$self->{fh}) {
+ return;
+ }
+ print { $self->{fh} } @msg;
+}
+
sub levels {
my $self = shift;
return ($FATAL, $START, $SUCCESS, $WARN, $INFO, $DEBUG);