diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-04-01 21:13:31 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-04-01 21:13:31 -0700 |
commit | 318a1ef88bb5ea09ff4cf953908aef5c76735a46 (patch) | |
tree | 9cdd8be7679e6a336af7a82ca4947b3ffdac97b2 /log.h | |
download | ksyxbot-318a1ef88bb5ea09ff4cf953908aef5c76735a46.tar ksyxbot-318a1ef88bb5ea09ff4cf953908aef5c76735a46.tar.gz ksyxbot-318a1ef88bb5ea09ff4cf953908aef5c76735a46.tar.bz2 ksyxbot-318a1ef88bb5ea09ff4cf953908aef5c76735a46.zip |
First Commit
Diffstat (limited to 'log.h')
-rw-r--r-- | log.h | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +/* + * Created by yuuta on 1/1/22. + */ + +#ifndef _LOG_H +#define _LOG_H + +enum log_level { + log_fetal = 1, + log_error = 2, + log_warn = 3, + log_info = 4, + log_debug = 5 +}; + +void g_log(enum log_level level, + const char *file, + int line, + const char *format, + ...); + +#define LOGFE(X, code) \ +do { g_log(log_fetal, __FUNCTION__, __LINE__, X); \ +exit(code); } while (0) + +#define LOGFEV(X, code, ...) \ +do { g_log(log_fetal, __FUNCTION__, __LINE__, X, __VA_ARGS__); \ +exit(code); } while (0) + +#define LOGF(X) g_log(log_fetal, __FUNCTION__, __LINE__, X) + +#define LOGFV(X, ...) g_log(log_fetal, __FUNCTION__, __LINE__, X, __VA_ARGS__) + +#define LOGE(X) g_log(log_error, __FUNCTION__, __LINE__, X) + +#define LOGEV(X, ...) g_log(log_error, __FUNCTION__, __LINE__, X, __VA_ARGS__) + +#define LOGW(X) g_log(log_warn, __FUNCTION__, __LINE__, X) + +#define LOGWV(X, ...) g_log(log_warn, __FUNCTION__, __LINE__, X, __VA_ARGS__) + +#define LOGI(X) g_log(log_info, __FUNCTION__, __LINE__, X) + +#define LOGIV(X, ...) g_log(log_info, __FUNCTION__, __LINE__, X, __VA_ARGS__) + +#define LOGD(X) g_log(log_debug, __FUNCTION__, __LINE__, X) + +#define LOGDV(X, ...) g_log(log_debug, __FUNCTION__, __LINE__, X, __VA_ARGS__) + +#endif /* _LOG_H */ |