From 38d320455336ab6da16c7c1b86e52d3118bcbd73 Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 9 Jan 2023 14:47:57 +0700 Subject: [PATCH] Remove duplication from FUNCTION_LOG_BEGIN_BASE() macro definitions. It is a bit simpler to define STACK_TRACE_TEST_START()/STACK_TRACE_TEST_STOP() in a separate #ifdef so FUNCTION_LOG_BEGIN_BASE() does not need to be defined twice. Also add missing semicolons exposed by this change. --- src/command/repo/get.c | 2 +- src/command/repo/ls.c | 2 +- src/command/repo/put.c | 2 +- src/common/debug.h | 37 +++++++++++++++------------------- src/common/exec.c | 4 ++-- src/common/io/client.c | 2 +- src/common/io/http/client.c | 2 +- src/common/io/http/request.c | 8 ++++---- src/common/io/http/response.c | 2 +- src/common/io/http/session.c | 4 ++-- src/common/io/server.c | 2 +- src/common/io/session.c | 2 +- src/common/io/socket/client.c | 2 +- src/common/io/socket/server.c | 2 +- src/common/io/socket/session.c | 2 +- src/common/io/tls/session.c | 2 +- 16 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/command/repo/get.c b/src/command/repo/get.c index c6ced05c2..e38521e07 100644 --- a/src/command/repo/get.c +++ b/src/command/repo/get.c @@ -24,7 +24,7 @@ Write source file to destination IO static int storageGetProcess(IoWrite *destination) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(IO_READ, destination); FUNCTION_LOG_END(); diff --git a/src/command/repo/ls.c b/src/command/repo/ls.c index bb86daed0..be635b16b 100644 --- a/src/command/repo/ls.c +++ b/src/command/repo/ls.c @@ -80,7 +80,7 @@ storageListRenderInfo(const StorageInfo *const info, IoWrite *const write, const static void storageListRender(IoWrite *write) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(IO_WRITE, write); FUNCTION_LOG_END(); diff --git a/src/command/repo/put.c b/src/command/repo/put.c index 7a9466566..b17c17912 100644 --- a/src/command/repo/put.c +++ b/src/command/repo/put.c @@ -21,7 +21,7 @@ Write source IO to destination file static void storagePutProcess(IoRead *source) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(IO_READ, source); FUNCTION_LOG_END(); diff --git a/src/common/debug.h b/src/common/debug.h index 0fba19713..95463ebd6 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -19,30 +19,25 @@ level is set to debug or trace. FUNCTION_LOG_logLevel #ifdef DEBUG_TEST_TRACE - #define FUNCTION_LOG_BEGIN_BASE(logLevel) \ - LogLevel FUNCTION_LOG_LEVEL() = STACK_TRACE_PUSH(logLevel); \ - \ - { \ - stackTraceParamLog(); \ - stackTraceTestStop(); - - #define FUNCTION_LOG_END_BASE() \ - stackTraceTestStart(); \ - LOG_FMT(FUNCTION_LOG_LEVEL(), 0, "(%s)", stackTraceParam()); \ - } + #define STACK_TRACE_TEST_START() stackTraceTestStart() + #define STACK_TRACE_TEST_STOP() stackTraceTestStop() #else - #define FUNCTION_LOG_BEGIN_BASE(logLevel) \ - LogLevel FUNCTION_LOG_LEVEL() = STACK_TRACE_PUSH(logLevel); \ - \ - if (logAny(FUNCTION_LOG_LEVEL())) \ - { \ - stackTraceParamLog(); - - #define FUNCTION_LOG_END_BASE() \ - LOG_FMT(FUNCTION_LOG_LEVEL(), 0, "(%s)", stackTraceParam()); \ - } + #define STACK_TRACE_TEST_START() + #define STACK_TRACE_TEST_STOP() #endif +#define FUNCTION_LOG_BEGIN_BASE(logLevel) \ + LogLevel FUNCTION_LOG_LEVEL() = STACK_TRACE_PUSH(logLevel); \ + \ + { \ + stackTraceParamLog(); \ + STACK_TRACE_TEST_STOP() + +#define FUNCTION_LOG_END_BASE() \ + STACK_TRACE_TEST_START(); \ + LOG_FMT(FUNCTION_LOG_LEVEL(), 0, "(%s)", stackTraceParam()); \ + } + /*********************************************************************************************************************************** General purpose function debugging macros diff --git a/src/common/exec.c b/src/common/exec.c index fa628b61a..c8321749e 100644 --- a/src/common/exec.c +++ b/src/common/exec.c @@ -114,7 +114,7 @@ execFreeResource(THIS_VOID) FN_EXTERN Exec * execNew(const String *command, const StringList *param, const String *name, TimeMSec timeout) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STRING, command); FUNCTION_LOG_PARAM(STRING_LIST, param); FUNCTION_LOG_PARAM(STRING, name); @@ -301,7 +301,7 @@ execFdRead(const THIS_VOID) FN_EXTERN void execOpen(Exec *this) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(EXEC, this); FUNCTION_LOG_END(); diff --git a/src/common/io/client.c b/src/common/io/client.c index 1229e7690..65fe45f30 100644 --- a/src/common/io/client.c +++ b/src/common/io/client.c @@ -19,7 +19,7 @@ struct IoClient FN_EXTERN IoClient * ioClientNew(void *driver, const IoClientInterface *interface) { - FUNCTION_LOG_BEGIN(logLevelTrace) + FUNCTION_LOG_BEGIN(logLevelTrace); FUNCTION_LOG_PARAM_P(VOID, driver); FUNCTION_LOG_PARAM(IO_CLIENT_INTERFACE, interface); FUNCTION_LOG_END(); diff --git a/src/common/io/http/client.c b/src/common/io/http/client.c index b661b023d..92fcc548b 100644 --- a/src/common/io/http/client.c +++ b/src/common/io/http/client.c @@ -34,7 +34,7 @@ struct HttpClient FN_EXTERN HttpClient * httpClientNew(IoClient *ioClient, TimeMSec timeout) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(IO_CLIENT, ioClient); FUNCTION_LOG_PARAM(TIME_MSEC, timeout); FUNCTION_LOG_END(); diff --git a/src/common/io/http/request.c b/src/common/io/http/request.c index 516300446..27343cb55 100644 --- a/src/common/io/http/request.c +++ b/src/common/io/http/request.c @@ -59,7 +59,7 @@ Process the request static HttpResponse * httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(HTTP_REQUEST, this); FUNCTION_LOG_PARAM(BOOL, waitForResponse); FUNCTION_LOG_PARAM(BOOL, contentCache); @@ -178,7 +178,7 @@ httpRequestProcess(HttpRequest *this, bool waitForResponse, bool contentCache) FN_EXTERN HttpRequest * httpRequestNew(HttpClient *client, const String *verb, const String *path, HttpRequestNewParam param) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(HTTP_CLIENT, client); FUNCTION_LOG_PARAM(STRING, verb); FUNCTION_LOG_PARAM(STRING, path); @@ -222,7 +222,7 @@ httpRequestNew(HttpClient *client, const String *verb, const String *path, HttpR FN_EXTERN HttpResponse * httpRequestResponse(HttpRequest *this, bool contentCache) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(HTTP_REQUEST, this); FUNCTION_LOG_PARAM(BOOL, contentCache); FUNCTION_LOG_END(); @@ -236,7 +236,7 @@ httpRequestResponse(HttpRequest *this, bool contentCache) FN_EXTERN void httpRequestError(const HttpRequest *this, HttpResponse *response) { - FUNCTION_LOG_BEGIN(logLevelTrace) + FUNCTION_LOG_BEGIN(logLevelTrace); FUNCTION_LOG_PARAM(HTTP_REQUEST, this); FUNCTION_LOG_PARAM(HTTP_RESPONSE, response); FUNCTION_LOG_END(); diff --git a/src/common/io/http/response.c b/src/common/io/http/response.c index 7f104a462..d5577da27 100644 --- a/src/common/io/http/response.c +++ b/src/common/io/http/response.c @@ -209,7 +209,7 @@ httpResponseEof(THIS_VOID) FN_EXTERN HttpResponse * httpResponseNew(HttpSession *session, const String *verb, bool contentCache) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(HTTP_SESSION, session); FUNCTION_LOG_PARAM(STRING, verb); FUNCTION_LOG_PARAM(BOOL, contentCache); diff --git a/src/common/io/http/session.c b/src/common/io/http/session.c index 7a1e9b811..07c33dbd2 100644 --- a/src/common/io/http/session.c +++ b/src/common/io/http/session.c @@ -21,7 +21,7 @@ struct HttpSession FN_EXTERN HttpSession * httpSessionNew(HttpClient *httpClient, IoSession *ioSession) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(HTTP_CLIENT, httpClient); FUNCTION_LOG_PARAM(IO_SESSION, ioSession); FUNCTION_LOG_END(); @@ -50,7 +50,7 @@ httpSessionNew(HttpClient *httpClient, IoSession *ioSession) FN_EXTERN void httpSessionDone(HttpSession *this) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(HTTP_SESSION, this); FUNCTION_LOG_END(); diff --git a/src/common/io/server.c b/src/common/io/server.c index 6a95d75e2..434cf3f81 100644 --- a/src/common/io/server.c +++ b/src/common/io/server.c @@ -20,7 +20,7 @@ struct IoServer FN_EXTERN IoServer * ioServerNew(void *const driver, const IoServerInterface *const interface) { - FUNCTION_LOG_BEGIN(logLevelTrace) + FUNCTION_LOG_BEGIN(logLevelTrace); FUNCTION_LOG_PARAM_P(VOID, driver); FUNCTION_LOG_PARAM(IO_SERVER_INTERFACE, interface); FUNCTION_LOG_END(); diff --git a/src/common/io/session.c b/src/common/io/session.c index 3628ca126..f3509e7de 100644 --- a/src/common/io/session.c +++ b/src/common/io/session.c @@ -19,7 +19,7 @@ struct IoSession FN_EXTERN IoSession * ioSessionNew(void *driver, const IoSessionInterface *interface) { - FUNCTION_LOG_BEGIN(logLevelTrace) + FUNCTION_LOG_BEGIN(logLevelTrace); FUNCTION_LOG_PARAM_P(VOID, driver); FUNCTION_LOG_PARAM(IO_SESSION_INTERFACE, interface); FUNCTION_LOG_END(); diff --git a/src/common/io/socket/client.c b/src/common/io/socket/client.c index 4eb872716..dbd521c41 100644 --- a/src/common/io/socket/client.c +++ b/src/common/io/socket/client.c @@ -161,7 +161,7 @@ static const IoClientInterface sckClientInterface = FN_EXTERN IoClient * sckClientNew(const String *const host, const unsigned int port, const TimeMSec timeoutConnect, const TimeMSec timeoutSession) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STRING, host); FUNCTION_LOG_PARAM(UINT, port); FUNCTION_LOG_PARAM(TIME_MSEC, timeoutConnect); diff --git a/src/common/io/socket/server.c b/src/common/io/socket/server.c index a416d13f4..ff758901a 100644 --- a/src/common/io/socket/server.c +++ b/src/common/io/socket/server.c @@ -144,7 +144,7 @@ static const IoServerInterface sckServerInterface = FN_EXTERN IoServer * sckServerNew(const String *const address, const unsigned int port, const TimeMSec timeout) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STRING, address); FUNCTION_LOG_PARAM(UINT, port); FUNCTION_LOG_PARAM(TIME_MSEC, timeout); diff --git a/src/common/io/socket/session.c b/src/common/io/socket/session.c index 617e8c4b9..52fa48cf0 100644 --- a/src/common/io/socket/session.c +++ b/src/common/io/socket/session.c @@ -165,7 +165,7 @@ static const IoSessionInterface sckSessionInterface = FN_EXTERN IoSession * sckSessionNew(IoSessionRole role, int fd, const String *host, unsigned int port, TimeMSec timeout) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(STRING_ID, role); FUNCTION_LOG_PARAM(INT, fd); FUNCTION_LOG_PARAM(STRING, host); diff --git a/src/common/io/tls/session.c b/src/common/io/tls/session.c index 49833c4f5..ea7ad37a2 100644 --- a/src/common/io/tls/session.c +++ b/src/common/io/tls/session.c @@ -352,7 +352,7 @@ static const IoSessionInterface tlsSessionInterface = FN_EXTERN IoSession * tlsSessionNew(SSL *session, IoSession *ioSession, TimeMSec timeout) { - FUNCTION_LOG_BEGIN(logLevelDebug) + FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM_P(VOID, session); FUNCTION_LOG_PARAM(IO_SESSION, ioSession); FUNCTION_LOG_PARAM(TIME_MSEC, timeout);