64# define _CLOG_ATTR_NONNULL(args...) __attribute__((nonnull(args)))
66# define _CLOG_ATTR_NONNULL(...)
70# define _CLOG_ATTR_PRINTF_FORMAT(format_param, dots_param) \
71 __attribute__((format(printf, format_param, dots_param)))
73# define _CLOG_ATTR_PRINTF_FORMAT(format_param, dots_param)
76#define STRINGIFY_ARG(x) "" #x
77#define STRINGIFY_APPEND(a, b) "" a #b
78#define STRINGIFY(x) STRINGIFY_APPEND("", x)
93#define CLG_SEVERITY_LEN (CLG_SEVERITY_FATAL + 1)
114 const char *file_line,
119 const char *file_line,
145#define CLG_LOGREF_DECLARE_GLOBAL(var, id) \
146 static CLG_LogRef _static_##var = {id}; \
147 CLG_LogRef *var = &_static_##var
150#define CLOG_ENSURE(clg_ref) \
151 ((clg_ref)->type ? (clg_ref)->type : (CLG_logref_init(clg_ref), (clg_ref)->type))
153#define CLOG_CHECK(clg_ref, verbose_level, ...) \
154 ((void)CLOG_ENSURE(clg_ref), \
155 ((clg_ref)->type->flag & CLG_FLAG_USE) && ((clg_ref)->type->level >= verbose_level))
157#define CLOG_AT_SEVERITY(clg_ref, severity, verbose_level, ...) \
159 const CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
160 if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
161 (severity >= CLG_SEVERITY_WARN)) \
163 CLG_logf(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, __VA_ARGS__); \
168#define CLOG_STR_AT_SEVERITY(clg_ref, severity, verbose_level, str) \
170 const CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \
171 if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \
172 (severity >= CLG_SEVERITY_WARN)) \
174 CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, str); \
179#define CLOG_INFO(clg_ref, level, ...) \
180 CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, __VA_ARGS__)
181#define CLOG_WARN(clg_ref, ...) CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, __VA_ARGS__)
182#define CLOG_ERROR(clg_ref, ...) CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, __VA_ARGS__)
183#define CLOG_FATAL(clg_ref, ...) CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, __VA_ARGS__)
185#define CLOG_STR_INFO(clg_ref, level, str) \
186 CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, str)
187#define CLOG_STR_WARN(clg_ref, str) CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, str)
188#define CLOG_STR_ERROR(clg_ref, str) CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, str)
189#define CLOG_STR_FATAL(clg_ref, str) CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, str)
void CLG_log_str(const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *message) _CLOG_ATTR_NONNULL(1
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
void CLG_output_set(void *file_handle)
void CLG_output_use_basename_set(int value)
void void CLG_logf(const CLG_LogType *lg, enum CLG_Severity severity, const char *file_line, const char *fn, const char *format,...) _CLOG_ATTR_NONNULL(1
void CLG_error_fn_set(void(*error_fn)(void *file_handle))
struct CLG_LogRef CLG_LogRef
void CLG_backtrace_fn_set(void(*fatal_fn)(void *file_handle))
#define _CLOG_ATTR_NONNULL(...)
struct CLG_LogType CLG_LogType
void CLG_fatal_fn_set(void(*fatal_fn)(void *file_handle))
void CLG_type_filter_include(const char *type_match, int type_match_len)
void CLG_logref_init(CLG_LogRef *clg_ref)
#define _CLOG_ATTR_PRINTF_FORMAT(format_param, dots_param)
void CLG_level_set(int level)
void CLG_output_use_timestamp_set(int value)
int CLG_color_support_get(CLG_LogRef *clg_ref)
struct CLG_LogType * next