mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Improved parameter/result logging in debug/trace functions.
This commit is contained in:
parent
e61ef6ebce
commit
1a5fa920e6
@ -201,6 +201,10 @@
|
||||
|
||||
<p>Code cleanup in preparation for improved <cmd>stanza-create</cmd> command.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Improved parameter/result logging in debug/trace functions.</p>
|
||||
</release-item>
|
||||
</release-refactor-list>
|
||||
</release-core-list>
|
||||
|
||||
|
@ -353,6 +353,59 @@ sub logDebugProcess
|
||||
return @oyResult;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# logDebugBuild
|
||||
####################################################################################################################################
|
||||
sub logDebugBuild
|
||||
{
|
||||
my $strValue = shift;
|
||||
|
||||
my $rResult;
|
||||
|
||||
# Value is undefined
|
||||
if (!defined($strValue))
|
||||
{
|
||||
$rResult = \'[undef]';
|
||||
}
|
||||
# Value is not a ref, but return it as a ref for efficiency
|
||||
elsif (!ref($strValue))
|
||||
{
|
||||
$rResult = \$strValue;
|
||||
}
|
||||
# Value is a hash
|
||||
elsif (ref($strValue) eq 'HASH')
|
||||
{
|
||||
my $strValueHash;
|
||||
|
||||
for my $strSubValue (sort(keys(%{$strValue})))
|
||||
{
|
||||
$strValueHash .=
|
||||
(defined($strValueHash) ? ', ' : '{') . "${strSubValue} => " . ${logDebugBuild($strValue->{$strSubValue})};
|
||||
}
|
||||
|
||||
$rResult = \(defined($strValueHash) ? $strValueHash . '}' : '{}');
|
||||
}
|
||||
# Value is an array
|
||||
elsif (ref($strValue) eq 'ARRAY')
|
||||
{
|
||||
my $strValueArray;
|
||||
|
||||
for my $strSubValue (@{$strValue})
|
||||
{
|
||||
$strValueArray .= (defined($strValueArray) ? ', ' : '(') . ${logDebugBuild($strSubValue)};
|
||||
}
|
||||
|
||||
$rResult = \(defined($strValueArray) ? $strValueArray . ')' : '()');
|
||||
}
|
||||
# Else some other type ??? For the moment this is forced to object to not make big log changes
|
||||
else
|
||||
{
|
||||
$rResult = \('[object]');
|
||||
}
|
||||
|
||||
return $rResult;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# logDebugOut
|
||||
####################################################################################################################################
|
||||
@ -383,74 +436,9 @@ sub logDebugOut
|
||||
$strParamSet .= ', ';
|
||||
}
|
||||
|
||||
my $strValueRef;
|
||||
my $bDefault = false;
|
||||
|
||||
if (ref($$oParamHash{$strParam}) eq 'HASH')
|
||||
{
|
||||
if (blessed($$oParamHash{$strParam}{value}))
|
||||
{
|
||||
$strValueRef = \'[object]';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ref($$oParamHash{$strParam}{value}) eq 'ARRAY')
|
||||
{
|
||||
my $strValueArray;
|
||||
|
||||
for my $strValue (@{$$oParamHash{$strParam}{value}})
|
||||
{
|
||||
if (ref($strValue) eq 'ARRAY')
|
||||
{
|
||||
my $strSubValueArray;
|
||||
|
||||
for my $strSubValue (@{$strValue})
|
||||
{
|
||||
$strSubValueArray .=
|
||||
(defined($strSubValueArray) ? ', ' : '(') .
|
||||
(defined($strSubValue) ? $strSubValue : '[undef]');
|
||||
}
|
||||
|
||||
$strValueArray .= (defined($strValueArray) ? ', ' : '(') .
|
||||
(defined($strSubValueArray) ? $strSubValueArray . ')' : '()');
|
||||
}
|
||||
else
|
||||
{
|
||||
$strValueArray .=
|
||||
(defined($strValueArray) ? ', ' : '(') . (defined($strValue) ? $strValue : '[undef]');
|
||||
}
|
||||
}
|
||||
|
||||
$strValueRef = \(defined($strValueArray) ? $strValueArray . ')' : '()');
|
||||
}
|
||||
else
|
||||
{
|
||||
$strValueRef = ref($$oParamHash{$strParam}{value}) ? $$oParamHash{$strParam}{value} :
|
||||
\$$oParamHash{$strParam}{value};
|
||||
|
||||
$bDefault = defined($$strValueRef) &&
|
||||
defined($$oParamHash{$strParam}{default}) ? $$oParamHash{$strParam}{default} : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
# If this is an ARRAY ref then create a comma-separated list
|
||||
elsif (ref($$oParamHash{$strParam}) eq 'ARRAY')
|
||||
{
|
||||
my $strValueArray;
|
||||
|
||||
for my $strValue (@{$$oParamHash{$strParam}{value}})
|
||||
{
|
||||
$strValueArray .=
|
||||
(defined($strValueArray) ? ', ' : '(') . (defined($strValue) ? $strValue : '[undef]');
|
||||
}
|
||||
|
||||
$strValueRef = \(defined($strValueArray) ? $strValueArray . ')' : '()');
|
||||
}
|
||||
# Else get a reference if a reference was not passed
|
||||
else
|
||||
{
|
||||
$strValueRef = ref($$oParamHash{$strParam}) ? $$oParamHash{$strParam} : \$$oParamHash{$strParam};
|
||||
}
|
||||
my $strValueRef = defined($oParamHash->{$strParam}{value}) ? logDebugBuild($oParamHash->{$strParam}{value}) : undef;
|
||||
my $bDefault =
|
||||
defined($$strValueRef) && defined($$oParamHash{$strParam}{default}) ? $$oParamHash{$strParam}{default} : false;
|
||||
|
||||
$strParamSet .= "${strParam} = " .
|
||||
($bDefault ? '<' : '') .
|
||||
|
@ -63,18 +63,11 @@ push @EXPORT, qw(commonPrefix);
|
||||
####################################################################################################################################
|
||||
# boolFormat
|
||||
#
|
||||
# Outut boolean as true or false.
|
||||
# Output boolean as true or false.
|
||||
####################################################################################################################################
|
||||
sub boolFormat
|
||||
{
|
||||
my $bValue;
|
||||
|
||||
if ($bValue)
|
||||
{
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return 'false';
|
||||
return shift() ? 'true' : 'false';
|
||||
}
|
||||
|
||||
push @EXPORT, qw(boolFormat);
|
||||
|
Loading…
Reference in New Issue
Block a user