47 lines
No EOL
1.6 KiB
C
47 lines
No EOL
1.6 KiB
C
#include <stdio.h>
|
|
#include <stdarg.h> // Required for variadic functions
|
|
|
|
/*
|
|
* Prints a message in cyan.
|
|
* Can accept format specifiers and variable arguments like printf.
|
|
*/
|
|
void info(const char* format, ...) {
|
|
va_list args;
|
|
va_start(args, format); // Initialize va_list with the format string
|
|
|
|
printf("\e[0;36m"); // Set text color to cyan
|
|
vprintf(format, args); // Print the formatted message using va_list
|
|
printf("\e[0m\n"); // Reset color and add a newline
|
|
|
|
va_end(args); // Clean up va_list
|
|
}
|
|
|
|
/*
|
|
* Prints an ERROR message in red.
|
|
* Can accept format specifiers and variable arguments like printf.
|
|
*/
|
|
void error(const char* format, ...) {
|
|
va_list args;
|
|
va_start(args, format); // Initialize va_list with the format string
|
|
|
|
printf("[\e[1;91mERROR\e[0m] \e[0;91m"); // Print ERROR prefix and set red color
|
|
vprintf(format, args); // Print the formatted message using va_list
|
|
printf("\e[0m\n"); // Reset color and add a newline
|
|
|
|
va_end(args); // Clean up va_list
|
|
}
|
|
|
|
/*
|
|
* Prints a WARNING message in yellow.
|
|
* Can accept format specifiers and variable arguments like printf.
|
|
*/
|
|
void warning(const char* format, ...) {
|
|
va_list args;
|
|
va_start(args, format); // Initialize va_list with the format string
|
|
|
|
printf("[\e[1;93mWARNING\e[0m] \e[0;93m"); // Print WARNING prefix and set yellow color
|
|
vprintf(format, args); // Print the formatted message using va_list
|
|
printf("\e[0m\n"); // Reset color and add a newline
|
|
|
|
va_end(args); // Clean up va_list
|
|
} |