ptk/include/ptk_log.h
2024-08-08 14:38:43 +02:00

35 lines
1.2 KiB
C

#ifndef _PTK_PTK_LOG_H
#define _PTK_PTK_LOG_H
#include <limits.h>
#include <stdarg.h>
typedef enum {
PTK_LOG_LEVEL_OFF = 0,
PTK_LOG_LEVEL_ERR = 1,
PTK_LOG_LEVEL_WARN = 2,
PTK_LOG_LEVEL_INFO = 3,
PTK_LOG_LEVEL_DEBUG = 4,
PTK_LOG_LEVEL_TRACE = 5,
PTK_LOG_LEVEL_ALL = INT_MAX,
} PtkLogLevel;
void ptk_log_init(PtkLogLevel level);
void ptk_log(const char *file, int line, PtkLogLevel level, const char *fmt, ...);
void ptk_err (const char *file, int line, const char *fmt, ...);
void ptk_warn (const char *file, int line, const char *fmt, ...);
void ptk_info (const char *file, int line, const char *fmt, ...);
void ptk_debug(const char *file, int line, const char *fmt, ...);
void ptk_trace(const char *file, int line, const char *fmt, ...);
#define PTK_LOG(level, ...) ptk_log(__FILE__, __LINE__, level, __VA_ARGS__)
#define PTK_ERR(...) ptk_err(__FILE__, __LINE__, __VA_ARGS__)
#define PTK_WARN(...) ptk_warn(__FILE__, __LINE__, __VA_ARGS__)
#define PTK_INFO(...) ptk_info(__FILE__, __LINE__, __VA_ARGS__)
#define PTK_DEBUG(...) ptk_debug(__FILE__, __LINE__, __VA_ARGS__)
#define PTK_TRACE(...) ptk_trace(__FILE__, __LINE__, __VA_ARGS__)
#endif // _PTK_PTK_LOG_H