22#include <ws_symbol_export.h>
23#include <ws_attributes.h>
24#include <ws_log_defs.h>
25#include <ws_posix_compat.h>
29#define _LOG_DOMAIN WS_LOG_DOMAIN
35#define _LOG_DEBUG_ENABLED true
37#define _LOG_DEBUG_ENABLED false
54#define LOG_HKCU_CONSOLE_OPEN "ConsoleOpen"
85 const char *file,
long line,
const char *func,
87 const char *user_format, va_list user_ap,
109 const char *file,
long line,
const char *func,
111 const char *user_format, va_list user_ap);
127 const char *file,
long line,
const char *func,
129 const char *user_format, va_list user_ap);
338#define LOG_ARGS_NOEXIT -1
340#define LONGOPT_WSLOG_LOG_LEVEL LONGOPT_BASE_WSLOG+1
341#define LONGOPT_WSLOG_LOG_DOMAIN LONGOPT_BASE_WSLOG+2
342#define LONGOPT_WSLOG_LOG_FILE LONGOPT_BASE_WSLOG+3
343#define LONGOPT_WSLOG_LOG_FATAL LONGOPT_BASE_WSLOG+4
344#define LONGOPT_WSLOG_LOG_FATAL_COUNT LONGOPT_BASE_WSLOG+5
345#define LONGOPT_WSLOG_LOG_FATAL_DOMAIN LONGOPT_BASE_WSLOG+6
346#define LONGOPT_WSLOG_LOG_DEBUG LONGOPT_BASE_WSLOG+7
347#define LONGOPT_WSLOG_LOG_NOISY LONGOPT_BASE_WSLOG+8
351#define LONGOPT_WSLOG \
352 {"log-level", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_LEVEL}, \
353 {"log-domain", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_DOMAIN}, \
355 {"log-domains", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_DOMAIN}, \
356 {"log-file", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_FILE}, \
357 {"log-fatal", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_FATAL}, \
358 {"log-fatal-count", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_FATAL_COUNT}, \
360 {"log-fatal-domain", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_FATAL_DOMAIN}, \
361 {"log-fatal-domains", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_FATAL_DOMAIN}, \
362 {"log-debug", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_DEBUG}, \
363 {"log-noisy", ws_required_argument, NULL, LONGOPT_WSLOG_LOG_NOISY},
382 const char* optstring,
const struct ws_option* long_options,
383 void (*vcmdarg_err)(
const char *, va_list ap),
411void ws_log_init(
void (*vcmdarg_err)(
const char *, va_list ap),
const char* console_title);
426 void (*vcmdarg_err)(
const char *, va_list ap),
const char* console_title);
446 void (*vcmdarg_err)(
const char *, va_list ap),
const char* console_title);
462void ws_log(
const char *domain,
enum ws_log_level level,
463 const char *format, ...) G_GNUC_PRINTF(3,4);
478void ws_logv(const
char *domain, enum ws_log_level level,
479 const
char *format, va_list ap);
499void ws_log_full(const
char *domain, enum ws_log_level level,
500 const
char *file,
long line, const
char *func,
501 const
char *format, ...) G_GNUC_PRINTF(6,7);
520void ws_logv_full(const
char *domain, enum ws_log_level level,
521 const
char *file,
long line, const
char *func,
522 const
char *format, va_list ap);
542void ws_log_fatal_full(const
char *domain, enum ws_log_level level,
543 const
char *file,
long line, const
char *func,
544 const
char *format, ...) G_GNUC_PRINTF(6,7);
552#define _LOG_IF_ACTIVE(active, level, file, line, func, ...) \
555 ws_log_full(_LOG_DOMAIN, level, \
561#define _LOG_FULL(active, level, ...) \
562 _LOG_IF_ACTIVE(active, level, __FILE__, __LINE__, __func__, __VA_ARGS__)
564#define _LOG_SIMPLE(active, level, ...) \
565 _LOG_IF_ACTIVE(active, level, NULL, -1, NULL, __VA_ARGS__)
576#define ws_error(...) \
577 ws_log_fatal_full(_LOG_DOMAIN, LOG_LEVEL_ERROR, \
578 __FILE__, __LINE__, __func__, __VA_ARGS__)
590#define ws_critical(...) \
591 _LOG_FULL(true, LOG_LEVEL_CRITICAL, __VA_ARGS__)
603#define ws_warning(...) \
604 _LOG_FULL(true, LOG_LEVEL_WARNING, __VA_ARGS__)
616#define ws_message(...) \
617 _LOG_SIMPLE(true, LOG_LEVEL_MESSAGE, __VA_ARGS__)
629#define ws_info(...) \
630 _LOG_SIMPLE(true, LOG_LEVEL_INFO, __VA_ARGS__)
643#define ws_debug(...) \
644 _LOG_FULL(_LOG_DEBUG_ENABLED, LOG_LEVEL_DEBUG, __VA_ARGS__)
657#define ws_noisy(...) \
658 _LOG_FULL(_LOG_DEBUG_ENABLED, LOG_LEVEL_NOISY, __VA_ARGS__)
670#define WS_DEBUG_HERE(...) \
671 _LOG_FULL(true, LOG_LEVEL_ECHO, __VA_ARGS__)
680#define WS_NOT_IMPLEMENTED() \
681 ws_error("Not implemented yet")
702 const char *file,
long line,
const char *func,
703 const char *
string, ssize_t length,
const char *endptr);
718#define ws_log_utf8(str, len, endptr) \
720 if (_LOG_DEBUG_ENABLED) { \
721 ws_log_utf8_full(LOG_DOMAIN_UTF_8, LOG_LEVEL_DEBUG, \
722 __FILE__, __LINE__, __func__, \
747 const char *file,
long line,
const char *func,
748 const uint8_t *
buffer,
size_t size,
749 size_t max_bytes_len,
const char *msg);
763#define ws_log_buffer(buf, size, msg) \
765 if (_LOG_DEBUG_ENABLED) { \
766 ws_log_buffer_full(_LOG_DOMAIN, LOG_LEVEL_DEBUG, \
767 __FILE__, __LINE__, __func__, \
768 buf, size, 36, msg ? msg : #buf); \
790 const char *file,
long line,
const char *func,
791 const char *format, ...) G_GNUC_PRINTF(6,7);
803void ws_log_add_custom_file(FILE *fp);
815void ws_log_print_usage(FILE *fp);
Sliding window buffer tracking per-stream burst and bandwidth statistics.
Definition mcast_stream.h:34
Log manifest entry containing timestamp and process ID.
Definition wslog.h:77
intmax_t pid
Definition wslog.h:80
long nanosecs
Definition wslog.h:79
struct tm tstamp_secs
Definition wslog.h:78
Structure representing a long-form command-line option.
Definition ws_getopt.h:64
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)
Set the active log writer with user data.
Definition wslog.c:654
WS_DLL_PUBLIC void ws_log_set_domain_filter(const char *domain_filter)
Set a domain filter from a string.
Definition wslog.c:573
WS_DLL_PUBLIC void ws_log_console_writer(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, ws_log_manifest_t *mft, const char *user_format, va_list user_ap)
Write a formatted log message to the console.
Definition wslog.c:1246
WS_DLL_PUBLIC void ws_log_set_debug_filter(const char *str_filter)
Set a debug filter from a string.
Definition wslog.c:587
WS_DLL_PUBLIC void ws_log_set_fatal_count(uint32_t count)
Set the fatal log count.
Definition wslog.c:623
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,...)
Emit a log message unconditionally with full source context.
Definition wslog.c:1098
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), const char *console_title)
Initialize the logging system with a custom writer and user data.
Definition wslog.c:822
WS_DLL_PUBLIC void ws_log_file_writer(FILE *fp, const char *domain, enum ws_log_level level, const char *file, long line, const char *func, ws_log_manifest_t *mft, const char *user_format, va_list user_ap)
Write a formatted log message to a file stream.
Definition wslog.c:1234
ws_log_console_open_pref
Console open preference for logging output.
Definition wslog.h:61
@ LOG_CONSOLE_OPEN_ALWAYS
Definition wslog.h:64
@ LOG_CONSOLE_OPEN_NEVER
Definition wslog.h:62
@ LOG_CONSOLE_OPEN_AUTO
Definition wslog.h:63
WS_DLL_PUBLIC void ws_log_init(void(*vcmdarg_err)(const char *, va_list ap), const char *console_title)
Initialize the logging system.
WS_DLL_PUBLIC void ws_log_set_fatal_domain_filter(const char *domain_filter)
Set a fatal domain filter from a string.
Definition wslog.c:580
WS_DLL_PUBLIC void ws_log_console_writer_set_use_stdout(bool use_stdout)
Configure log levels "info" and below to use stdout.
Definition wslog.c:1259
WS_DLL_PUBLIC enum ws_log_level ws_log_set_level(enum ws_log_level level)
Set the active log level.
Definition wslog.c:357
void ws_log_writer_free_data_cb(void *user_data)
Definition wslog.h:92
WS_DLL_PUBLIC void ws_log_set_noisy_filter(const char *str_filter)
Set a noisy filter from a string.
Definition wslog.c:594
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:84
WS_DLL_PUBLIC int ws_log_parse_args(int *argc_ptr, char *argv[], const char *optstring, const struct ws_option *long_options, void(*vcmdarg_err)(const char *, va_list ap), int exit_failure)
Parse command-line arguments for log options.
Definition wslog.c:394
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)
Output a formatted log message for a byte buffer with source context.
Definition wslog.c:1212
WS_DLL_PUBLIC enum ws_log_level ws_log_set_fatal_level(enum ws_log_level level)
Set the fatal log level.
Definition wslog.c:601
WS_DLL_PUBLIC WS_RETNONNULL const char * ws_log_level_to_string(enum ws_log_level level)
Convert a numerical log level to its string representation.
Definition wslog.c:143
WS_DLL_PUBLIC void ws_log(const char *domain, enum ws_log_level level, const char *format,...)
Output a formatted message to the log.
Definition wslog.c:1052
WS_DLL_PUBLIC bool ws_log_is_wslog_arg(int arg)
Determine if a command-line argument is used by wslog.
Definition wslog.c:515
WS_DLL_PUBLIC void ws_log_utf8_full(const char *domain, enum ws_log_level level, const char *file, long line, const char *func, const char *string, ssize_t length, const char *endptr)
Output a UTF-8 encoded log message with source context.
Definition wslog.c:1177
WS_DLL_PUBLIC enum ws_log_level ws_log_get_level(void)
Get the currently active global log level.
Definition wslog.c:351
WS_DLL_PUBLIC void ws_log_init_with_writer(ws_log_writer_cb *writer, void(*vcmdarg_err)(const char *, va_list ap), const char *console_title)
Initialize the logging system with a custom writer.
Definition wslog.c:814
WS_DLL_PUBLIC bool ws_log_set_fatal_count_str(const char *str_count)
Set the fatal log count from a string.
Definition wslog.c:628
WS_DLL_PUBLIC void ws_log_set_writer(ws_log_writer_cb *writer)
Set the active log writer.
Definition wslog.c:643
WS_DLL_PUBLIC bool ws_log_msg_is_active(const char *domain, enum ws_log_level level)
Check if a log message will be output for a given domain and level.
Definition wslog.c:285
WS_DLL_PUBLIC enum ws_log_level ws_log_set_fatal_level_str(const char *str_level)
Set the fatal log level from a string.
Definition wslog.c:615
WS_DLL_PUBLIC enum ws_log_level ws_log_set_level_str(const char *str_level)
Set the active log level from a string.
Definition wslog.c:369