Skip to content

Commit

Permalink
Fixing issue #1971: providing log levels -10 to disable warnings and …
Browse files Browse the repository at this point in the history
…-20 to disable errors too.
  • Loading branch information
Matthias Koefferlein committed Jan 16, 2025
1 parent 07da5a3 commit a75eca5
Showing 1 changed file with 40 additions and 24 deletions.
64 changes: 40 additions & 24 deletions src/tl/tl/tlLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,34 +392,42 @@ WarningChannel::~WarningChannel ()
void
WarningChannel::puts (const char *s)
{
fputs (s, stdout);
if (verbosity () >= 0) {
fputs (s, stdout);
}
}

void
WarningChannel::endl ()
{
fputs ("\n", stdout);
m_new_line = true;
if (verbosity () >= 0) {
fputs ("\n", stdout);
m_new_line = true;
}
}

void
WarningChannel::end ()
{
if (m_colorized) {
fputs (ANSI_RESET, stdout);
if (verbosity () >= 0) {
if (m_colorized) {
fputs (ANSI_RESET, stdout);
}
fflush (stdout);
}
fflush (stdout);
}

void
WarningChannel::begin ()
{
if (m_colorized) {
fputs (ANSI_BLUE, stdout);
}
if (m_new_line) {
fputs ("Warning: ", stdout);
m_new_line = false;
if (verbosity () >= 0) {
if (m_colorized) {
fputs (ANSI_BLUE, stdout);
}
if (m_new_line) {
fputs ("Warning: ", stdout);
m_new_line = false;
}
}
}

Expand Down Expand Up @@ -463,34 +471,42 @@ ErrorChannel::~ErrorChannel ()
void
ErrorChannel::puts (const char *s)
{
fputs (s, stderr);
if (verbosity () >= -10) {
fputs (s, stderr);
}
}

void
ErrorChannel::endl ()
{
fputs ("\n", stderr);
m_new_line = true;
if (verbosity () >= -10) {
fputs ("\n", stderr);
m_new_line = true;
}
}

void
ErrorChannel::end ()
{
if (m_colorized) {
fputs (ANSI_RESET, stderr);
if (verbosity () >= -10) {
if (m_colorized) {
fputs (ANSI_RESET, stderr);
}
fflush (stderr);
}
fflush (stderr);
}

void
ErrorChannel::begin ()
{
if (m_colorized) {
fputs (ANSI_RED, stderr);
}
if (m_new_line) {
fputs ("ERROR: ", stderr);
m_new_line = false;
if (verbosity () >= -10) {
if (m_colorized) {
fputs (ANSI_RED, stderr);
}
if (m_new_line) {
fputs ("ERROR: ", stderr);
m_new_line = false;
}
}
}

Expand Down

0 comments on commit a75eca5

Please sign in to comment.