Log Colors #8

Merged
wesley merged 1 commits from logger/colors into main 2024-02-10 11:26:48 -05:00
2 changed files with 6 additions and 6 deletions

View File

@@ -14,10 +14,9 @@ typedef enum level_color {
} level_color; } level_color;
void send_to_console(const char *message, level_color color) { void send_to_console(const char *message, level_color color) {
// TODO: Make use of the color we are passing in so that we can color the const char *color_strings[] = {"41;97", "0;91", "0;93", "0;94", "0;92"};
// output on the console
printf("%s", message); printf("\033[%sm%s\033[0m\n", color_strings[color], message);
} }
void send_to_error_log(const char *message) { void send_to_error_log(const char *message) {
@@ -48,7 +47,7 @@ void log_output(log_level level, const char *message, ...) {
// Now we prepend the message with our message level // Now we prepend the message with our message level
char log_message[msg_length]; char log_message[msg_length];
sprintf(log_message, "%s%s\n", level_strings[level], format_message); sprintf(log_message, "%s%s", level_strings[level], format_message);
// Now we call the appropriate function depending on the level // Now we call the appropriate function depending on the level
if (level <= 1) { if (level <= 1) {

View File

@@ -1,8 +1,9 @@
#include <stdio.h> // printf() #include <stdio.h> // printf()
#include <stdlib.h> // malloc() free() #include <stdlib.h> // malloc() free()
#include <string.h> #include <string.h> // memset()
#include "../defines.h" #include "../defines.h"
#include "../logger/logger.h"
#include "zone.h" #include "zone.h"
typedef struct ZoneHeader { typedef struct ZoneHeader {
@@ -32,7 +33,7 @@ void *zoneAlloc(Zone *zone, size_t sizeBytes) {
ZoneHeader *zone_header = (ZoneHeader *)zone - sizeof(ZoneHeader); ZoneHeader *zone_header = (ZoneHeader *)zone - sizeof(ZoneHeader);
if (zone_header->cur_size + sizeBytes > zone_header->capacity) { if (zone_header->cur_size + sizeBytes > zone_header->capacity) {
printf("Could not allocate, not enough space."); QERROR("Could not allocate, not enough space.");
return NULL; return NULL;
} }