Add verbosity stream
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
5de8b3a8ee
commit
52bd8b8b52
3 changed files with 50 additions and 1 deletions
|
@ -1 +1 @@
|
|||
add_library(util trace.cpp debug.cpp name.cpp exception.cpp)
|
||||
add_library(util trace.cpp debug.cpp name.cpp exception.cpp verbosity.cpp)
|
||||
|
|
31
src/util/verbosity.cpp
Normal file
31
src/util/verbosity.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#include "verbosity.h"
|
||||
|
||||
namespace lean {
|
||||
|
||||
unsigned g_verbosity_level = 0;
|
||||
|
||||
void set_verbosity_level(unsigned lvl) {
|
||||
g_verbosity_level = lvl;
|
||||
}
|
||||
|
||||
unsigned get_verbosity_level() {
|
||||
return g_verbosity_level;
|
||||
}
|
||||
|
||||
static std::ostream* g_verbose_stream = &std::cerr;
|
||||
|
||||
void set_verbose_stream(std::ostream& str) {
|
||||
g_verbose_stream = &str;
|
||||
}
|
||||
|
||||
std::ostream& verbose_stream() {
|
||||
return *g_verbose_stream;
|
||||
}
|
||||
|
||||
}
|
18
src/util/verbosity.h
Normal file
18
src/util/verbosity.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
|
||||
namespace lean {
|
||||
void set_verbosity_level(unsigned lvl);
|
||||
unsigned get_verbosity_level();
|
||||
std::ostream& verbose_stream();
|
||||
void set_verbose_stream(std::ostream& s);
|
||||
#define lean_verbose(LVL, CODE) { if (get_verbosity_level() >= LVL) { CODE } }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue