mirror of
https://github.com/hmaxnl/netex.git
synced 2025-01-18 15:34:20 +01:00
Initial logging implementation.
This commit is contained in:
parent
4850ee2c86
commit
63fa472d8c
|
@ -1,6 +1,29 @@
|
||||||
#ifndef LOG_H
|
#ifndef LOG_H
|
||||||
#define 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
|
#endif //LOG_H
|
||||||
|
|
|
@ -1,2 +1,34 @@
|
||||||
#include "netex.h"
|
#include "netex.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ void strsplfree(SPLIT_STR* str)
|
||||||
free(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 strocc(const char* str, const char character)
|
||||||
{
|
{
|
||||||
size_t occurrences = 0;
|
size_t occurrences = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user