#ifndef _NWLOG_H_ #define _NWLOG_H_ #include #include /* * 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); int nwlog_set_output_path(const char *path); void nwlog_set_output_file(FILE *fp); void nwlog_close_output(void); 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_emitv(NwLogLevel level, const char *subsystem, const char *fmt, va_list ap); 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