diff --git a/easylogger/plugins/file/elog_file.c b/easylogger/plugins/file/elog_file.c new file mode 100644 index 0000000..4fd06ba --- /dev/null +++ b/easylogger/plugins/file/elog_file.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +#include "elog_file.h" + +/* initialize OK flag */ +static bool init_ok = false; + +ElogErrCode elog_file_init(void) +{ + ElogErrCode result = ELOG_NO_ERR; + if (init_ok) + goto __exit; + + elog_file_port_init(); + + init_ok = true; +__exit: + return result; +} + +void elog_file_write(const char *log, size_t size) +{ + ELOG_ASSERT(init_ok); + ELOG_ASSERT(log); + + elog_file_port_lock(); + elog_file_port_write(log, size); + elog_file_port_unlock(); +} +void elog_file_deinit(void) +{ + ELOG_ASSERT(init_ok); + elog_file_port_deinit(); +} + diff --git a/easylogger/plugins/file/elog_file.h b/easylogger/plugins/file/elog_file.h new file mode 100644 index 0000000..6ff5806 --- /dev/null +++ b/easylogger/plugins/file/elog_file.h @@ -0,0 +1,28 @@ +#ifndef __ELOG_FILE__H__ +#define __ELOG_FILE__H__ + +#include + +/* EasyLogger file log plugin's software version number */ +#define ELOG_FILE_SW_VERSION "V1.0.0" + +#ifdef __cplusplus +extern "C" { +#endif + /* elog_file.c */ + ElogErrCode elog_file_init(void); + void elog_file_write(const char *log, size_t size); + void elog_file_deinit(void); + + /* elog_file_port.c */ + ElogErrCode elog_flash_port_init(void); + void elog_file_port_write(const char *log, size_t size); + void elog_file_port_lock(void); + void elog_file_port_unlock(void); + void elog_file_port_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/easylogger/plugins/file/elog_file_cfg.h b/easylogger/plugins/file/elog_file_cfg.h new file mode 100644 index 0000000..a8afe49 --- /dev/null +++ b/easylogger/plugins/file/elog_file_cfg.h @@ -0,0 +1,13 @@ +#ifndef _ELOG_FILE_CFG_H_ +#define _ELOG_FILE_CFG_H_ + +/* EasyLogger file log plugin's using file name */ +#define ELOG_FILE_NAME + +/* EasyLogger file log plugin's using file max size */ +#define ELOG_FILE_MAX_SIZE + +/* EasyLogger file log plugin's using semaphore key */ +#define ELOG_FILE_SEM_KEY + +#endif /* _ELOG_FILE_CFG_H_ */ diff --git a/easylogger/plugins/file/elog_file_port.c b/easylogger/plugins/file/elog_file_port.c new file mode 100644 index 0000000..2878664 --- /dev/null +++ b/easylogger/plugins/file/elog_file_port.c @@ -0,0 +1,52 @@ +#include "elog_file.h" + +/** + * EasyLogger flile log pulgin port initialize + * + * @return result + */ +ElogErrCode elog_file_port_init(void) { + ElogErrCode result = ELOG_NO_ERR; + + /* add your code here */ + + return result; +} + +/** + * output file saved log port interface + * + * @param log file saved log + * @param size log size + */ +void elog_file_port_output(const char *log, size_t size) { + + /* add your code here */ + +} + +/** + * file log lock + */ +void elog_file_port_lock(void) { + + /* add your code here */ + +} + +/** + * file log unlock + */ +void elog_file_port_unlock(void) { + + /* add your code here */ + +} +/** + * file log deinit + */ +void elog_file_port_deinit(void) { + + /* add your code here */ + +}