13#ifndef CDI_LOGGER_API_API_H__
14#define CDI_LOGGER_API_API_H__
27#define CDI_MAX_LOG_STRING_LENGTH (1024)
30#define CDI_MAX_LOG_FUNCTION_NAME_STRING_LENGTH (128)
76#define CDI_LOG_THREAD(log_level, ...) \
77 CdiLogger(CdiLoggerThreadLogGet(), kLogComponentGeneric, log_level, __FUNCTION__, __LINE__, __VA_ARGS__)
89#define CDI_LOG_THREAD_COMPONENT(log_level, component, ...) \
90 CdiLogger(CdiLoggerThreadLogGet(), component, log_level, __FUNCTION__, __LINE__, __VA_ARGS__)
99#define CDI_LOG_HANDLE(log_handle, log_level, ...) \
100 CdiLogger(log_handle, kLogComponentGeneric, log_level, __FUNCTION__, __LINE__, __VA_ARGS__)
108#define CDI_LOG_THREAD_MULTILINE_BEGIN(log_level, multiline_state_ptr) \
109 CdiLoggerMultilineBegin(CdiLoggerThreadLogGet(), kLogComponentGeneric, log_level, __FUNCTION__, __LINE__, \
116#define CDI_LOG_MULTILINE(multiline_state_ptr, ...) \
117 CdiLoggerMultiline(multiline_state_ptr, __VA_ARGS__)
124#define CDI_LOG_MULTILINE_END(multiline_handle) CdiLoggerMultilineEnd(multiline_handle)
132#define CDI_LOG_WHEN(log_level, condition, number, ...) \
134 static uint64_t log_event_count = 0; \
136 CdiOsAtomicInc64(&log_event_count); \
137 if ((number) > 0 && (1 == log_event_count % (number) || 1 == (number))) { \
138 if (1 < (number)) { \
139 CDI_LOG_HANDLE(CdiLogGlobalGet(), kLogInfo, "The following message has " \
140 "occurred [%llu] times.", log_event_count); \
142 CdiLogger(CdiLogGlobalGet(), kLogComponentGeneric, log_level, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
153#define CDI_LOG_THREAD_WHEN(log_level, condition, number, ...) \
155 static uint64_t log_event_count = 0; \
157 CdiOsAtomicInc64(&log_event_count); \
158 if ((number) > 0 && (1 == log_event_count % (number) || 1 == (number))) { \
159 if (1 < (number)) { \
160 CDI_LOG_HANDLE(CdiLoggerThreadLogGet(), kLogInfo, "The following message has " \
161 "occurred [%llu] times.", log_event_count); \
163 CdiLogger(CdiLoggerThreadLogGet(), kLogComponentGeneric, log_level, \
164 __FUNCTION__, __LINE__, ##__VA_ARGS__); \
227 const char* function_name_str,
int line_number,
const char* format_str, ...);
272 const char* function_name_str,
int line_number,
CdiReturnStatus
Values used for API function return codes.
Definition cdi_core_api.h:189
This file declares the public API data types, structures and functions that comprise the CDI log API.
CdiLogComponent
This selector determines the SDK component type for logging. Logging for it can be enabled/disabled u...
Definition cdi_log_enums.h:35
CdiLogLevel
This selector determines the log level of messages generated using the CdiLogMessageCallback()....
Definition cdi_log_enums.h:50
CDI_INTERFACE void CdiLoggerThreadLogUnset(void)
Definition logger.c:1032
CDI_INTERFACE bool CdiLoggerCreate(CdiLogLevel default_log_level, CdiLoggerHandle *ret_logger_handle_ptr)
Definition logger.c:748
#define CDI_MAX_LOG_FUNCTION_NAME_STRING_LENGTH
Maximum length of log message function name string used in logger.c.
Definition cdi_logger_api.h:30
CDI_INTERFACE CdiLogHandle CdiLoggerThreadLogGet(void)
Definition logger.c:1039
CDI_INTERFACE void CdiLoggerShutdown(bool force)
Definition logger.c:1230
CDI_INTERFACE bool CdiLoggerCreateFileLog(CdiLoggerHandle logger_handle, const char *filename_str, CdiLogHandle *ret_log_handle_ptr)
Definition logger.c:851
CDI_INTERFACE void CdiLoggerDestroyLog(CdiLogHandle handle)
Definition logger.c:1166
CDI_INTERFACE bool CdiLoggerInitialize(void)
Definition logger.c:676
CDI_INTERFACE bool CdiLoggerIsEnabled(CdiLogHandle handle, CdiLogComponent component, CdiLogLevel log_level)
Definition logger.c:1050
CDI_INTERFACE bool CdiLoggerComponentIsEnabled(CdiLogHandle handle, CdiLogComponent component)
Definition logger.c:1082
CDI_INTERFACE void CdiLoggerMultilineBegin(CdiLogHandle handle, CdiLogComponent component, CdiLogLevel log_level, const char *function_name_str, int line_number, CdiLogMultilineState *state_ptr)
Definition logger.c:884
CDI_INTERFACE void CdiLoggerLogFromCallback(CdiLogHandle handle, const CdiLogMessageCbData *cb_data_ptr)
Definition logger.c:998
CDI_INTERFACE CdiReturnStatus CdiLoggerComponentEnable(CdiLogHandle handle, CdiLogComponent component, bool enable)
Definition logger.c:1069
CDI_INTERFACE CdiReturnStatus CdiLoggerComponentEnableGlobal(CdiLogComponent component, bool enable)
Definition logger.c:1106
CDI_INTERFACE CdiReturnStatus CdiLoggerStderrEnable(bool enable, CdiLogLevel level)
Definition logger.c:1158
struct CdiLoggerState * CdiLoggerHandle
Type used as the handle (pointer to an opaque structure) for a logger instance. Each handle represent...
Definition cdi_logger_api.h:36
CDI_INTERFACE bool CdiLoggerThreadLogSet(CdiLogHandle handle)
Definition logger.c:1024
struct CdiLogState * CdiLogHandle
Type used as the handle (pointer to an opaque structure) for a log. Each handle represents an instanc...
Definition cdi_logger_api.h:42
CDI_INTERFACE void CdiLogger(CdiLogHandle handle, CdiLogComponent component, CdiLogLevel log_level, const char *function_name_str, int line_number, const char *format_str,...)
Definition logger.c:862
CDI_INTERFACE void CdiLoggerFlushAllFileLogs(void)
Definition logger.c:1204
CDI_INTERFACE CdiReturnStatus CdiLoggerLevelSet(CdiLogHandle handle, CdiLogComponent component, CdiLogLevel level)
Definition logger.c:1093
CDI_INTERFACE char * CdiLoggerMultilineGetBuffer(CdiLogMultilineState *state_ptr)
Definition logger.c:961
CDI_INTERFACE bool CdiLoggerCreateLog(CdiLoggerHandle logger_handle, CdiConnectionHandle con_handle, const CdiLogMethodData *log_method_data_ptr, CdiLogHandle *ret_log_handle_ptr)
Definition logger.c:773
CDI_INTERFACE void CdiLoggerDestroyLogger(CdiLoggerHandle logger_handle)
Definition logger.c:1197
CDI_INTERFACE void CdiLoggerMultiline(CdiLogMultilineState *state_ptr, const char *format_str,...)
Definition logger.c:909
CDI_INTERFACE void CdiLoggerMultilineEnd(CdiLogMultilineState *state_ptr)
Definition logger.c:971
CDI_INTERFACE CdiReturnStatus CdiLoggerLevelSetGlobal(CdiLogComponent component, CdiLogLevel level)
Definition logger.c:1132
This file contains the declarations for OS functions for creating/managing/freeing threads,...
The declarations in this header file correspond to the definitions in cdi_utility_api....
#define CDI_INTERFACE
Specify C linkage when compiling as C++ and define API interface export for Windows.
Definition cdi_utility_api.h:34
Structure definition behind the connection handles shared with the user's application program....
Definition private.h:371
A structure of this type is passed as the parameter to CdiLogMessageCallback(). It contains a single ...
Definition cdi_log_api.h:81
A structure of this type is used to configure the type of log method that is being used....
Definition cdi_log_api.h:63
Structure used to hold state data for a multiline log message.
Definition cdi_logger_api.h:52
int line_number
Line number in file where log was called.
Definition cdi_logger_api.h:60
CdiLogLevel log_level
Current log level for log_handle.
Definition cdi_logger_api.h:57
CdiLogHandle log_handle
Handle to log being accessed.
Definition cdi_logger_api.h:54
CdiMultilineLogBufferState * buffer_state_ptr
Pointer to log message buffer structure.
Definition cdi_logger_api.h:63
bool logging_enabled
When true, logging is enabled for this log_handle.
Definition cdi_logger_api.h:53
int line_count
Number of log lines in the log message buffer.
Definition cdi_logger_api.h:62
CdiLogComponent component
Selects the SDK component type for logging.
Definition cdi_logger_api.h:56
bool buffer_used
Buffer was used, so don't generate output when ending using CdiLoggerMultilineEnd().
Definition cdi_logger_api.h:65
Structure used to hold state data for a single log of any type (stdout, callback or file).
Definition logger.c:79
Structure used to hold state data for a single logger.
Definition logger.c:43
Structure used to hold a buffer for a multiline log message.
Definition logger.c:105