Browse Source

【存在问题】日志写文件

paint_robot_new-v1.5
Lizongdi 2 weeks ago
parent
commit
53d486f9e0
  1. 10
      library/log/elog_port.c
  2. 2
      library/log/include/elog_file.h
  3. 2
      library/log/include/elog_file_cfg.h
  4. 8
      library/log/log.c

10
library/log/elog_port.c

@ -35,9 +35,7 @@
#include "rd_time.h"
#include "rd_thread.h"
#ifndef DEBUG
#include "elog_file.h"
#endif
static pthread_mutex_t output_lock;
@ -49,9 +47,7 @@ static pthread_mutex_t output_lock;
WEAK ElogErrCode elog_port_init(void) {
ElogErrCode result = ELOG_NO_ERR;
Rd_MutexInit(&output_lock);
#ifndef DEBUG
elog_file_init();
#endif
return result;
}
@ -60,9 +56,7 @@ WEAK ElogErrCode elog_port_init(void) {
*
*/
WEAK void elog_port_deinit(void) {
#ifndef DEBUG
elog_file_deinit();
#endif
Rd_MutexDestroy(&output_lock);
}
@ -73,11 +67,7 @@ WEAK void elog_port_deinit(void) {
* @param size log size
*/
WEAK void elog_port_output(const char *log, size_t size) {
#ifdef DEBUG
RD_PRINTF("%.*s", (int)size, log);
#else
elog_file_write(log, size);
#endif
}
/**

2
library/log/include/elog_file.h

@ -38,9 +38,7 @@
extern "C" {
#endif
#ifndef DEBUG
#define ELOG_FILE_ENABLE
#endif
/* EasyLogger file log plugin's software version number */
#define ELOG_FILE_SW_VERSION "V1.0.0"

2
library/log/include/elog_file_cfg.h

@ -31,7 +31,7 @@
#define _ELOG_FILE_CFG_H_
/* EasyLogger file log plugin's using file name */
#define ELOG_FILE_NAME "rd.log"
#define ELOG_FILE_NAME "C:rd.log"
/* EasyLogger file log plugin's using file max size */
#define ELOG_FILE_MAX_SIZE (1 * 1024 * 1024)

8
library/log/log.c

@ -1,18 +1,10 @@
#include <stdio.h>
#include "elog.h"
void Rd_ElogEnableStrong(void)
{
// 用于强符号覆盖的锚点
}
__attribute__((constructor(101)))
void Rd_ElogInit(void)
{
#ifndef DEBUG
/* close printf buffer */
//setbuf(stdout, NULL);
#endif
/* initialize EasyLogger */
elog_init();
/* set EasyLogger log format */

Loading…
Cancel
Save