core-legacy/include/logger.h

27 lines
1 KiB
C
Raw Normal View History

2020-05-05 09:42:02 +00:00
#ifndef CORE_LOGGER_H
#define CORE_LOGGER_H
#include <stdio.h>
#include <time.h>
#include <colors.h>
#include <config.h>
2020-05-05 20:29:04 +00:00
#ifndef SOURCE_PATH_SIZE
#define SOURCE_PATH_SIZE 0
#endif
#define __FILENAME__ (__FILE__ + SOURCE_PATH_SIZE)
2020-05-05 09:42:02 +00:00
void
logger_log(FILE *stream, log_level_t level, const char *filename, int line, const char *func, const char *msg, ...);
#define LOG_TRACE(...) logger_log(stdout, LOG_LEVEL_TRACE, __FILENAME__, __LINE__, __func__, ##__VA_ARGS__)
#define LOG_DEBUG(...) logger_log(stdout, LOG_LEVEL_DEBUG, __FILENAME__, __LINE__, __func__, ##__VA_ARGS__)
#define LOG_INFO(...) logger_log(stdout, LOG_LEVEL_INFO , __FILENAME__, __LINE__, __func__, ##__VA_ARGS__)
#define LOG_WARN(...) logger_log(stdout, LOG_LEVEL_WARN , __FILENAME__, __LINE__, __func__, ##__VA_ARGS__)
#define LOG_ERROR(...) logger_log(stderr, LOG_LEVEL_ERROR, __FILENAME__, __LINE__, __func__, ##__VA_ARGS__)
#define LOG_FATAL(...) logger_log(stderr, LOG_LEVEL_FATAL, __FILENAME__, __LINE__, __func__, ##__VA_ARGS__)
#endif //CORE_LOGGER_H