easylogging++: add file-only logs
This commit is contained in:
parent
db9dc7c2df
commit
5bab044984
|
@ -2183,11 +2183,11 @@ void Storage::setApplicationArguments(int argc, char** argv) {
|
|||
void DefaultLogDispatchCallback::handle(const LogDispatchData* data) {
|
||||
m_data = data;
|
||||
dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(),
|
||||
m_data->dispatchAction() == base::DispatchAction::NormalLog));
|
||||
m_data->dispatchAction() == base::DispatchAction::NormalLog || m_data->dispatchAction() == base::DispatchAction::FileOnlyLog));
|
||||
}
|
||||
|
||||
void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) {
|
||||
if (m_data->dispatchAction() == base::DispatchAction::NormalLog) {
|
||||
if (m_data->dispatchAction() == base::DispatchAction::NormalLog || m_data->dispatchAction() == base::DispatchAction::FileOnlyLog) {
|
||||
if (m_data->logMessage()->logger()->m_typedConfigurations->toFile(m_data->logMessage()->level())) {
|
||||
base::type::fstream_t* fs = m_data->logMessage()->logger()->m_typedConfigurations->fileStream(
|
||||
m_data->logMessage()->level());
|
||||
|
@ -2210,10 +2210,12 @@ void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) {
|
|||
<< m_data->logMessage()->logger()->id() << "]", false);
|
||||
}
|
||||
}
|
||||
if (m_data->logMessage()->logger()->m_typedConfigurations->toStandardOutput(m_data->logMessage()->level())) {
|
||||
if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput))
|
||||
m_data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, m_data->logMessage()->level());
|
||||
ELPP_COUT << ELPP_COUT_LINE(logLine);
|
||||
if (m_data->dispatchAction() != base::DispatchAction::FileOnlyLog) {
|
||||
if (m_data->logMessage()->logger()->m_typedConfigurations->toStandardOutput(m_data->logMessage()->level())) {
|
||||
if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput))
|
||||
m_data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, m_data->logMessage()->level());
|
||||
ELPP_COUT << ELPP_COUT_LINE(logLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(ELPP_SYSLOG)
|
||||
|
@ -2249,8 +2251,8 @@ void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) {
|
|||
|
||||
void AsyncLogDispatchCallback::handle(const LogDispatchData* data) {
|
||||
base::type::string_t logLine = data->logMessage()->logger()->logBuilder()->build(data->logMessage(),
|
||||
data->dispatchAction() == base::DispatchAction::NormalLog);
|
||||
if (data->dispatchAction() == base::DispatchAction::NormalLog
|
||||
data->dispatchAction() == base::DispatchAction::NormalLog || data->dispatchAction() == base::DispatchAction::FileOnlyLog);
|
||||
if ((data->dispatchAction() == base::DispatchAction::NormalLog || data->dispatchAction() == base::DispatchAction::FileOnlyLog)
|
||||
&& data->logMessage()->logger()->typedConfigurations()->toStandardOutput(data->logMessage()->level())) {
|
||||
if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput))
|
||||
data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, data->logMessage()->level());
|
||||
|
@ -2305,7 +2307,7 @@ void AsyncDispatchWorker::handle(AsyncLogItem* logItem) {
|
|||
Logger* logger = logMessage->logger();
|
||||
base::TypedConfigurations* conf = logger->typedConfigurations();
|
||||
base::type::string_t logLine = logItem->logLine();
|
||||
if (data->dispatchAction() == base::DispatchAction::NormalLog) {
|
||||
if (data->dispatchAction() == base::DispatchAction::NormalLog || data->dispatchAction() == base::DispatchAction::FileOnlyLog) {
|
||||
if (conf->toFile(logMessage->level())) {
|
||||
base::type::fstream_t* fs = conf->fileStream(logMessage->level());
|
||||
if (fs != nullptr) {
|
||||
|
|
|
@ -2183,7 +2183,7 @@ class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCoun
|
|||
};
|
||||
/// @brief Action to be taken for dispatching
|
||||
enum class DispatchAction : base::type::EnumType {
|
||||
None = 1, NormalLog = 2, SysLog = 4
|
||||
None = 1, NormalLog = 2, SysLog = 4, FileOnlyLog = 8,
|
||||
};
|
||||
} // namespace base
|
||||
template <typename T>
|
||||
|
|
Loading…
Reference in New Issue