Skip to content

Commit 91faf6f

Browse files
committed
info messages are streamed to stdio
#improvement
1 parent 19ecb23 commit 91faf6f

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/lib/Support/Error.cpp

+33-1
Original file line numberDiff line numberDiff 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+
243267
void
244268
call_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
{

0 commit comments

Comments
 (0)