//! Trace messages #ifndef _TRACE_H #define _TRACE_H #include #include enum trace_level { TRACE_LEVEL_DEBUG = 0, TRACE_LEVEL_INFO, TRACE_LEVEL_WARN, TRACE_LEVEL_ERROR, TRACE_LEVEL_FATAL, _TRACE_LEVEL_NUM, }; #ifdef DEBUG #define _TRACE_LEVEL_DEFAULT TRACE_LEVEL_DEBUG #else #define _TRACE_LEVEL_DEFAULT TRACE_LEVEL_WARN #endif int _t_fprintf(enum trace_level l, FILE* output, const char* msg, ...); enum trace_level trace_max_level(); void trace_init_with(enum trace_level max_level); // Initialise the tracer with env-var `_TRACE_CONTROL_ENV_NAME`. If the env-var is not found, the max trace level is not modified. If it is found but has an invalid value, this function returns 0. Otherwise it modifies the max trace level value and returns 1. int trace_init(); const char* trace_name_of(enum trace_level lv); extern const char* const _TRACE_CONTROL_ENV_NAME; extern const char* const _trace_level_descriptions[_TRACE_LEVEL_NUM]; #endif /* _TRACE_H */