17using namespace logging;
20 : LoggingLevel(LogLevel), OutStream(OutStream), FormatOutput(FormatOutput) {
22 OutStream << std::flush;
27 OutStream << std::flush;
56 assert(
false &&
"Requested string representation for unknown LogLevel");
63 std::stringstream SS{
"\033["};
65 if (!Options.empty()) {
67 SS <<
int(Option) <<
';';
78 std::stringstream SS{
"\033["};
80 SS <<
int(Option) <<
'm' << Message <<
"\033[0m";
85 std::set<FormatOption> Options) {
86 std::stringstream SS{
"\033["};
88 for (
auto &Option : Options)
89 SS <<
int(Option) <<
';';
91 SS <<
'm' << Message <<
"\033[0m";
97 std::lock_guard<std::mutex> Lock(LogMutex);
99 if (LoggingLevel > LogLevel)
106 OutStream <<
'[' <<
to_string(LogLevel) <<
"] " << Message << std::endl;
112 Level LogLevel)
const {
114 std::lock_guard<std::mutex> Lock(LogMutex);
115 if (LoggingLevel > LogLevel)
122 <<
"\n\tOffending event name='"
125 <<
"'\n\tOffending='"
128 <<
'\'' << std::endl;
130 OutStream <<
'[' <<
to_string(LogLevel) <<
"] " << Message
140 Level LogLevel)
const {
142 std::lock_guard<std::mutex> Lock(LogMutex);
143 if (LoggingLevel > LogLevel)
149 <<
"\n\tExpected event name='"
155 <<
"'\n\tObserved event name='"
164 <<
'\'' << std::endl;
166 OutStream <<
'[' <<
to_string(LogLevel) <<
"] " << Message
167 <<
"\n\tExpected event name='" <<
ExpectedEvent.getEventName()
170 <<
"'\n\tObserved event name='" <<
ObservedEvent.getEventName()
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.
Assertion event struct, provides statically callable CTORs.