You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-07 00:35:37 +02:00
Add ASSERT_DEBUG() macro for debugging.
Replace all current assert() calls except in tests that can't use the debug code.
This commit is contained in:
@ -1,22 +1,28 @@
|
||||
/***********************************************************************************************************************************
|
||||
Common Command Routines
|
||||
***********************************************************************************************************************************/
|
||||
#include <assert.h>
|
||||
#include <string.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()
|
||||
{
|
||||
// A command must be set
|
||||
assert(cfgCommand() != cfgCmdNone);
|
||||
ASSERT_DEBUG_COMMAND_SET();
|
||||
|
||||
// This is fairly expensive log message to generate so skip it if it won't be output
|
||||
if (logWill(cfgLogLevelDefault()))
|
||||
@ -112,8 +118,7 @@ End the command
|
||||
void
|
||||
cmdEnd(int code)
|
||||
{
|
||||
// A command must be set
|
||||
assert(cfgCommand() != cfgCmdNone);
|
||||
ASSERT_DEBUG_COMMAND_SET();
|
||||
|
||||
// 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()))
|
||||
|
Reference in New Issue
Block a user