From 67170b26357edcc116dcd52ca975eae0ca1a8bb6 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 4 Dec 2022 19:24:06 +0100 Subject: [PATCH] made logger-test much better it now reads content of log file --- src/logger/lib/test/main.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/logger/lib/test/main.c b/src/logger/lib/test/main.c index ba2a0d7..18411f8 100644 --- a/src/logger/lib/test/main.c +++ b/src/logger/lib/test/main.c @@ -19,17 +19,34 @@ along with this program. If not, see . #include #include +#include int main(void) { //VARIABLES logFile logger = initLogger(WRITE_DIR); //INITIALIZE LOGGER FILE - - printf("%d\n", logger.file); + int bufferSize; + char *buffer; + FILE *fileBuffer; writeLog(logger.file, WRITE_MESSAGE); //WRITE + fileBuffer = fopen(logger.fileName, "r"); + fseek(fileBuffer, 0, SEEK_END); + bufferSize = ftell(fileBuffer); + rewind(fileBuffer); //REWIND fileBuffer (NO SHIT) + + //SET LENGTH OF buffer + buffer = malloc(bufferSize + 1); + + //LOAD jsonFile + fread(buffer, bufferSize, 1, fileBuffer); + + printf("%s\n", buffer); + //DEALLOCATION + free(buffer); + fclose(fileBuffer); deallocateLogger(logger); return 0; } \ No newline at end of file