made logger-test much better

it now reads content of log file
This commit is contained in:
Václav Šmejkal 2022-12-04 19:24:06 +01:00
parent 054c7647a1
commit 67170b2635
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19

View File

@ -19,17 +19,34 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <why2.h> #include <why2.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
int main(void) int main(void)
{ {
//VARIABLES //VARIABLES
logFile logger = initLogger(WRITE_DIR); //INITIALIZE LOGGER FILE logFile logger = initLogger(WRITE_DIR); //INITIALIZE LOGGER FILE
int bufferSize;
printf("%d\n", logger.file); char *buffer;
FILE *fileBuffer;
writeLog(logger.file, WRITE_MESSAGE); //WRITE 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 //DEALLOCATION
free(buffer);
fclose(fileBuffer);
deallocateLogger(logger); deallocateLogger(logger);
return 0; return 0;
} }