Skip to content

Commit a75eca5

Browse files
author
Matthias Koefferlein
committed
Fixing issue #1971: providing log levels -10 to disable warnings and -20 to disable errors too.
1 parent 07da5a3 commit a75eca5

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed

src/tl/tl/tlLog.cc

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -392,34 +392,42 @@ WarningChannel::~WarningChannel ()
392392
void
393393
WarningChannel::puts (const char *s)
394394
{
395-
fputs (s, stdout);
395+
if (verbosity () >= 0) {
396+
fputs (s, stdout);
397+
}
396398
}
397399

398400
void
399401
WarningChannel::endl ()
400402
{
401-
fputs ("\n", stdout);
402-
m_new_line = true;
403+
if (verbosity () >= 0) {
404+
fputs ("\n", stdout);
405+
m_new_line = true;
406+
}
403407
}
404408

405409
void
406410
WarningChannel::end ()
407411
{
408-
if (m_colorized) {
409-
fputs (ANSI_RESET, stdout);
412+
if (verbosity () >= 0) {
413+
if (m_colorized) {
414+
fputs (ANSI_RESET, stdout);
415+
}
416+
fflush (stdout);
410417
}
411-
fflush (stdout);
412418
}
413419

414420
void
415421
WarningChannel::begin ()
416422
{
417-
if (m_colorized) {
418-
fputs (ANSI_BLUE, stdout);
419-
}
420-
if (m_new_line) {
421-
fputs ("Warning: ", stdout);
422-
m_new_line = false;
423+
if (verbosity () >= 0) {
424+
if (m_colorized) {
425+
fputs (ANSI_BLUE, stdout);
426+
}
427+
if (m_new_line) {
428+
fputs ("Warning: ", stdout);
429+
m_new_line = false;
430+
}
423431
}
424432
}
425433

@@ -463,34 +471,42 @@ ErrorChannel::~ErrorChannel ()
463471
void
464472
ErrorChannel::puts (const char *s)
465473
{
466-
fputs (s, stderr);
474+
if (verbosity () >= -10) {
475+
fputs (s, stderr);
476+
}
467477
}
468478

469479
void
470480
ErrorChannel::endl ()
471481
{
472-
fputs ("\n", stderr);
473-
m_new_line = true;
482+
if (verbosity () >= -10) {
483+
fputs ("\n", stderr);
484+
m_new_line = true;
485+
}
474486
}
475487

476488
void
477489
ErrorChannel::end ()
478490
{
479-
if (m_colorized) {
480-
fputs (ANSI_RESET, stderr);
491+
if (verbosity () >= -10) {
492+
if (m_colorized) {
493+
fputs (ANSI_RESET, stderr);
494+
}
495+
fflush (stderr);
481496
}
482-
fflush (stderr);
483497
}
484498

485499
void
486500
ErrorChannel::begin ()
487501
{
488-
if (m_colorized) {
489-
fputs (ANSI_RED, stderr);
490-
}
491-
if (m_new_line) {
492-
fputs ("ERROR: ", stderr);
493-
m_new_line = false;
502+
if (verbosity () >= -10) {
503+
if (m_colorized) {
504+
fputs (ANSI_RED, stderr);
505+
}
506+
if (m_new_line) {
507+
fputs ("ERROR: ", stderr);
508+
m_new_line = false;
509+
}
494510
}
495511
}
496512

0 commit comments

Comments
 (0)