Compare commits

..

No commits in common. "1d981103b60259be1d7a5bf33aa9cb4326474693" and "43582273fd21cf3de79dc434ac93e6eb6e7a50b8" have entirely different histories.

2 changed files with 15 additions and 23 deletions

View File

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

View File

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