spz-lab4/inc/print.h

67 lines
1.3 KiB
C
Raw Normal View History

2025-04-23 22:51:00 +03:00
#ifndef INC_PRINT_H
#define INC_PRINT_H
#include <stdio.h>
#include "config.h"
#include "color.h"
#if DEBUG == 1
#define pr(...) { printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__); }
#else
#define pr(...) {}
#endif
#if LOG_LEVEL >= 2
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_err(...) { \
printf(COLOR_RED "[%s:%d] Error: ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
}
#else
#define pr_err(...) { \
printf(COLOR_RED "Error: "); \
printf(__VA_ARGS__); \
printf(COLOR_RESET);\
}
#endif
#else
#define pr_err(...) {}
#endif
#if LOG_LEVEL >= 3
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_warn(...) { \
printf(COLOR_YELLOW "[%s:%d] Warning: ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
}
#else
#define pr_warn(...) { \
printf(COLOR_YELLOW "Warning: "); \
printf(__VA_ARGS__); \
printf(COLOR_RESET); \
}
#endif
#else
#define pr_warn(...) {}
#endif
#if LOG_LEVEL >= 4
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
#define pr_info(...) { \
printf("[%s:%d] Info: ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
}
#else
#define pr_info(...) { printf("Info: "); printf(__VA_ARGS__); }
#endif
#else
#define pr_info(...) {}
#endif
#endif