#ifndef LOG_H
#define LOG_H

#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>

#define LOG_LEVEL_NONE 0
#define LOG_LEVEL_FATAL 1
#define LOG_LEVEL_ERROR 2
#define LOG_LEVEL_WARN 3
#define LOG_LEVEL_INFO 4
#define LOG_LEVEL_DEBUG 5

extern unsigned int logLevel;

// Logging macros
#define FATAL_COL  "\x1B[4;31m"
#define ERROR_COL  "\x1B[91m"
#define WARN_COL   "\x1B[33m"
#define INFO_COL   "\x1B[34m"
#define DEBUG_COL  "\x1B[90m"
#define NORMAL_COL "\x1B[0m"

#define FATAL(...) if (logLevel >= LOG_LEVEL_FATAL) { fprintf(stderr, "| %sFATAL%s | ", FATAL_COL, NORMAL_COL); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
#define ERROR(...) if (logLevel >= LOG_LEVEL_ERROR) { fprintf(stderr, "| %sERROR%s | ", ERROR_COL, NORMAL_COL); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
#define WARN(...)  if (logLevel >= LOG_LEVEL_WARN)  { fprintf(stderr, "| %sWARN%s  | ", WARN_COL,  NORMAL_COL); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
#define INFO(...)  if (logLevel >= LOG_LEVEL_INFO)  { fprintf(stderr, "| %sINFO%s  | ", INFO_COL,  NORMAL_COL); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
#define DEBUG(...) if (logLevel >= LOG_LEVEL_DEBUG) { fprintf(stderr, "| %sDEBUG%s | ", DEBUG_COL, NORMAL_COL); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }

#endif // LOG_H