mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
89 lines
2.1 KiB
C++
89 lines
2.1 KiB
C++
#include "LogEasylogging.h"
|
|
#include "easylogging++.h"
|
|
#include <thread>
|
|
// #define ELPP_UNICODE // Define for easylogging
|
|
INITIALIZE_EASYLOGGINGPP // Init easylogging
|
|
// static bool initFlag = false; // Only used for init easyloggingpp
|
|
bool test = false;
|
|
LogEasylogging::LogEasylogging(const LogSetting *setting)
|
|
{
|
|
if (!setting)
|
|
{
|
|
return;
|
|
}
|
|
if (setting->fileName)
|
|
{
|
|
mFileName = setting->fileName;
|
|
}
|
|
if (setting->maxSize)
|
|
{
|
|
mMaxSize = setting->maxSize;
|
|
}
|
|
}
|
|
bool LogEasylogging::Init()
|
|
{
|
|
#if 0
|
|
el::Configurations conf("/home/xiaojiazhu/project/OS/OSThings/test/out/bin/default-logger.conf");
|
|
el::Loggers::reconfigureAllLoggers(conf);
|
|
#endif
|
|
// Set the log path.
|
|
if (mFileName.size() > 0)
|
|
{
|
|
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Filename, mFileName.c_str());
|
|
}
|
|
|
|
// Set the max size of log file.
|
|
// el::Loggers::reconfigureAllLoggers(el::ConfigurationType::MaxLogFileSize, "1048576");
|
|
if (mMaxSize.size() > 0)
|
|
{
|
|
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::MaxLogFileSize, mMaxSize.c_str());
|
|
}
|
|
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "true");
|
|
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::ToFile, "true");
|
|
return true;
|
|
}
|
|
bool LogEasylogging::UnInit()
|
|
{
|
|
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::ToFile, "false");
|
|
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Enabled, "false");
|
|
return true;
|
|
}
|
|
bool LogEasylogging::IsWorking()
|
|
{
|
|
return true;
|
|
}
|
|
int LogEasylogging::Log(const char *buff)
|
|
{
|
|
// LOG(INFO) << buff;
|
|
return 0;
|
|
}
|
|
|
|
int LogEasylogging::InFo(const char *buff)
|
|
{
|
|
LOG(INFO) << buff;
|
|
return 0;
|
|
}
|
|
|
|
int LogEasylogging::Warning(const char *buff)
|
|
{
|
|
LOG(WARNING) << buff;
|
|
return 0;
|
|
}
|
|
|
|
int LogEasylogging::Error(const char *buff)
|
|
{
|
|
LOG(ERROR) << buff;
|
|
return 0;
|
|
}
|
|
|
|
int LogEasylogging::Debug(const char *buff)
|
|
{
|
|
LOG(DEBUG) << buff;
|
|
return 0;
|
|
}
|
|
|
|
int LogEasylogging::Trace(const char *buff)
|
|
{
|
|
LOG(TRACE) << buff;
|
|
return 0;
|
|
} |