Compare commits

...

2 Commits

Author SHA1 Message Date
Valentin Moguérou 1d981103b6 couleur 2024-04-16 01:29:35 +02:00
Valentin Moguérou 642caf7f2a Fix Makefile 2024-04-16 01:24:32 +02:00
2 changed files with 23 additions and 15 deletions

View File

@ -9,31 +9,30 @@ test: bin/main
bin/main MP2I-creneaux.txt 33 MP2I-colleurs.txt 16 6 15 output.csv
OBJECTS = obj/structure.o obj/algorithm.o obj/display.o obj/logger.o obj/main.o
bin/main: bin $(OBJECTS)
bin/main: $(OBJECTS)
@mkdir -p bin
$(CC) -o $@ $(LFLAGS) $(FLAGS) $(OBJECTS)
obj/main.o: src/main.c obj
obj/main.o: src/main.c
@mkdir -p obj
$(CC) -o $@ -c $(FLAGS) $<
obj/structure.o: src/structure.c src/structure.h obj
obj/structure.o: src/structure.c src/structure.h
@mkdir -p obj
$(CC) -o $@ -c $(FLAGS) $<
obj/display.o: src/display.c src/display.h obj
obj/display.o: src/display.c src/display.h
@mkdir -p obj
$(CC) -o $@ -c $(FLAGS) $<
obj/algorithm.o: src/algorithm.c src/algorithm.h obj
obj/algorithm.o: src/algorithm.c src/algorithm.h
@mkdir -p obj
$(CC) -o $@ -c $(FLAGS) $<
obj/logger.o: src/logger.c src/logger.h obj
obj/logger.o: src/logger.c src/logger.h
@mkdir -p obj
$(CC) -o $@ -c $(FLAGS) $<
bin:
mkdir -p bin
obj:
mkdir -p obj
.PHONY: clean
clean:

View File

@ -51,28 +51,37 @@ void logprint(LogLevel level, char* str, va_list args)
clock_t t = clock();
char label[6];
char ansi_code[12];
switch (level)
{
case (LOG_PANIC):
strcpy(label, "PANIC");
strcpy(ansi_code, "\x1b[31;49m");
break;
case (LOG_FATAL):
strcpy(label, "FATAL");
strcpy(ansi_code, "\x1b[31;49m");
break;
case (LOG_ERROR):
strcpy(label, "ERROR");
strcpy(ansi_code, "\x1b[31;49m");
break;
case (LOG_WARN):
strcpy(label, "WARN");
strcpy(ansi_code, "\x1b[35;49m");
break;
case (LOG_INFO):
strcpy(label, "INFO");
strcpy(ansi_code, "\x1b[33;49m");
break;
case (LOG_DEBUG):
strcpy(label, "DEBUG");
strcpy(ansi_code, "\x1b[36;49m");
break;
case (LOG_TRACE):
strcpy(label, "TRACE");
strcpy(ansi_code, "\x1b[36;49m");
break;
}
@ -81,7 +90,7 @@ void logprint(LogLevel level, char* str, va_list args)
if (level < logger->level)
return;
fprintf(stream, "[%s][%f]: ", label, (double)t / CLOCKS_PER_SEC);
fprintf(stream, "%s[%s][%f]: ", ansi_code, label, (double)t / CLOCKS_PER_SEC);
vfprintf(stream, str, args);
fprintf(stream, "\n");