21 : LoggingLevel(LogLevel), OutStream(OutStream), FormatOutput(FormatOutput) {
24 FormatOutput = EnvVal.value();
26 OutStream << std::flush;
31 OutStream << std::flush;
60 assert(
false &&
"Requested string representation for unknown LogLevel");
67 std::stringstream SS{
"\033["};
69 if (!Options.empty()) {
71 SS <<
int(Option) <<
';';
82 std::stringstream SS{
"\033["};
84 SS <<
int(Option) <<
'm' << Message <<
"\033[0m";
89 std::set<FormatOption> Options) {
90 std::stringstream SS{
"\033["};
92 for (
auto &Option : Options)
93 SS <<
int(Option) <<
';';
95 SS <<
'm' << Message <<
"\033[0m";
101 std::lock_guard<std::mutex> Lock(LogMutex);
103 if (LoggingLevel > LogLevel)
110 OutStream <<
'[' <<
to_string(LogLevel) <<
"] " << Message << std::endl;
116 Level LogLevel)
const {
118 std::lock_guard<std::mutex> Lock(LogMutex);
119 if (LoggingLevel > LogLevel)
126 <<
"\n\tOffending event name='"
129 <<
"'\n\tOffending='"
132 <<
'\'' << std::endl;
134 OutStream <<
'[' <<
to_string(LogLevel) <<
"] " << Message
144 Level LogLevel)
const {
146 std::lock_guard<std::mutex> Lock(LogMutex);
147 if (LoggingLevel > LogLevel)
153 <<
"\n\tExpected event name='"
159 <<
"'\n\tObserved event name='"
168 <<
'\'' << std::endl;
170 OutStream <<
'[' <<
to_string(LogLevel) <<
"] " << Message
171 <<
"\n\tExpected event name='" <<
ExpectedEvent.getEventName()
174 <<
"'\n\tObserved event name='" <<
ObservedEvent.getEventName()
Provides environment helpers shared between a couple of places.
std::map< Level, std::set< FormatOption > > AggregatedFormatOptions
Provides ompTest-tailored logging, with log-levels and formatting/coloring.
void log(const std::string &Message, Level LogLevel) const
Log the given message to the output.
Logger(Level LogLevel=Level::Warning, std::ostream &OutStream=std::cerr, bool FormatOutput=true)
void setFormatOutput(bool Enabled)
Set if output is being formatted (e.g. colored).
Level getLoggingLevel() const
Return the current (minimum) Logging Level.
void logEventMismatch(const std::string &Message, const omptest::OmptAssertEvent &OffendingEvent, Level LogLevel=Level::Error) const
Log a single event mismatch.
void setLoggingLevel(Level LogLevel)
Set the (minimum) Logging Level.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
std::string getFormatSequence(Level LogLevel=Level::Default)
Returns the format options as escaped sequence, for the given logging level.
const char * to_string(Level LogLevel)
Returns a string representation of the given logging level.
std::string format(const std::string &Message, FormatOption Option)
Format the given message with the provided option(s) and return it.
std::optional< bool > getBoolEnvironmentVariable(const char *VariableName)
Load the value of a given boolean environmental variable.
Assertion event struct, provides statically callable CTORs.