|
@@ -1,5 +1,6 @@
|
|
#ifndef AFUN_LOG_HPP
|
|
#ifndef AFUN_LOG_HPP
|
|
#define AFUN_LOG_HPP
|
|
#define AFUN_LOG_HPP
|
|
|
|
+
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include "aFunToolExport.h"
|
|
#include "aFunToolExport.h"
|
|
#include "macro.hpp"
|
|
#include "macro.hpp"
|
|
@@ -26,22 +27,30 @@ namespace aFuntool {
|
|
const std::string id;
|
|
const std::string id;
|
|
LogLevel level = log_debug;
|
|
LogLevel level = log_debug;
|
|
bool exit = true;
|
|
bool exit = true;
|
|
|
|
+
|
|
friend class LogFactory;
|
|
friend class LogFactory;
|
|
|
|
|
|
public:
|
|
public:
|
|
- explicit Logger(const std::string &id_, LogLevel level_=log_warning, bool exit_=true);
|
|
|
|
|
|
+ explicit Logger(const std::string &id_, LogLevel level_ = log_warning, bool exit_ = true);
|
|
|
|
+
|
|
int writeTrackLog(const char *file, int line, const char *func,
|
|
int writeTrackLog(const char *file, int line, const char *func,
|
|
const char *format, ...);
|
|
const char *format, ...);
|
|
|
|
+
|
|
int writeDebugLog(const char *file, int line, const char *func,
|
|
int writeDebugLog(const char *file, int line, const char *func,
|
|
const char *format, ...);
|
|
const char *format, ...);
|
|
|
|
+
|
|
int writeInfoLog(const char *file, int line, const char *func,
|
|
int writeInfoLog(const char *file, int line, const char *func,
|
|
const char *format, ...);
|
|
const char *format, ...);
|
|
|
|
+
|
|
int writeWarningLog(const char *file, int line, const char *func,
|
|
int writeWarningLog(const char *file, int line, const char *func,
|
|
const char *format, ...);
|
|
const char *format, ...);
|
|
|
|
+
|
|
int writeErrorLog(const char *file, int line, const char *func,
|
|
int writeErrorLog(const char *file, int line, const char *func,
|
|
const char *format, ...);
|
|
const char *format, ...);
|
|
|
|
+
|
|
int writeSendErrorLog(const char *file, int line, const char *func,
|
|
int writeSendErrorLog(const char *file, int line, const char *func,
|
|
const char *format, ...);
|
|
const char *format, ...);
|
|
|
|
+
|
|
int writeFatalErrorLog(const char *file, int line, const char *func,
|
|
int writeFatalErrorLog(const char *file, int line, const char *func,
|
|
int exit_code, const char *format, ...);
|
|
int exit_code, const char *format, ...);
|
|
};
|
|
};
|
|
@@ -63,37 +72,36 @@ namespace aFuntool {
|
|
|
|
|
|
public:
|
|
public:
|
|
Logger sys_log = Logger("SYSTEM");
|
|
Logger sys_log = Logger("SYSTEM");
|
|
-
|
|
|
|
- LogFactory();
|
|
|
|
- ~LogFactory();
|
|
|
|
- int initLogSystem(ConstFilePath path, bool is_asyn=true);
|
|
|
|
- bool destruct();
|
|
|
|
- void writeLog(LogLevel level,
|
|
|
|
- const char *id, pid_t tid,
|
|
|
|
- const char *ti, time_t t,
|
|
|
|
- const char *file, int line, const char *func,
|
|
|
|
- const char *info);
|
|
|
|
- static void writeConsole(LogLevel level,
|
|
|
|
- const char *id, pid_t tid,
|
|
|
|
- const char *ti, time_t t,
|
|
|
|
- const char *file, int line, const char *func,
|
|
|
|
- const char *info);
|
|
|
|
- void writeLogAsyn(LogLevel level,
|
|
|
|
- const char *id, pid_t tid,
|
|
|
|
- const char *ti, time_t t,
|
|
|
|
- const char *file, int line, const char *func, const char *info);
|
|
|
|
- int newLog(Logger *logger,
|
|
|
|
- bool pc,
|
|
|
|
- LogLevel level,
|
|
|
|
- const char *file, int line, const char *func,
|
|
|
|
- const char *format, va_list ap);
|
|
|
|
- bool news() {return !init || log_buf != nullptr;}
|
|
|
|
- int wait() {return pthread_cond_wait(&cond, &mutex);}
|
|
|
|
- bool stop() {return !init && log_buf == nullptr;}
|
|
|
|
- struct LogNode *pop();
|
|
|
|
|
|
+ AFUN_TOOL_EXPORT LogFactory();
|
|
|
|
+ AFUN_TOOL_EXPORT ~LogFactory();
|
|
|
|
+ AFUN_TOOL_EXPORT int initLogSystem(ConstFilePath path, bool is_asyn = true);
|
|
|
|
+ AFUN_TOOL_EXPORT bool destruct();
|
|
|
|
+ AFUN_TOOL_EXPORT void writeLog(LogLevel level,
|
|
|
|
+ const char *id, pid_t tid,
|
|
|
|
+ const char *ti, time_t t,
|
|
|
|
+ const char *file, int line, const char *func,
|
|
|
|
+ const char *info);
|
|
|
|
+ AFUN_TOOL_EXPORT static void writeConsole(LogLevel level,
|
|
|
|
+ const char *id, pid_t tid,
|
|
|
|
+ const char *ti, time_t t,
|
|
|
|
+ const char *file, int line, const char *func,
|
|
|
|
+ const char *info);
|
|
|
|
+ AFUN_TOOL_EXPORT void writeLogAsyn(LogLevel level,
|
|
|
|
+ const char *id, pid_t tid,
|
|
|
|
+ const char *ti, time_t t,
|
|
|
|
+ const char *file, int line, const char *func, const char *info);
|
|
|
|
+ AFUN_TOOL_EXPORT int newLog(Logger *logger,
|
|
|
|
+ bool pc,
|
|
|
|
+ LogLevel level,
|
|
|
|
+ const char *file, int line, const char *func,
|
|
|
|
+ const char *format, va_list ap);
|
|
|
|
+ bool news(){ return !init || log_buf != nullptr; }
|
|
|
|
+ int wait(){ return pthread_cond_wait(&cond, &mutex); }
|
|
|
|
+ bool stop(){ return !init && log_buf == nullptr; }
|
|
|
|
+ AFUN_TOOL_EXPORT struct LogNode *pop();
|
|
};
|
|
};
|
|
|
|
|
|
- extern LogFactory log_factory;
|
|
|
|
|
|
+ AFUN_TOOL_EXPORT extern LogFactory log_factory;
|
|
}
|
|
}
|
|
|
|
|
|
#ifndef NO_DEFINE_LOG_MACRO
|
|
#ifndef NO_DEFINE_LOG_MACRO
|