[Openmp-commits] [openmp] [OpenMP] Add ompTest library to OpenMP (PR #147381)
Jan Patrick Lehr via Openmp-commits
openmp-commits at lists.llvm.org
Tue Aug 5 03:05:02 PDT 2025
================
@@ -0,0 +1,177 @@
+//===- Logging.cpp - General logging class implementation -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implements ompTest-tailored logging.
+///
+//===----------------------------------------------------------------------===//
+
+#include "Logging.h"
+
+using namespace omptest;
+using namespace logging;
+
+Logger::Logger(Level LogLevel, std::ostream &OutStream, bool FormatOutput)
+ : LoggingLevel(LogLevel), OutStream(OutStream), FormatOutput(FormatOutput) {
+ // Flush any buffered output
+ OutStream << std::flush;
+}
+
+Logger::~Logger() {
+ // Flush any buffered output
+ OutStream << std::flush;
+}
+
+std::map<Level, std::set<FormatOption>> AggregatedFormatOptions{
+ {Level::DIAGNOSTIC, {FormatOption::COLOR_LightBlue}},
+ {Level::INFO, {FormatOption::COLOR_LightGray}},
+ {Level::WARNING, {FormatOption::COLOR_LightYellow}},
+ {Level::ERROR, {FormatOption::COLOR_Red}},
+ {Level::CRITICAL, {FormatOption::COLOR_LightRed}},
+ {Level::Default, {FormatOption::NONE}},
+ {Level::ExpectedEvent, {FormatOption::BOLD, FormatOption::COLOR_Cyan}},
+ {Level::ObservedEvent, {FormatOption::COLOR_Cyan}},
+ {Level::OffendingEvent, {FormatOption::COLOR_Yellow}}};
+
+const char *logging::to_string(Level LogLevel) {
----------------
jplehr wrote:
Why is this inconsistent with the rest of the interface?
```suggestion
const char *logging::toString(Level LogLevel) {
```
https://github.com/llvm/llvm-project/pull/147381
More information about the Openmp-commits
mailing list