C Standard Library Extensions
1.2.3
|
36 #define CX_LOG_LEVEL_USER_SHIFT (8)
46 CX_LOG_FLAG_RECURSION = 1 << 0,
47 CX_LOG_FLAG_FATAL = 1 << 1,
50 CX_LOG_LEVEL_ERROR = 1 << 2,
51 CX_LOG_LEVEL_CRITICAL = 1 << 3,
52 CX_LOG_LEVEL_WARNING = 1 << 4,
53 CX_LOG_LEVEL_MESSAGE = 1 << 5,
54 CX_LOG_LEVEL_INFO = 1 << 6,
55 CX_LOG_LEVEL_DEBUG = 1 << 7,
57 CX_LOG_LEVEL_MASK = ~(CX_LOG_FLAG_RECURSION | CX_LOG_FLAG_FATAL)
60 #define CX_LOG_FATAL_MASK (CX_LOG_FLAG_RECURSION | CX_LOG_LEVEL_ERROR)
67 typedef void (*cx_log_func) (
const cxchar *, cx_log_level_flags,
68 const cxchar *, cxptr);
69 typedef void (*cx_print_func) (
const cxchar *);
77 const cxchar *, cxptr);
89 void cx_log(
const cxchar *, cx_log_level_flags,
90 const cxchar *, ...) CX_GNUC_PRINTF(3, 4);
91 void cx_logv(const cxchar *, cx_log_level_flags,
92 const cxchar *, va_list) CX_GNUC_PRINTF(3, 0);
97 void cx_print(const cxchar *, ...) CX_GNUC_PRINTF(1, 2);
98 void cx_printerr(const cxchar *, ...) CX_GNUC_PRINTF(1, 0);
105 void cx_error(const cxchar *, ...) CX_GNUC_PRINTF(1, 2);
106 void cx_critical(const cxchar *, ...) CX_GNUC_PRINTF(1, 2);
107 void cx_warning(const cxchar *, ...) CX_GNUC_PRINTF(1, 2);
108 void cx_message(const cxchar *, ...) CX_GNUC_PRINTF(1, 2);
111 #ifndef CX_LOG_DOMAIN
112 # define CX_LOG_DOMAIN ((cxchar *)0)
120 #ifdef CX_DISABLE_ASSERT
122 # define cx_assert(expr)
127 # define cx_assert(expr) \
133 cx_log(CX_LOG_DOMAIN, CX_LOG_LEVEL_ERROR, \
134 "file %s: line %d (%s): assertion failed: (%s)", \
135 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
139 # define cx_assert(expr) \
145 cx_log(CX_LOG_DOMAIN,CX_LOG_LEVEL_ERROR, \
146 "file %s: line %d: assertion failed: (%s)", \
147 __FILE__, __LINE__, #expr); \
cxchar * cx_strvdupf(const cxchar *format, va_list args)
Create a string from a variable-length argument list under format control.
Definition: cxstrutils.c:556
void cx_message(const cxchar *format,...)
Log a normal message.
Definition: cxmessages.c:1513
struct _cx_string_ cx_string
The cx_string data type.
Definition: cxstring.h:52
cxsize cx_log_get_domain_count(void)
Get the number of registered log domains.
Definition: cxmessages.c:669
cx_log_level_flags cx_log_set_always_fatal(cx_log_level_flags mask)
Set log levels to be always fatal.
Definition: cxmessages.c:632
void cx_log(const cxchar *name, cx_log_level_flags level, const cxchar *format,...)
Log a formatted message.
Definition: cxmessages.c:1120
cxint cx_strncasecmp(const cxchar *s1, const cxchar *s2, cxsize n)
Compare the first n characters of two strings ignoring the case of ASCII characters.
Definition: cxstrutils.c:246
cxint cx_vsnprintf(cxchar *string, cxsize n, const cxchar *format, va_list args)
Safe version of vsprintf().
Definition: cxutils.c:285
cx_string * cx_string_prepend(cx_string *self, const cxchar *data)
Prepend an array of characters to the string.
Definition: cxstring.c:593
cxptr cx_malloc(cxsize nbytes)
Allocate nbytes bytes.
Definition: cxmemory.c:280
void cx_warning(const cxchar *format,...)
Log a warning.
Definition: cxmessages.c:1486
cx_print_func cx_printerr_set_handler(cx_print_func func)
Set handler for error message output.
Definition: cxmessages.c:1329
void cx_free(cxptr memory)
Memory block deallocation.
Definition: cxmemory.c:486
cx_string * cx_string_new(void)
Create a new, empty string container.
Definition: cxstring.c:232
const cxchar * cx_program_get_name(void)
Get the name of the application.
Definition: cxutils.c:97
void cx_printerr(const cxchar *format,...)
Output a formatted message via the error message handler.
Definition: cxmessages.c:1371
const cxchar * cx_log_get_domain_name(cxsize position)
Get the name of a log domain.
Definition: cxmessages.c:705
cx_log_func cx_log_set_default_handler(cx_log_func func)
Set the default log handler.
Definition: cxmessages.c:790
cx_log_level_flags cx_log_set_fatal_mask(const cxchar *name, cx_log_level_flags fatal_mask)
Sets the log message level which are fatal for a given domain.
Definition: cxmessages.c:740
cx_print_func cx_print_set_handler(cx_print_func func)
Set handler for message output.
Definition: cxmessages.c:1238
void cx_print(const cxchar *format,...)
Output a formatted message via the print handler.
Definition: cxmessages.c:1280
cxint cx_string_sprintf(cx_string *self, const char *format,...)
Writes to a string under format control.
Definition: cxstring.c:996
cxint cx_strcasecmp(const cxchar *s1, const cxchar *s2)
Compare two strings ignoring the case of ASCII characters.
Definition: cxstrutils.c:203
void cx_log_remove_handler(const cxchar *name, cxuint id)
Remove a log handler from a domain.
Definition: cxmessages.c:878
void cx_logv(const cxchar *name, cx_log_level_flags level, const cxchar *format, va_list args)
Log a formatted message using a variable-length argument.
Definition: cxmessages.c:949
void cx_log_default_handler(const cxchar *name, cx_log_level_flags level, const cxchar *message, cxptr data)
Default log handler.
Definition: cxmessages.c:1156
void cx_string_delete(cx_string *self)
Destroy a string.
Definition: cxstring.c:305
cxint cx_bits_find(cxuint32 mask, cxint start)
Get the position of the first bit set, searching from left to right.
Definition: cxutils.c:156
cxchar * cx_strdup(const cxchar *string)
Duplicate a string.
Definition: cxstrutils.c:497
cx_string * cx_string_append(cx_string *self, const cxchar *data)
Append an array of characters to the string.
Definition: cxstring.c:645
const cxchar * cx_string_get(const cx_string *self)
Get the string's value.
Definition: cxstring.c:414
void cx_error(const cxchar *format,...)
Log an error message.
Definition: cxmessages.c:1425
cxuint cx_log_set_handler(const cxchar *name, cx_log_level_flags levels, cx_log_func func, cxptr data)
Set the log handler for a log domain.
Definition: cxmessages.c:825
void cx_critical(const cxchar *format,...)
Log a "critical" warning.
Definition: cxmessages.c:1458