22#include <ws_symbol_export.h>
23#include <ws_attributes.h>
24#include <ws_log_defs.h>
25#include <ws_posix_compat.h>
28#define _LOG_DOMAIN WS_LOG_DOMAIN
34#define _LOG_DEBUG_ENABLED true
36#define _LOG_DEBUG_ENABLED false
53#define LOG_HKCU_CONSOLE_OPEN "ConsoleOpen"
56 LOG_CONSOLE_OPEN_NEVER,
57 LOG_CONSOLE_OPEN_AUTO,
58 LOG_CONSOLE_OPEN_ALWAYS,
59} ws_log_console_open_pref;
62ws_log_console_open_pref ws_log_console_open;
65 struct tm tstamp_secs;
72 const char *file,
long line,
const char *func,
74 const char *user_format, va_list user_ap,
83void ws_log_file_writer(FILE *fp,
const char *domain,
enum ws_log_level level,
84 const char *file,
long line,
const char *func,
86 const char *user_format, va_list user_ap);
90void ws_log_console_writer(
const char *domain,
enum ws_log_level level,
91 const char *file,
long line,
const char *func,
93 const char *user_format, va_list user_ap);
219#define LOG_ARGS_NOEXIT -1
227 void (*vcmdarg_err)(
const char *, va_list ap),
239 void (*vcmdarg_err)(
const char *, va_list ap));
250 void (*vcmdarg_err)(
const char *, va_list ap));
264 void (*vcmdarg_err)(
const char *, va_list ap));
272void ws_log(
const char *domain,
enum ws_log_level level,
273 const char *format, ...) G_GNUC_PRINTF(3,4);
281void ws_logv(const
char *domain, enum ws_log_level level,
282 const
char *format, va_list ap);
292 const
char *file,
long line, const
char *func,
293 const
char *format, ...) G_GNUC_PRINTF(6,7);
302void ws_logv_full(const
char *domain, enum ws_log_level level,
303 const
char *file,
long line, const
char *func,
304 const
char *format, va_list ap);
309void ws_log_fatal_full(const
char *domain, enum ws_log_level level,
310 const
char *file,
long line, const
char *func,
311 const
char *format, ...) G_GNUC_PRINTF(6,7);
319#define _LOG_IF_ACTIVE(active, level, file, line, func, ...) \
322 ws_log_full(_LOG_DOMAIN, level, \
328#define _LOG_FULL(active, level, ...) \
329 _LOG_IF_ACTIVE(active, level, __FILE__, __LINE__, __func__, __VA_ARGS__)
331#define _LOG_SIMPLE(active, level, ...) \
332 _LOG_IF_ACTIVE(active, level, NULL, -1, NULL, __VA_ARGS__)
340#define ws_error(...) \
341 ws_log_fatal_full(_LOG_DOMAIN, LOG_LEVEL_ERROR, \
342 __FILE__, __LINE__, __func__, __VA_ARGS__)
348#define ws_critical(...) \
349 _LOG_FULL(true, LOG_LEVEL_CRITICAL, __VA_ARGS__)
355#define ws_warning(...) \
356 _LOG_FULL(true, LOG_LEVEL_WARNING, __VA_ARGS__)
363#define ws_message(...) \
364 _LOG_SIMPLE(true, LOG_LEVEL_MESSAGE, __VA_ARGS__)
371#define ws_info(...) \
372 _LOG_SIMPLE(true, LOG_LEVEL_INFO, __VA_ARGS__)
378#define ws_debug(...) \
379 _LOG_FULL(_LOG_DEBUG_ENABLED, LOG_LEVEL_DEBUG, __VA_ARGS__)
385#define ws_noisy(...) \
386 _LOG_FULL(_LOG_DEBUG_ENABLED, LOG_LEVEL_NOISY, __VA_ARGS__)
389#define WS_DEBUG_HERE(...) \
390 _LOG_FULL(true, LOG_LEVEL_ECHO, __VA_ARGS__)
392#define WS_NOT_IMPLEMENTED() \
393 ws_error("Not implemented yet")
396void ws_log_utf8_full(
const char *domain,
enum ws_log_level level,
397 const char *file,
long line,
const char *func,
398 const char *
string, ssize_t length,
const char *endptr);
401#define ws_log_utf8(str, len, endptr) \
403 if (_LOG_DEBUG_ENABLED) { \
404 ws_log_utf8_full(LOG_DOMAIN_UTF_8, LOG_LEVEL_DEBUG, \
405 __FILE__, __LINE__, __func__, \
417 const char *file,
long line,
const char *func,
418 const uint8_t *
buffer,
size_t size,
419 size_t max_bytes_len,
const char *msg);
422#define ws_log_buffer(buf, size) \
424 if (_LOG_DEBUG_ENABLED) { \
425 ws_log_buffer_full(_LOG_DOMAIN, LOG_LEVEL_DEBUG, \
426 __FILE__, __LINE__, __func__, \
427 buf, size, 36, #buf); \
441 const char *file,
long line,
const char *func,
442 const char *format, ...) G_GNUC_PRINTF(6,7);
455void ws_log_print_usage(FILE *fp);
Definition mcast_stream.h:30
WS_DLL_PUBLIC void ws_log(const char *domain, enum ws_log_level level, const char *format,...) G_GNUC_PRINTF(3
WS_DLL_PUBLIC void ws_log_init_with_writer_and_data(const char *progname, ws_log_writer_cb *writer, void *user_data, ws_log_writer_free_data_cb *free_user_data, void(*vcmdarg_err)(const char *, va_list ap))
Definition wslog.c:936
WS_DLL_PUBLIC void ws_log_set_writer_with_data(ws_log_writer_cb *writer, void *user_data, ws_log_writer_free_data_cb *free_user_data)
Definition wslog.c:775
WS_DLL_PUBLIC void ws_log_set_domain_filter(const char *domain_filter)
Definition wslog.c:713
WS_DLL_PUBLIC void ws_log_set_debug_filter(const char *str_filter)
Definition wslog.c:727
void() ws_log_writer_free_data_cb(void *user_data)
Definition wslog.h:79
WS_DLL_PUBLIC void ws_log_set_fatal_domain_filter(const char *domain_filter)
Definition wslog.c:720
WS_DLL_PUBLIC void ws_log_console_writer_set_use_stdout(bool use_stdout)
Definition wslog.c:1373
WS_DLL_PUBLIC enum ws_log_level ws_log_set_level(enum ws_log_level level)
Definition wslog.c:350
WS_DLL_PUBLIC void ws_log_set_noisy_filter(const char *str_filter)
Definition wslog.c:734
WS_DLL_PUBLIC void WS_DLL_PUBLIC void ws_logv_full(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, const char *format, va_list ap)
Definition wslog.c:1154
WS_DLL_PUBLIC int ws_log_parse_args(int *argc_ptr, char *argv[], void(*vcmdarg_err)(const char *, va_list ap), int exit_failure)
Definition wslog.c:502
WS_DLL_PUBLIC void ws_log_write_always_full(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, const char *format,...) G_GNUC_PRINTF(6
void() ws_log_writer_cb(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, const char *fatal_msg, ws_log_manifest_t *mft, const char *user_format, va_list user_ap, void *user_data)
Definition wslog.h:71
WS_DLL_PUBLIC void ws_log_buffer_full(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, const uint8_t *buffer, size_t size, size_t max_bytes_len, const char *msg)
Definition wslog.c:1326
WS_DLL_PUBLIC enum ws_log_level ws_log_set_fatal_level(enum ws_log_level level)
Definition wslog.c:741
WS_DLL_PUBLIC void WS_DLL_PUBLIC void ws_log_add_custom_file(FILE *fp)
Definition wslog.c:1396
WS_DLL_PUBLIC WS_RETNONNULL const char * ws_log_level_to_string(enum ws_log_level level)
Definition wslog.c:136
WS_DLL_PUBLIC void ws_log_init(const char *progname, void(*vcmdarg_err)(const char *, va_list ap))
Definition wslog.c:847
WS_DLL_PUBLIC void ws_log_full(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, const char *format,...) G_GNUC_PRINTF(6
WS_DLL_PUBLIC void WS_DLL_PUBLIC void ws_logv(const char *domain, enum ws_log_level level, const char *format, va_list ap)
Definition wslog.c:1143
WS_DLL_PUBLIC void ws_log_init_with_writer(const char *progname, ws_log_writer_cb *writer, void(*vcmdarg_err)(const char *, va_list ap))
Definition wslog.c:927
WS_DLL_PUBLIC enum ws_log_level ws_log_get_level(void)
Definition wslog.c:344
WS_DLL_PUBLIC void ws_log_set_writer(ws_log_writer_cb *writer)
Definition wslog.c:764
WS_DLL_PUBLIC bool ws_log_msg_is_active(const char *domain, enum ws_log_level level)
Definition wslog.c:278
WS_DLL_PUBLIC enum ws_log_level ws_log_set_fatal_level_str(const char *str_level)
Definition wslog.c:755
WS_DLL_PUBLIC enum ws_log_level ws_log_set_level_str(const char *str_level)
Definition wslog.c:362