其他分享
首页 > 其他分享> > log日志实现

log日志实现

作者:互联网

实例

file.h

#ifndef _FILE_H
#define _FILE_H

#include <stdio.h>
#include <stdlib.h>

#define LOG_LEVEL_FATAL  0
#define LOG_LEVEL_ERROR  1
#define LOG_LEVEL_WARN  2
#define LOG_LEVEL_INFO  3
#define LOG_LEVEL_DEBUG  4
#define LOG_LEVEL_MAX   5

#define self_dbg printf
#define self_err printf
#define self_warn printf
#define self_info printf

typedef enum {
​    LOG_OFF = 0,
​    LOG_ON
} LOG_SWITCH;

struct log_config{
​    unsigned int global_log_level;
​    unsigned int log_buf_size;
​    LOG_SWITCH logfile_log_to_file_switch;
​    char logfile_log_files_dir[256];
​    unsigned int logfile_nr_rolling_files;
​    unsigned long long logfile_max_file_size;
​    unsigned int logfile_flush_to_disk_period;
};

struct log_config* get_log_configs(void);
static int get_exec_name(char *name);
static int log_files_dir_init(char* dir);
LOG_SWITCH get_log_file_switch_status(void);
void output_log_to_file(char *log, un

标签:log,LEVEL,实现,LOG,int,日志,logfile,define
来源: https://blog.csdn.net/weixin_43405004/article/details/120249216