pgbackrest.git / summary / log / commit / refs

commit    d321ef0b6d5af0c1dce8fd5701edbadffffce5af
Author:   David Steele <david@pgmasters.net>
Date:     Fri May 29 16:26:31 2015 +0000

    Implement issue #89: Make confess backtraces log-level dependent.
    
    ASSERTs still dump stack traces to the console and file in all cases.  ERRORs only dump stack traces to the file when the file log level is DEBUG or TRACE.


README.md | 2 +- doc/doc.xml | 2 +- lib/BackRest/Exception.pm | 7 +++++-- lib/BackRest/Utility.pm | 10 ++++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 482ddef6c..f41730de0 100644 --- a/README.md +++ b/README.md @@ -745,7 +745,7 @@ example: db-path=/data/db * Better logging before pg_start_backup() to make it clear when the backup is waiting on a checkpoint. Suggested by Michael Renner. -* Various command behavior and help fixes. Reported by Michael Renner. +* Various command behavior, help and logging fixes. Reported by Michael Renner. * Fixed an issue in async archiving where archive-push was not properly returning 0 when archive-max-mb was reached and moved the async check after transfer to avoid having to remove the stop file twice. Also added unit tests for this case and improved error messages to make it clearer to the user what went wrong. Reported by Michael Renner. diff --git a/doc/doc.xml b/doc/doc.xml index f741a6a94..8aad11d84 100644 --- a/doc/doc.xml +++ b/doc/doc.xml @@ -702,7 +702,7 @@ Run a <id>full</id> backup on the <id>db</id> stanza. <param>--type</param> can <text>Better logging before pg_start_backup() to make it clear when the backup is waiting on a checkpoint. Suggested by Michael Renner.</text> </release-feature> <release-feature> - <text>Various command behavior and help fixes. Reported by Michael Renner.</text> + <text>Various command behavior, help and logging fixes. Reported by Michael Renner.</text> </release-feature> <release-feature> <text>Fixed an issue in async archiving where archive-push was not properly returning 0 when archive-max-mb was reached and moved the async check after transfer to avoid having to remove the stop file twice. Also added unit tests for this case and improved error messages to make it clearer to the user what went wrong. Reported by Michael Renner.</text> diff --git a/lib/BackRest/Exception.pm b/lib/BackRest/Exception.pm index e3758e976..1255c3e96 100644 --- a/lib/BackRest/Exception.pm +++ b/lib/BackRest/Exception.pm @@ -37,14 +37,17 @@ use constant ERROR_VERSION_NOT_SUPPORTED => 121, ERROR_PATH_CREATE => 122, ERROR_OPERATION_INVALID => 123, - ERROR_HOST_CONNECT => 124 + ERROR_HOST_CONNECT => 124, + + ERROR_UNKNOWN => 199 }; our @EXPORT = qw(ERROR_ASSERT ERROR_CHECKSUM ERROR_CONFIG ERROR_FILE_INVALID ERROR_FORMAT ERROR_OPERATION_REQUIRED ERROR_OPTION_INVALID ERROR_OPTION_INVALID_VALUE ERROR_OPTION_INVALID_RANGE ERROR_OPTION_INVALID_PAIR ERROR_OPTION_DUPLICATE_KEY ERROR_OPTION_NEGATE ERROR_OPTION_REQUIRED ERROR_POSTMASTER_RUNNING ERROR_PROTOCOL ERROR_RESTORE_PATH_NOT_EMPTY ERROR_FILE_OPEN ERROR_FILE_READ ERROR_PARAM_REQUIRED ERROR_ARCHIVE_MISMATCH - ERROR_ARCHIVE_DUPLICATE ERROR_VERSION_NOT_SUPPORTED ERROR_PATH_CREATE ERROR_OPERATION_INVALID ERROR_HOST_CONNECT); + ERROR_ARCHIVE_DUPLICATE ERROR_VERSION_NOT_SUPPORTED ERROR_PATH_CREATE ERROR_OPERATION_INVALID ERROR_HOST_CONNECT + ERROR_UNKNOWN); #################################################################################################################################### # CONSTRUCTOR diff --git a/lib/BackRest/Utility.pm b/lib/BackRest/Utility.pm index 831249164..ca070ebe1 100644 --- a/lib/BackRest/Utility.pm +++ b/lib/BackRest/Utility.pm @@ -468,8 +468,13 @@ sub log $strMessageFormat =~ s/\n/\n /g; $strMessageFormat = ' ' . $strMessageFormat; } - elsif ($strLevel eq ERROR && defined($iCode)) + elsif ($strLevel eq ERROR) { + if (!defined($iCode)) + { + $iCode = ERROR_UNKNOWN; + } + $strMessageFormat =~ s/\n/\n /g; } @@ -509,7 +514,8 @@ sub log { print $hLogFile $strMessageFormat; - if ($strLevel eq ERROR || $strLevel eq ASSERT) + if ($strLevel eq ASSERT || + ($strLevel eq ERROR && ($strLogLevelFile eq DEBUG || $strLogLevelFile eq TRACE))) { my $strStackTrace = longmess() . "\n"; $strStackTrace =~ s/\n/\n /g; [parent: 13e4eec629df]