mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
#include "logMakePtr.h"
|
|
#include "logUb.h"
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
RETURN_CODE_C create_log_module(void)
|
|
{
|
|
LogUbuntu *log = NULL;
|
|
RETURN_CODE_C code = create_log_instance(&log);
|
|
if (C_RETURN_CODE_OK == code.mCode) {
|
|
LogInfo("Create log instance ok.\n");
|
|
reset_log_impl((ILog *)log);
|
|
return code;
|
|
}
|
|
return CreateReturnCode(C_RETURN_CODE_NOT_OK);
|
|
}
|
|
|
|
RETURN_CODE_C destroy_log_module(void)
|
|
{
|
|
reset_log_impl(NULL);
|
|
return CreateReturnCode(C_RETURN_CODE_OK);
|
|
}
|
|
|
|
static RETURN_CODE_C create_log_instance_ptr(LogMakePtr *object, LogUbuntu **log)
|
|
{
|
|
return new_log(log);
|
|
}
|
|
|
|
static void log_make_ptr_free(LogMakePtr *object)
|
|
{
|
|
}
|
|
|
|
static LogMakePtr default_log_make_ptr = {
|
|
.init = NULL,
|
|
.create_log_instance = create_log_instance_ptr,
|
|
.free = log_make_ptr_free,
|
|
.unInit = NULL,
|
|
};
|
|
static LogMakePtr *log_make_ptr_instance = &default_log_make_ptr;
|
|
|
|
LogMakePtr *get_log_make_ptr_instance(void)
|
|
{
|
|
return log_make_ptr_instance;
|
|
}
|
|
|
|
void log_make_ptr_object_init(LogMakePtr *object)
|
|
{
|
|
memcpy(object, &default_log_make_ptr, sizeof(LogMakePtr));
|
|
}
|
|
void reset_log_make_ptr_impl(LogMakePtr *impl)
|
|
{
|
|
log_make_ptr_instance->free(log_make_ptr_instance);
|
|
log_make_ptr_instance = impl;
|
|
} |