Initial commit
This commit is contained in:
37
logger.h
Normal file
37
logger.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define ANSI_ESC_RED "\x1B[31m"
|
||||
#define ANSI_ESC_GREEN "\x1B[32m"
|
||||
#define ANSI_ESC_YELLOW "\x1B[33m"
|
||||
#define ANSI_ESC_BLUE "\x1B[34m"
|
||||
#define ANSI_ESC_MAGENTA "\x1B[35m"
|
||||
#define ANSI_ESC_CYAN "\x1B[36m"
|
||||
#define ANSI_ESC_COLOR_RESET "\x1B[m"
|
||||
|
||||
#define ANSI_ESC_CLEAR "\x1B[2J"
|
||||
#define ANSI_ESC_CURSOR_RESET "\x1B[;H"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define PRINT(file, color, prompt, format, ...) \
|
||||
fprintf(file, "%s%s", color, prompt), \
|
||||
fprintf(file, format, ##__VA_ARGS__), \
|
||||
fprintf(file, "%s", ANSI_ESC_COLOR_RESET)
|
||||
#define ERROR(format, ...) \
|
||||
PRINT(stderr, ANSI_ESC_RED, "[ERROR] ", format, ##__VA_ARGS__)
|
||||
#define DEBUG(format, ...) \
|
||||
PRINT(stderr, ANSI_ESC_YELLOW, "[DEBUG] ", format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PRINT(file, color, prompt, format, ...) \
|
||||
fprintf(file, "%s", prompt), \
|
||||
fprintf(file, format, ##__VA_ARGS__)
|
||||
#define ERROR(format, ...)
|
||||
#define DEBUG(format, ...)
|
||||
#endif
|
||||
|
||||
#define INFO(format, ...) \
|
||||
PRINT(stdout, ANSI_ESC_CYAN, "** ", format, ##__VA_ARGS__)
|
||||
#define OUTPUT(format, ...) \
|
||||
PRINT(stdout, ANSI_ESC_COLOR_RESET, "", format, ##__VA_ARGS__)
|
||||
Reference in New Issue
Block a user