add log4cplus
This commit is contained in:
80
log4cplus/log4.h
Normal file
80
log4cplus/log4.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef LOG4_H
|
||||
#define LOG4_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
//防止#include <log4cplus/logger.h>里的冲突
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
//防止#include <log4cplus/logger.h>里的冲突
|
||||
|
||||
#include "logger.h"
|
||||
#include <set>
|
||||
#include "loggingmacros.h"
|
||||
|
||||
|
||||
#define LOGTYPE_COM 1
|
||||
#define LOGTYPE_DATA 2
|
||||
|
||||
struct TypedLogger {
|
||||
log4cplus::Logger logger;
|
||||
int logtype;
|
||||
TypedLogger();
|
||||
TypedLogger(const log4cplus::Logger& l, int t);
|
||||
};
|
||||
|
||||
struct DebugSwitch {
|
||||
bool debug_open;
|
||||
std::set<std::string> targets;
|
||||
int min_level;
|
||||
std::map<int, bool> type_enable;
|
||||
|
||||
DebugSwitch();
|
||||
void open();
|
||||
void close();
|
||||
void set_target(const std::string& name);
|
||||
void set_level(int level);
|
||||
void enable_type(int type);
|
||||
void disable_type(int type);
|
||||
bool match(const std::string& logger_name, int level, int logtype);
|
||||
};
|
||||
|
||||
extern std::map<std::string, TypedLogger> logger_map;
|
||||
extern DebugSwitch g_debug_switch;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
log4cplus::Logger init_logger(const std::string& full_name, const std::string& file_dir, const std::string& base_file);
|
||||
|
||||
|
||||
void process_log_command(const std::string& id, const std::string& level, const std::string& grade, const std::string& logtype_str);
|
||||
|
||||
|
||||
void update_log_entries_countdown();
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
void remove_loggers_by_terminal_id(const char* terminal_id_cstr);
|
||||
void init_logger_process();
|
||||
void init_loggers();
|
||||
void init_loggers_bydevid(const char* dev_id);
|
||||
|
||||
void log_debug(const char* key, const char* msg);
|
||||
void log_info(const char* key, const char* msg);
|
||||
void log_warn(const char* key, const char* msg);
|
||||
void log_error(const char* key, const char* msg);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // LOG4_H
|
||||
Reference in New Issue
Block a user