|
|
|
|
|
#ifndef _QLOGGING_H_
|
|
|
|
|
|
#define _QLOGGING_H_
|
|
|
|
|
|
#include "LogStream.h"
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
namespace SystemLog {
|
|
|
|
|
|
class lpLogging
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
enum LogLevel {
|
|
|
|
|
|
PARAM = 0,//<2F><><EFBFBD><EFBFBD> <20>ļ<DEB8>¼
|
|
|
|
|
|
USER = 1,//<2F>û<EFBFBD><C3BB><EFBFBD>¼<EFBFBD><C2BC>¼
|
|
|
|
|
|
STATUS = 2,//ϵͳ״̬<D7B4><CCAC>¼
|
|
|
|
|
|
WARN = 3,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|
|
|
|
|
INFO = 4,//<2F><>Ϣ <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
NUM_LOG_LEVELS,//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
};
|
|
|
|
|
|
lpLogging();
|
|
|
|
|
|
lpLogging(LogLevel level);
|
|
|
|
|
|
lpLogging(LogLevel level, const char* func);
|
|
|
|
|
|
~lpLogging();
|
|
|
|
|
|
|
|
|
|
|
|
LogStream& stream()
|
|
|
|
|
|
{
|
|
|
|
|
|
return impl_.stream_;
|
|
|
|
|
|
}
|
|
|
|
|
|
static LogLevel logLevel();
|
|
|
|
|
|
static void setLogLevel(LogLevel level);
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::function<void(int ntypeID, const char* msg, int len)> OutputFunc;
|
|
|
|
|
|
typedef std::function<void()> FlushFunc;
|
|
|
|
|
|
static void setOutput(OutputFunc);
|
|
|
|
|
|
static void setFlush(FlushFunc);
|
|
|
|
|
|
private:
|
|
|
|
|
|
class Impl {
|
|
|
|
|
|
public:
|
|
|
|
|
|
typedef lpLogging::LogLevel LogLevel;
|
|
|
|
|
|
Impl(LogLevel level, int old_errno);
|
|
|
|
|
|
void formatTime();
|
|
|
|
|
|
void finish();
|
|
|
|
|
|
LogStream stream_;
|
|
|
|
|
|
LogLevel level_;
|
|
|
|
|
|
};
|
|
|
|
|
|
Impl impl_;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define SYSLOG_PARAM SystemLog::lpLogging(SystemLog::lpLogging::PARAM).stream()
|
|
|
|
|
|
#define SYSLOG_USER SystemLog::lpLogging(SystemLog::lpLogging::USER).stream()
|
|
|
|
|
|
#define SYSLOG_STATUS SystemLog::lpLogging(SystemLog::lpLogging::STATUS).stream()
|
|
|
|
|
|
#define SYSLOG_WARN SystemLog::lpLogging(SystemLog::lpLogging::WARN).stream()
|
|
|
|
|
|
#define SYSLOG_INFO SystemLog::lpLogging(SystemLog::lpLogging::INFO).stream()
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|