hunting/utils/LogC/abstract/iLog.c
2023-09-02 07:45:55 -07:00

58 lines
1.1 KiB
C

#include "iLog.h"
#include "ReturnCode.h"
#include <stddef.h>
#include <string.h>
static RETURN_CODE_C def_log_init(ILog *impl)
{
return CreateReturnCode(C_RETURN_CODE_VIRTUAL_FUNCTION);
}
static RETURN_CODE_C def_log_unInit(ILog *impl)
{
return CreateReturnCode(C_RETURN_CODE_VIRTUAL_FUNCTION);
}
static void def_free(ILog *impl)
{}
static void def_log_fmt(ILog *log, const LogLeveL level, const char *fmt, ...)
{}
static ILog default_log = {
.init = def_log_init,
.log_fmt = def_log_fmt,
.free = def_free,
.unInit = def_log_unInit,
};
static ILog *instance = &default_log;
ILog *get_log_instance(void)
{
return instance;
}
void reset_log_impl(ILog *impl)
{
instance->free(impl);
instance = impl;
}
RETURN_CODE_C new_i_Log(ILog **impl)
{
if (!impl || !(*impl)) {
return CreateReturnCode(C_RETURN_CODE_NOT_OK);
}
memcpy(*impl, &default_log, sizeof(ILog));
return CreateReturnCode(C_RETURN_CODE_OK);
}
RETURN_CODE_C create_log_module(void)
{
return CreateReturnCode(C_RETURN_CODE_OK);
}
RETURN_CODE_C destroy_log_module(void)
{
return CreateReturnCode(C_RETURN_CODE_OK);
}