File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,30 @@ getLevel(unsigned level) noexcept
240240 }
241241}
242242
243+ constexpr
244+ llvm::raw_ostream::Colors
245+ getLevelColor (Level level)
246+ {
247+ switch (level)
248+ {
249+ case Level::trace:
250+ return llvm::raw_ostream::Colors::CYAN;
251+ case Level::debug:
252+ return llvm::raw_ostream::Colors::GREEN;
253+ case Level::info:
254+ return llvm::raw_ostream::Colors::WHITE;
255+ case Level::warn:
256+ return llvm::raw_ostream::Colors::MAGENTA;
257+ case Level::error:
258+ return llvm::raw_ostream::Colors::RED;
259+ case Level::fatal:
260+ return llvm::raw_ostream::Colors::RED;
261+ default :
262+ MRDOCS_UNREACHABLE ();
263+ }
264+ }
265+
266+
243267void
244268call_impl (
245269 Level level,
@@ -282,7 +306,15 @@ call_impl(
282306 std::lock_guard<llvm::sys::Mutex> lock (mutex_);
283307 if (!s.empty())
284308 {
285- llvm::errs () << s;
309+ if (level >= Level::error)
310+ {
311+ llvm::errs () << s;
312+ }
313+ else
314+ {
315+ llvm::outs () << getLevelColor (level) << s << llvm::raw_ostream::Colors::RESET;
316+ llvm::outs ().flush ();
317+ }
286318 }
287319 switch (level)
288320 {
You can’t perform that action at this time.
0 commit comments