Commit d889bdf3 authored by Victor Poughon's avatar Victor Poughon

ENH: add back custom logger formatting

parent f3b1326f
Pipeline #334 passed with stage
in 30 minutes and 2 seconds
......@@ -69,6 +69,9 @@ public:
/** Set the flag m_LogSetupInfoDone to true */
void LogSetupInformationDone();
// Overwrite this to provide custom formatting of log entries
std::string BuildFormattedEntry(itk::Logger::PriorityLevelType, std::string const&) override;
protected:
Logger();
virtual ~Logger() override = default;
......
......@@ -26,6 +26,9 @@
#include "gdal.h"
#include "itkMultiThreader.h"
#include <type_traits>
#include <cassert>
namespace otb
{
......@@ -117,4 +120,32 @@ void Logger::LogSetupInformationDone()
m_LogSetupInfoDone = true;
}
std::string Logger::BuildFormattedEntry(itk::Logger::PriorityLevelType level, std::string const& content)
{
static const std::string levelString[] = {"(MUSTFLUSH)", "(FATAL)", "(CRITICAL)", "(WARNING)", "(INFO)", "(DEBUG)", "(NOTSET)"};
assert(level <= std::extent<decltype(levelString)>::value);
std::ostringstream s;
switch (this->m_TimeStampFormat)
{
case REALVALUE:
{
s.precision(30);
s << m_Clock->GetTimeInSeconds();
break;
}
case HUMANREADABLE:
{
s << itksys::SystemTools::GetCurrentDateTime(this->m_HumanReadableFormat.c_str());
break;
}
}
s << " " << levelString[level] << ": " << content;
return s.str();
}
} // namespace otb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment