76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
#ifndef _NWLOG_H_
|
|
#define _NWLOG_H_
|
|
|
|
/*
|
|
* Common logging facade vocabulary and first libnwcore logging API.
|
|
*
|
|
* Runtime configuration uses cumulative level names/masks:
|
|
* off/0, error/1, warn/12, info/123, debug/1234 and trace/12345.
|
|
* Detail logging is maintainer-only and is not enabled by nw.ini.
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum nwlog_level_e {
|
|
NWLOG_LEVEL_ERROR = 1,
|
|
NWLOG_LEVEL_WARN = 2,
|
|
NWLOG_LEVEL_INFO = 3,
|
|
NWLOG_LEVEL_DEBUG = 4,
|
|
NWLOG_LEVEL_TRACE = 5,
|
|
|
|
/* Collapse target for useful legacy XDPRINTF levels 6..99. */
|
|
NWLOG_LEVEL_DETAIL = 6
|
|
} NwLogLevel;
|
|
|
|
void nwlog_set_process_name(const char *name);
|
|
void nwlog_set_level_mask(unsigned int mask);
|
|
unsigned int nwlog_get_level_mask(void);
|
|
unsigned int nwlog_parse_level_mask(const char *text, unsigned int fallback);
|
|
int nwlog_enabled(NwLogLevel level);
|
|
const char *nwlog_level_name(NwLogLevel level);
|
|
|
|
int nwlog_emit(NwLogLevel level, const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 3, 4)))
|
|
#endif
|
|
;
|
|
|
|
int nwlog_error(const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 2, 3)))
|
|
#endif
|
|
;
|
|
int nwlog_warn(const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 2, 3)))
|
|
#endif
|
|
;
|
|
int nwlog_info(const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 2, 3)))
|
|
#endif
|
|
;
|
|
int nwlog_debug(const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 2, 3)))
|
|
#endif
|
|
;
|
|
int nwlog_trace(const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 2, 3)))
|
|
#endif
|
|
;
|
|
int nwlog_detail(const char *subsystem, const char *fmt, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 2, 3)))
|
|
#endif
|
|
;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|