You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Rename FUNCTION_DEBUG_* and consolidate ASSERT_* macros for consistency.
Rename FUNCTION_DEBUG_* macros to FUNCTION_LOG_* to more accurately reflect what they do. Further rename FUNCTION_DEBUG_RESULT* macros to FUNCTION_LOG_RETURN* to make it clearer that they return from the function as well as logging. Leave FUNCTION_TEST_* macros as they are. Consolidate the various ASSERT* macros into a single ASSERT macro that is always compiled out of production builds. It was difficult to figure out when an assert would be checked with all the different types in play. When ASSERTs are compiled in they will always be checked regardless of the log level -- tying these two concepts together was not a good idea.
This commit is contained in:
@ -4,7 +4,6 @@ Common Command Routines
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
@ -23,11 +22,11 @@ Capture time at the very start of main so total time is more accurate
|
||||
void
|
||||
cmdInit(void)
|
||||
{
|
||||
FUNCTION_DEBUG_VOID(logLevelTrace);
|
||||
FUNCTION_LOG_VOID(logLevelTrace);
|
||||
|
||||
timeBegin = timeMSec();
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -36,11 +35,11 @@ Begin the command
|
||||
void
|
||||
cmdBegin(bool logOption)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(BOOL, logOption);
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(BOOL, logOption);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(cfgCommand() != cfgCmdNone);
|
||||
FUNCTION_DEBUG_END();
|
||||
ASSERT(cfgCommand() != cfgCmdNone);
|
||||
|
||||
// This is fairly expensive log message to generate so skip it if it won't be output
|
||||
if (logWill(cfgLogLevelDefault()))
|
||||
@ -157,7 +156,7 @@ cmdBegin(bool logOption)
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -166,12 +165,12 @@ End the command
|
||||
void
|
||||
cmdEnd(int code, const String *errorMessage)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(INT, code);
|
||||
FUNCTION_DEBUG_PARAM(STRING, errorMessage);
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(INT, code);
|
||||
FUNCTION_LOG_PARAM(STRING, errorMessage);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
FUNCTION_DEBUG_ASSERT(cfgCommand() != cfgCmdNone);
|
||||
FUNCTION_DEBUG_END();
|
||||
ASSERT(cfgCommand() != cfgCmdNone);
|
||||
|
||||
// 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()))
|
||||
@ -199,5 +198,5 @@ cmdEnd(int code, const String *errorMessage)
|
||||
// Reset timeBegin in case there is another command following this one
|
||||
timeBegin = timeMSec();
|
||||
|
||||
FUNCTION_DEBUG_RESULT_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
Reference in New Issue
Block a user