rsyslog/runtime/debug.h
Rainer Gerhards b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00

87 lines
3.1 KiB
C

/* debug.h
*
* Definitions for the debug module.
*
* Copyright 2008-2018 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* -or-
* see COPYING.ASL20 in the source distribution
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DEBUG_H_INCLUDED
#define DEBUG_H_INCLUDED
#include <pthread.h>
#include "obj-types.h"
/* some settings for various debug modes */
#define DEBUG_OFF 0
#define DEBUG_ONDEMAND 1
#define DEBUG_FULL 2
/* external static data elements (some time to be replaced) */
extern int Debug; /* debug flag - read-only after startup */
extern int debugging_on; /* read-only, except on sig USR1 */
extern int stddbg; /* the handle for regular debug output, set to stdout if not forking, -1 otherwise */
extern int dbgTimeoutToStderr;
/* prototypes */
rsRetVal dbgClassInit(void);
rsRetVal dbgClassExit(void);
void dbgSetDebugFile(uchar *fn);
void dbgSetDebugLevel(int level);
void dbgSetThrdName(const uchar *pszName);
void dbgOutputTID(char *name);
int dbgGetDbglogFd(void);
/* external data */
extern char *pszAltDbgFileName; /* if set, debug output is *also* sent to here */
extern int altdbg; /* and the handle for alternate debug output */
/* macros */
#ifdef DEBUGLESS
#define DBGL_UNUSED __attribute__((__unused__))
static inline void r_dbgoprint(const char DBGL_UNUSED *srcname,
obj_t DBGL_UNUSED *pObj,
const char DBGL_UNUSED *fmt,
...) {}
static inline void r_dbgprintf(const char DBGL_UNUSED *srcname, const char DBGL_UNUSED *fmt, ...) {}
#else
#define DBGL_UNUSED
void r_dbgoprint(const char *srcname, obj_t *pObj, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
void r_dbgprintf(const char *srcname, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
#endif
#define DBGPRINTF(...) \
if (Debug) { \
r_dbgprintf(__FILE__, __VA_ARGS__); \
}
#define DBGOPRINT(...) \
if (Debug) { \
r_dbgoprint(__FILE__, __VA_ARGS__); \
}
#define dbgprintf(...) r_dbgprintf(__FILE__, __VA_ARGS__)
#define dbgoprint(...) r_dbgoprint(__FILE__, __VA_ARGS__)
/* things originally introduced for now removed rtinst */
#define d_pthread_mutex_lock(x) pthread_mutex_lock(x)
#define d_pthread_mutex_trylock(x) pthread_mutex_trylock(x)
#define d_pthread_mutex_unlock(x) pthread_mutex_unlock(x)
#define d_pthread_cond_wait(cond, mut) pthread_cond_wait(cond, mut)
#define d_pthread_cond_timedwait(cond, mut, to) pthread_cond_timedwait(cond, mut, to)
#endif /* #ifndef DEBUG_H_INCLUDED */