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),
238void ws_log_init(
void (*vcmdarg_err)(
const char *, va_list ap));
248 void (*vcmdarg_err)(
const char *, va_list ap));
261 void (*vcmdarg_err)(
const char *, va_list ap));
269void ws_log(
const char *domain,
enum ws_log_level level,
270 const char *format, ...) G_GNUC_PRINTF(3,4);
278void ws_logv(const
char *domain, enum ws_log_level level,
279 const
char *format, va_list ap);
289 const
char *file,
long line, const
char *func,
290 const
char *format, ...) G_GNUC_PRINTF(6,7);
299void ws_logv_full(const
char *domain, enum ws_log_level level,
300 const
char *file,
long line, const
char *func,
301 const
char *format, va_list ap);
306void ws_log_fatal_full(const
char *domain, enum ws_log_level level,
307 const
char *file,
long line, const
char *func,
308 const
char *format, ...) G_GNUC_PRINTF(6,7);
316#define _LOG_IF_ACTIVE(active, level, file, line, func, ...) \
319 ws_log_full(_LOG_DOMAIN, level, \
325#define _LOG_FULL(active, level, ...) \
326 _LOG_IF_ACTIVE(active, level, __FILE__, __LINE__, __func__, __VA_ARGS__)
328#define _LOG_SIMPLE(active, level, ...) \
329 _LOG_IF_ACTIVE(active, level, NULL, -1, NULL, __VA_ARGS__)
337#define ws_error(...) \
338 ws_log_fatal_full(_LOG_DOMAIN, LOG_LEVEL_ERROR, \
339 __FILE__, __LINE__, __func__, __VA_ARGS__)
345#define ws_critical(...) \
346 _LOG_FULL(true, LOG_LEVEL_CRITICAL, __VA_ARGS__)
352#define ws_warning(...) \
353 _LOG_FULL(true, LOG_LEVEL_WARNING, __VA_ARGS__)
360#define ws_message(...) \
361 _LOG_SIMPLE(true, LOG_LEVEL_MESSAGE, __VA_ARGS__)
368#define ws_info(...) \
369 _LOG_SIMPLE(true, LOG_LEVEL_INFO, __VA_ARGS__)
375#define ws_debug(...) \
376 _LOG_FULL(_LOG_DEBUG_ENABLED, LOG_LEVEL_DEBUG, __VA_ARGS__)
382#define ws_noisy(...) \
383 _LOG_FULL(_LOG_DEBUG_ENABLED, LOG_LEVEL_NOISY, __VA_ARGS__)
386#define WS_DEBUG_HERE(...) \
387 _LOG_FULL(true, LOG_LEVEL_ECHO, __VA_ARGS__)
389#define WS_NOT_IMPLEMENTED() \
390 ws_error("Not implemented yet")
393void ws_log_utf8_full(
const char *domain,
enum ws_log_level level,
394 const char *file,
long line,
const char *func,
395 const char *
string, ssize_t length,
const char *endptr);
398#define ws_log_utf8(str, len, endptr) \
400 if (_LOG_DEBUG_ENABLED) { \
401 ws_log_utf8_full(LOG_DOMAIN_UTF_8, LOG_LEVEL_DEBUG, \
402 __FILE__, __LINE__, __func__, \
414 const char *file,
long line,
const char *func,
415 const uint8_t *
buffer,
size_t size,
416 size_t max_bytes_len,
const char *msg);
419#define ws_log_buffer(buf, size, msg) \
421 if (_LOG_DEBUG_ENABLED) { \
422 ws_log_buffer_full(_LOG_DOMAIN, LOG_LEVEL_DEBUG, \
423 __FILE__, __LINE__, __func__, \
424 buf, size, 36, msg ? msg : #buf); \
438 const char *file,
long line,
const char *func,
439 const char *format, ...) G_GNUC_PRINTF(6,7);
452void 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_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:1367
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:1148
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:1320
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_log_init(void(*vcmdarg_err)(const char *, va_list ap))
Definition wslog.c:847
WS_DLL_PUBLIC void WS_DLL_PUBLIC void ws_log_add_custom_file(FILE *fp)
Definition wslog.c:1390
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_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_log_init_with_writer(ws_log_writer_cb *writer, void(*vcmdarg_err)(const char *, va_list ap))
Definition wslog.c:923
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:1137
WS_DLL_PUBLIC void ws_log_init_with_writer_and_data(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:931
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