123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937 |
- #pragma once
- #ifndef _ZF_LOG_H_
- #define _ZF_LOG_H_
- #define ZF_LOG_VERSION 4
- #if defined(ZF_LOG_VERSION_REQUIRED)
- #if ZF_LOG_VERSION_REQUIRED != ZF_LOG_VERSION
- #error different zf_log version required
- #endif
- #endif
- #define ZF_LOG_VERBOSE 1
- #define ZF_LOG_DEBUG 2
- #define ZF_LOG_INFO 3
- #define ZF_LOG_WARN 4
- #define ZF_LOG_ERROR 5
- #define ZF_LOG_FATAL 6
- #define ZF_LOG_NONE 0xFF
- #if defined(ZF_LOG_LEVEL)
- #define _ZF_LOG_LEVEL ZF_LOG_LEVEL
- #elif defined(ZF_LOG_DEF_LEVEL)
- #define _ZF_LOG_LEVEL ZF_LOG_DEF_LEVEL
- #else
- #ifdef NDEBUG
- #define _ZF_LOG_LEVEL ZF_LOG_INFO
- #else
- #define _ZF_LOG_LEVEL ZF_LOG_DEBUG
- #endif
- #endif
- #if defined(ZF_LOG_OUTPUT_LEVEL)
- #define _ZF_LOG_OUTPUT_LEVEL ZF_LOG_OUTPUT_LEVEL
- #else
- #define _ZF_LOG_OUTPUT_LEVEL _zf_log_global_output_lvl
- #endif
- #if defined(ZF_LOG_TAG)
- #define _ZF_LOG_TAG ZF_LOG_TAG
- #elif defined(ZF_LOG_DEF_TAG)
- #define _ZF_LOG_TAG ZF_LOG_DEF_TAG
- #else
- #define _ZF_LOG_TAG 0
- #endif
- #define ZF_LOG_SRCLOC_NONE 0
- #define ZF_LOG_SRCLOC_SHORT 1
- #define ZF_LOG_SRCLOC_LONG 2
- #if defined(ZF_LOG_SRCLOC)
- #define _ZF_LOG_SRCLOC ZF_LOG_SRCLOC
- #elif defined(ZF_LOG_DEF_SRCLOC)
- #define _ZF_LOG_SRCLOC ZF_LOG_DEF_SRCLOC
- #else
- #ifdef NDEBUG
- #define _ZF_LOG_SRCLOC ZF_LOG_SRCLOC_NONE
- #else
- #define _ZF_LOG_SRCLOC ZF_LOG_SRCLOC_LONG
- #endif
- #endif
- #if ZF_LOG_SRCLOC_LONG == _ZF_LOG_SRCLOC
- #define _ZF_LOG_SRCLOC_FUNCTION _ZF_LOG_FUNCTION
- #else
- #define _ZF_LOG_SRCLOC_FUNCTION 0
- #endif
- #define ZF_LOG_CENSORED 1
- #define ZF_LOG_UNCENSORED 0
- #if defined(ZF_LOG_CENSORING)
- #define _ZF_LOG_CENSORING ZF_LOG_CENSORING
- #elif defined(ZF_LOG_DEF_CENSORING)
- #define _ZF_LOG_CENSORING ZF_LOG_DEF_CENSORING
- #else
- #ifdef NDEBUG
- #define _ZF_LOG_CENSORING ZF_LOG_CENSORED
- #else
- #define _ZF_LOG_CENSORING ZF_LOG_UNCENSORED
- #endif
- #endif
- #define ZF_LOG_SECRETS (ZF_LOG_UNCENSORED == _ZF_LOG_CENSORING)
- #define ZF_LOG_DEFINE_TAG_PREFIX const char *_zf_log_tag_prefix
- #define ZF_LOG_DEFINE_GLOBAL_FORMAT zf_log_format _zf_log_global_format
- #define ZF_LOG_DEFINE_GLOBAL_OUTPUT zf_log_output _zf_log_global_output
- #define ZF_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL int _zf_log_global_output_lvl
- #define ZF_LOG_GLOBAL_FORMAT ((const zf_log_format *)&_zf_log_global_format)
- #define ZF_LOG_GLOBAL_OUTPUT ((const zf_log_output *)&_zf_log_global_output)
- #ifdef ZF_LOG_LIBRARY_PREFIX
- #define _ZF_LOG_DECOR__(prefix, name) prefix ## name
- #define _ZF_LOG_DECOR_(prefix, name) _ZF_LOG_DECOR__(prefix, name)
- #define _ZF_LOG_DECOR(name) _ZF_LOG_DECOR_(ZF_LOG_LIBRARY_PREFIX, name)
- #define zf_log_set_tag_prefix _ZF_LOG_DECOR(zf_log_set_tag_prefix)
- #define zf_log_set_mem_width _ZF_LOG_DECOR(zf_log_set_mem_width)
- #define zf_log_set_output_level _ZF_LOG_DECOR(zf_log_set_output_level)
- #define zf_log_set_output_v _ZF_LOG_DECOR(zf_log_set_output_v)
- #define zf_log_set_output_p _ZF_LOG_DECOR(zf_log_set_output_p)
- #define zf_log_out_stderr_callback _ZF_LOG_DECOR(zf_log_out_stderr_callback)
- #define _zf_log_tag_prefix _ZF_LOG_DECOR(_zf_log_tag_prefix)
- #define _zf_log_global_format _ZF_LOG_DECOR(_zf_log_global_format)
- #define _zf_log_global_output _ZF_LOG_DECOR(_zf_log_global_output)
- #define _zf_log_global_output_lvl _ZF_LOG_DECOR(_zf_log_global_output_lvl)
- #define _zf_log_write_d _ZF_LOG_DECOR(_zf_log_write_d)
- #define _zf_log_write_aux_d _ZF_LOG_DECOR(_zf_log_write_aux_d)
- #define _zf_log_write _ZF_LOG_DECOR(_zf_log_write)
- #define _zf_log_write_aux _ZF_LOG_DECOR(_zf_log_write_aux)
- #define _zf_log_write_mem_d _ZF_LOG_DECOR(_zf_log_write_mem_d)
- #define _zf_log_write_mem_aux_d _ZF_LOG_DECOR(_zf_log_write_mem_aux_d)
- #define _zf_log_write_mem _ZF_LOG_DECOR(_zf_log_write_mem)
- #define _zf_log_write_mem_aux _ZF_LOG_DECOR(_zf_log_write_mem_aux)
- #define _zf_log_stderr_spec _ZF_LOG_DECOR(_zf_log_stderr_spec)
- #endif
- #if defined(__printflike)
- #define _ZF_LOG_PRINTFLIKE(a, b) __printflike(a, b)
- #else
- #define _ZF_LOG_PRINTFLIKE(a, b)
- #endif
- #if (defined(_WIN32) || defined(_WIN64)) && !defined(__GNUC__)
- #define _ZF_LOG_FUNCTION __FUNCTION__
- #else
- #define _ZF_LOG_FUNCTION __func__
- #endif
- #if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
- #define _ZF_LOG_INLINE __inline
- #define _ZF_LOG_IF(cond) \
- __pragma(warning(push)) \
- __pragma(warning(disable:4127)) \
- if(cond) \
- __pragma(warning(pop))
- #define _ZF_LOG_WHILE(cond) \
- __pragma(warning(push)) \
- __pragma(warning(disable:4127)) \
- while(cond) \
- __pragma(warning(pop))
- #else
- #define _ZF_LOG_INLINE inline
- #define _ZF_LOG_IF(cond) if(cond)
- #define _ZF_LOG_WHILE(cond) while(cond)
- #endif
- #define _ZF_LOG_NEVER _ZF_LOG_IF(0)
- #define _ZF_LOG_ONCE _ZF_LOG_WHILE(0)
- #ifdef __cplusplus
- extern "C" {
- #endif
- void zf_log_set_tag_prefix(const char *const prefix);
- void zf_log_set_mem_width(const unsigned w);
- void zf_log_set_output_level(const int lvl);
- enum
- {
- ZF_LOG_PUT_CTX = 1 << 0,
- ZF_LOG_PUT_TAG = 1 << 1,
- ZF_LOG_PUT_SRC = 1 << 2,
- ZF_LOG_PUT_MSG = 1 << 3,
- ZF_LOG_PUT_STD = 0xffff,
- };
- typedef struct zf_log_message
- {
- int lvl;
- const char *tag;
- char *buf;
- char *e;
- char *p;
- char *tag_b;
- char *tag_e;
- char *msg_b;
- }
- zf_log_message;
- typedef void (*zf_log_output_cb)(const zf_log_message *msg, void *arg);
- typedef struct zf_log_format
- {
- unsigned mem_width;
- }
- zf_log_format;
- typedef struct zf_log_output
- {
- unsigned mask;
- void *arg;
- zf_log_output_cb callback;
- }
- zf_log_output;
- void zf_log_set_output_v(const unsigned mask, void *const arg,
- const zf_log_output_cb callback);
- static _ZF_LOG_INLINE void zf_log_set_output_p(const zf_log_output *const output)
- {
- zf_log_set_output_v(output->mask, output->arg, output->callback);
- }
- typedef struct zf_log_spec
- {
- const zf_log_format *format;
- const zf_log_output *output;
- }
- zf_log_spec;
- #ifdef __cplusplus
- }
- #endif
- #define ZF_LOG_IF(cond, f) do { _ZF_LOG_IF((cond)) { f; } } _ZF_LOG_ONCE
- #define ZF_LOG_SECRET(f) ZF_LOG_IF(ZF_LOG_SECRETS, f)
- #define ZF_LOG_ENABLED(lvl) ((lvl) >= _ZF_LOG_LEVEL)
- #define ZF_LOG_ENABLED_VERBOSE ZF_LOG_ENABLED(ZF_LOG_VERBOSE)
- #define ZF_LOG_ENABLED_DEBUG ZF_LOG_ENABLED(ZF_LOG_DEBUG)
- #define ZF_LOG_ENABLED_INFO ZF_LOG_ENABLED(ZF_LOG_INFO)
- #define ZF_LOG_ENABLED_WARN ZF_LOG_ENABLED(ZF_LOG_WARN)
- #define ZF_LOG_ENABLED_ERROR ZF_LOG_ENABLED(ZF_LOG_ERROR)
- #define ZF_LOG_ENABLED_FATAL ZF_LOG_ENABLED(ZF_LOG_FATAL)
- #define ZF_LOG_ON(lvl) \
- (ZF_LOG_ENABLED((lvl)) && (lvl) >= _ZF_LOG_OUTPUT_LEVEL)
- #define ZF_LOG_ON_VERBOSE ZF_LOG_ON(ZF_LOG_VERBOSE)
- #define ZF_LOG_ON_DEBUG ZF_LOG_ON(ZF_LOG_DEBUG)
- #define ZF_LOG_ON_INFO ZF_LOG_ON(ZF_LOG_INFO)
- #define ZF_LOG_ON_WARN ZF_LOG_ON(ZF_LOG_WARN)
- #define ZF_LOG_ON_ERROR ZF_LOG_ON(ZF_LOG_ERROR)
- #define ZF_LOG_ON_FATAL ZF_LOG_ON(ZF_LOG_FATAL)
- #ifdef __cplusplus
- extern "C" {
- #endif
- extern const char *_zf_log_tag_prefix;
- extern zf_log_format _zf_log_global_format;
- extern zf_log_output _zf_log_global_output;
- extern int _zf_log_global_output_lvl;
- extern const zf_log_spec _zf_log_stderr_spec;
- void _zf_log_write_d(
- const char *const func, const char *const file, const unsigned line,
- const int lvl, const char *const tag,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(6, 7);
- void _zf_log_write_aux_d(
- const char *const func, const char *const file, const unsigned line,
- const zf_log_spec *const log, const int lvl, const char *const tag,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(7, 8);
- void _zf_log_write(
- const int lvl, const char *const tag,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(3, 4);
- void _zf_log_write_aux(
- const zf_log_spec *const log, const int lvl, const char *const tag,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(4, 5);
- void _zf_log_write_mem_d(
- const char *const func, const char *const file, const unsigned line,
- const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(8, 9);
- void _zf_log_write_mem_aux_d(
- const char *const func, const char *const file, const unsigned line,
- const zf_log_spec *const log, const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(9, 10);
- void _zf_log_write_mem(
- const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(5, 6);
- void _zf_log_write_mem_aux(
- const zf_log_spec *const log, const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...) _ZF_LOG_PRINTFLIKE(6, 7);
- #ifdef __cplusplus
- }
- #endif
- #if ZF_LOG_SRCLOC_NONE == _ZF_LOG_SRCLOC
- #define ZF_LOG_WRITE(lvl, tag, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write(lvl, tag, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #define ZF_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_mem(lvl, tag, d, d_sz, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #define ZF_LOG_WRITE_AUX(log, lvl, tag, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_aux(log, lvl, tag, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #define ZF_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_mem_aux(log, lvl, tag, d, d_sz, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #else
- #define ZF_LOG_WRITE(lvl, tag, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_d(_ZF_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- lvl, tag, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #define ZF_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_mem_d(_ZF_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- lvl, tag, d, d_sz, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #define ZF_LOG_WRITE_AUX(log, lvl, tag, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_aux_d(_ZF_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- log, lvl, tag, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #define ZF_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
- do { \
- if (ZF_LOG_ON(lvl)) \
- _zf_log_write_mem_aux_d(_ZF_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, \
- log, lvl, tag, d, d_sz, __VA_ARGS__); \
- } _ZF_LOG_ONCE
- #endif
- static _ZF_LOG_INLINE void _zf_log_unused(const int dummy, ...) {(void)dummy;}
- #define _ZF_LOG_UNUSED(...) \
- do { _ZF_LOG_NEVER _zf_log_unused(0, __VA_ARGS__); } _ZF_LOG_ONCE
- #if ZF_LOG_ENABLED_VERBOSE
- #define ZF_LOGV(...) \
- ZF_LOG_WRITE(ZF_LOG_VERBOSE, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGV_AUX(log, ...) \
- ZF_LOG_WRITE_AUX(log, ZF_LOG_VERBOSE, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGV_MEM(d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(ZF_LOG_VERBOSE, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define ZF_LOGV_MEM_AUX(log, d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(log, ZF_LOG_VERBOSE, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #else
- #define ZF_LOGV(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGV_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGV_MEM(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGV_MEM_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #endif
- #if ZF_LOG_ENABLED_DEBUG
- #define ZF_LOGD(...) \
- ZF_LOG_WRITE(ZF_LOG_DEBUG, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGD_AUX(log, ...) \
- ZF_LOG_WRITE_AUX(log, ZF_LOG_DEBUG, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGD_MEM(d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(ZF_LOG_DEBUG, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define ZF_LOGD_MEM_AUX(log, d, d_sz, ...) \
- ZF_LOG_WRITE_MEM_AUX(log, ZF_LOG_DEBUG, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #else
- #define ZF_LOGD(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGD_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGD_MEM(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGD_MEM_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #endif
- #if ZF_LOG_ENABLED_INFO
- #define ZF_LOGI(...) \
- ZF_LOG_WRITE(ZF_LOG_INFO, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGI_AUX(log, ...) \
- ZF_LOG_WRITE_AUX(log, ZF_LOG_INFO, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGI_MEM(d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(ZF_LOG_INFO, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define ZF_LOGI_MEM_AUX(log, d, d_sz, ...) \
- ZF_LOG_WRITE_MEM_AUX(log, ZF_LOG_INFO, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #else
- #define ZF_LOGI(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGI_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGI_MEM(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGI_MEM_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #endif
- #if ZF_LOG_ENABLED_WARN
- #define ZF_LOGW(...) \
- ZF_LOG_WRITE(ZF_LOG_WARN, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGW_AUX(log, ...) \
- ZF_LOG_WRITE_AUX(log, ZF_LOG_WARN, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGW_MEM(d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(ZF_LOG_WARN, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define ZF_LOGW_MEM_AUX(log, d, d_sz, ...) \
- ZF_LOG_WRITE_MEM_AUX(log, ZF_LOG_WARN, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #else
- #define ZF_LOGW(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGW_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGW_MEM(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGW_MEM_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #endif
- #if ZF_LOG_ENABLED_ERROR
- #define ZF_LOGE(...) \
- ZF_LOG_WRITE(ZF_LOG_ERROR, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGE_AUX(log, ...) \
- ZF_LOG_WRITE_AUX(log, ZF_LOG_ERROR, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGE_MEM(d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(ZF_LOG_ERROR, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define ZF_LOGE_MEM_AUX(log, d, d_sz, ...) \
- ZF_LOG_WRITE_MEM_AUX(log, ZF_LOG_ERROR, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #else
- #define ZF_LOGE(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGE_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGE_MEM(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGE_MEM_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #endif
- #if ZF_LOG_ENABLED_FATAL
- #define ZF_LOGF(...) \
- ZF_LOG_WRITE(ZF_LOG_FATAL, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGF_AUX(log, ...) \
- ZF_LOG_WRITE_AUX(log, ZF_LOG_FATAL, _ZF_LOG_TAG, __VA_ARGS__)
- #define ZF_LOGF_MEM(d, d_sz, ...) \
- ZF_LOG_WRITE_MEM(ZF_LOG_FATAL, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #define ZF_LOGF_MEM_AUX(log, d, d_sz, ...) \
- ZF_LOG_WRITE_MEM_AUX(log, ZF_LOG_FATAL, _ZF_LOG_TAG, d, d_sz, __VA_ARGS__)
- #else
- #define ZF_LOGF(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGF_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGF_MEM(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #define ZF_LOGF_MEM_AUX(...) _ZF_LOG_UNUSED(__VA_ARGS__)
- #endif
- #define ZF_LOGV_STR(s) ZF_LOGV("%s", (s))
- #define ZF_LOGD_STR(s) ZF_LOGD("%s", (s))
- #define ZF_LOGI_STR(s) ZF_LOGI("%s", (s))
- #define ZF_LOGW_STR(s) ZF_LOGW("%s", (s))
- #define ZF_LOGE_STR(s) ZF_LOGE("%s", (s))
- #define ZF_LOGF_STR(s) ZF_LOGF("%s", (s))
- #ifdef __cplusplus
- extern "C" {
- #endif
- enum { ZF_LOG_OUT_STDERR_MASK = ZF_LOG_PUT_STD };
- void zf_log_out_stderr_callback(const zf_log_message *const msg, void *arg);
- #define ZF_LOG_OUT_STDERR ZF_LOG_OUT_STDERR_MASK, 0, zf_log_out_stderr_callback
- #define ZF_LOG_STDERR (&_zf_log_stderr_spec)
- #ifdef __cplusplus
- }
- #endif
- #endif
|