-// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <iostream>
#include <stdexcept>
+#include <chrono>
+#include <iomanip>
+#include <ctime>
+
enum class VerbosityMode { undefined, nolog, withlog };
static VerbosityMode isActivated = VerbosityMode::undefined;
return verbosityLevel;
}
- void BASICS_EXPORT SetVerbosityLevel(VerbosityLevelType level)
+ void SetVerbosityLevel(VerbosityLevelType level)
{
verbosityLevel = level;
}
verbosityLevel = FromStrToVerbosityLevel(level);
}
+ std::vector<std::string> GetAllVerbosityLevelPossibilitiesStr()
+ {
+ return {ERROR_LEVEL_VALUE_STR,WARNING_LEVEL_VALUE_STR,INFO_LEVEL_VALUE_STR,DEBUG_LEVEL_VALUE_STR};
+ }
+
std::string VerbosityLevelStr()
{
return FromVerbosityLevelToStr( VerbosityLevel() );
{
return VerbosityLevel() >= VerbosityLevelType::error_level;
}
+
+ void AppendTimeClock(std::ostream& os)
+ {
+ auto now = std::chrono::system_clock::now();
+ auto duration = now.time_since_epoch();
+ auto timestamp = std::chrono::system_clock::to_time_t(now);
+ std::tm *local_time = std::localtime(×tamp);
+ auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
+ os << std::setfill('0') << std::setw(2) << local_time->tm_hour << ":"
+ << std::setw(2) << local_time->tm_min << ":"
+ << std::setw(2) << local_time->tm_sec << "." << std::setw(3) << millis % 1000 << " - ";
+ }
}