From 49cced6b4fd51cf6b161011983ddeb93a42487df Mon Sep 17 00:00:00 2001 From: Sheldon Lee Date: Wed, 1 Jul 2020 01:49:06 +0100 Subject: [PATCH] Added logging functionality. --- log.c | 22 ++++++++++++++++++++++ log.h | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 log.c create mode 100644 log.h diff --git a/log.c b/log.c new file mode 100644 index 0000000..38e9ec3 --- /dev/null +++ b/log.c @@ -0,0 +1,22 @@ +#include +#include "log.h" +static FILE* file = 0; +static char* name; + +void startLog(char* filename) +{ + name = filename; + file = fopen(filename, "w"); +} + +void logLine(char* string) +{ + if (!file) return; + fputs(string, file); + fputs("\n", file); +} + +void endLog() +{ + fclose(file); +} diff --git a/log.h b/log.h new file mode 100644 index 0000000..1ad1339 --- /dev/null +++ b/log.h @@ -0,0 +1,10 @@ +#ifndef LOG_H +#define LOG_H + +void startLog(char* filename); + +void logLine(char* string); + +void endLog(); + +#endif