You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naka/include/trace.h

36 lines
919 B

//! Trace messages
#ifndef _TRACE_H
#define _TRACE_H
#include <stdio.h>
#include <stdarg.h>
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_INFO
#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;
#endif /* _TRACE_H */