parent
42a50e194c
commit
75cd8806b8
@ -0,0 +1,38 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
#ifndef __ELOG_FILE__H__
|
||||
#define __ELOG_FILE__H__
|
||||
|
||||
#include <elog.h>
|
||||
|
||||
/* 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
|
||||
@ -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_ */
|
||||
@ -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 */
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue