diff --git a/src/net/include/log.h b/src/net/include/log.h index acfea1c..932dfad 100755 --- a/src/net/include/log.h +++ b/src/net/include/log.h @@ -1,6 +1,29 @@ #ifndef LOG_H #define LOG_H +enum log_level +{ + Info = 0, + Warning = 1, + Error = 2, + Fatal = 3, + Debug = 4, + Verbose = 5 +}; +typedef struct app_logger_info +{ + char* log_file; + char* executable_name; + int log_file_max_size; + enum log_level max_log_level; + /// logger list/linked list/array? +} app_logger_info; + +typedef struct logger +{ + app_logger_info* app_logger; + char* name; +} logger; #endif //LOG_H diff --git a/src/net/logging/log.c b/src/net/logging/log.c index 8979ac1..7f1b61f 100755 --- a/src/net/logging/log.c +++ b/src/net/logging/log.c @@ -1,2 +1,34 @@ #include "netex.h" -#include "log.h" \ No newline at end of file +#include "log.h" +#include + +bool canLog = true; +app_logger_info* default_app_log = NULL; + +app_logger_info* initialize_log(char* logPath, char* executable, int maxFileSize, enum log_level maxLogLevel) +{ + return NULL; +} + +void shutdown_log(app_logger_info* appLogger) +{ + canLog = false; +} + +logger* create_logger(app_logger_info* appLogger, char* name) +{ + return NULL; +} + +void log_to_file(logger* logger, enum log_level logLevel, char* format, ...) +{ + if (!canLog || logger->app_logger->max_log_level <= logLevel) return; + char* logMessage; + va_list args; + va_start(args, format); + int formatedStringSize = vasprintf(&logMessage, format, args); + if (0 > formatedStringSize) logMessage = NULL; + va_end(args); + //TODO: Handle logging to file/queue + free(logMessage); +} diff --git a/src/net/str/str_utils.c b/src/net/str/str_utils.c index f23dcad..7616f4f 100755 --- a/src/net/str/str_utils.c +++ b/src/net/str/str_utils.c @@ -56,7 +56,7 @@ void strsplfree(SPLIT_STR* str) free(str); } -// Returns the amount of times the 'character' occurrs in the given string. +// Returns the amount of times the 'character' occurs in the given string. size_t strocc(const char* str, const char character) { size_t occurrences = 0;