I may not be using the right names, but hopefully this post can be understood.
In logmanager.h the following app types are defined:enum {no_index = -1, invalid_log, stdout_log, app_log, debug_log};
In the app.cpp the following block if you do not look at the underlying code you would assume allows multiple loggers (TextCtrlLogger, FileLogger, StdoutLogger, NullLogger) for the same LogManager::app_log or LogManager::debug_log:
if (parser.Found(_T("no-log")) == false)
Manager::Get()->GetLogManager()->SetLog(new TextCtrlLogger, LogManager::app_log);
if (parser.Found(_T("log-to-file")))
Manager::Get()->GetLogManager()->SetLog(new FileLogger(_T("codeblocks.log")), LogManager::app_log);
if (m_HasDebugLog)
Manager::Get()->GetLogManager()->SetLog(new TextCtrlLogger, LogManager::debug_log);
if (parser.Found(_T("debug-log-to-file")))
Manager::Get()->GetLogManager()->SetLog(new FileLogger(_T("codeblocks-debug.log")), LogManager::debug_log);
But the Manager::Get()->GetLogManager()->SetLog(....) code does not allow multiple loggers for the same app types (parameter i)
size_t LogManager::SetLog(Logger* l, int i)
{
unsigned int index = i;
if (i <= no_index)
{
for (index = debug_log + 1; index < max_logs; ++index)
{
if (slot[index].GetLogger() == &g_null_log)
{
slot[index].SetLogger(l);
return index;
}
}
delete l;
return invalid_log;
}
slot[index].SetLogger(l);
return index;
}
I have been pulling my hair out as there is no error message if the app.cpp block tries to register multiple loggers.
Is there any reason that the code as to why the code could/should not be enhanced to support multiple loggers for the one app type so the logs can be shown on the console/gui and also logged to a file? Before I do anything I thought I should ask as I am puzzled as to why the someone has not updated the code to support multiple loggers.
Just for completeness the log level log function follows that calls the logger type to do the logging:
void LogManager::LogInternal(const wxString& msg, int i, Logger::level lv)
{
if (i >= 0 && i <= max_logs && slot[i].log != &g_null_log)
slot[i].log->Append(msg, lv);
}