You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-07 00:35:37 +02:00
Add stack trace macros to all functions.
Low-level functions only include stack trace in test builds while higher-level functions ship with stack trace built-in. Stack traces include all parameters passed to the function but production builds only create the parameter list when the log level is set high enough, i.e. debug or trace depending on the function.
This commit is contained in:
@ -4,25 +4,23 @@ Common Command Routines
|
||||
#include <string.h>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
#include "config/config.h"
|
||||
#include "version.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Debug Asserts
|
||||
***********************************************************************************************************************************/
|
||||
// The command must be set
|
||||
#define ASSERT_DEBUG_COMMAND_SET() \
|
||||
ASSERT_DEBUG(cfgCommand() != cfgCmdNone)
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Begin the command
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
cmdBegin(bool logOption)
|
||||
{
|
||||
ASSERT_DEBUG_COMMAND_SET();
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, logOption);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(cfgCommand() != cfgCmdNone);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
// This is fairly expensive log message to generate so skip it if it won't be output
|
||||
if (logWill(cfgLogLevelDefault()))
|
||||
@ -134,10 +132,12 @@ cmdBegin(bool logOption)
|
||||
}
|
||||
}
|
||||
|
||||
LOG_ANY(cfgLogLevelDefault(), 0, strPtr(info));
|
||||
LOG(cfgLogLevelDefault(), 0, strPtr(info));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -146,8 +146,13 @@ End the command
|
||||
void
|
||||
cmdEnd(int code, const String *errorMessage)
|
||||
{
|
||||
ASSERT_DEBUG_COMMAND_SET();
|
||||
ASSERT_DEBUG(code == 0 || errorMessage != NULL);
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(INT, code);
|
||||
FUNCTION_DEBUG_PARAM(STRING, errorMessage);
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(cfgCommand() != cfgCmdNone);
|
||||
FUNCTION_DEBUG_ASSERT(code == 0 || errorMessage != NULL);
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
// Skip this log message if it won't be output. It's not too expensive but since we skipped cmdBegin(), may as well.
|
||||
if (logWill(cfgLogLevelDefault()))
|
||||
@ -162,8 +167,10 @@ cmdEnd(int code, const String *errorMessage)
|
||||
else
|
||||
strCat(info, strPtr(errorMessage));
|
||||
|
||||
LOG_ANY(cfgLogLevelDefault(), 0, strPtr(info));
|
||||
LOG(cfgLogLevelDefault(), 0, strPtr(info));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
}
|
||||
|
Reference in New Issue
Block a user