Skip to content

Commit

Permalink
Rename methods for setting logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Hanlon committed Feb 20, 2022
1 parent dbb55e8 commit 4fa3c36
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions include/netlist_paths/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ class Options {
void setErrorOnUnmatchedNode(bool value) { errorOnUnmatchedNode = value; }

/// Enable verbose output.
void setVerbose() {
void setLoggingVerbose() {
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::info);
}

/// Enable debug output (including verbose messages).
void setDebug() {
void setLoggingDebug() {
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug);
}

/// Supress verbose and debug messages.
void setQuiet() {
void setLoggingQuiet() {
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning);
}

/// Supress warning, verbose and debug messages.
void setNoWarnings() {
void setLoggingErrorOnly() {
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::error);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ class Options {
errorOnUnmatchedNode(false) {
// Setup logging.
boost::log::add_console_log(std::clog, boost::log::keywords::format = "%Severity%: %Message%");
setQuiet();
setLoggingQuiet();
}

public:
Expand Down
6 changes: 4 additions & 2 deletions lib/netlist_paths/python_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ BOOST_PYTHON_MODULE(py_netlist_paths)
.def("get_instance", &Options::getInstancePtr,
return_value_policy<reference_existing_object>())
.staticmethod("get_instance")
.def("set_verbose", &Options::setVerbose)
.def("set_debug", &Options::setDebug)
.def("set_logging_verbose", &Options::setLoggingVerbose)
.def("set_logging_debug", &Options::setLoggingDebug)
.def("set_logging_quiet", &Options::setLoggingQuiet)
.def("set_logging_error_only", &Options::setLoggingErrorOnly)
.def("set_match_exact", &Options::setMatchExact)
.def("set_match_wildcard", &Options::setMatchWildcard)
.def("set_match_regex", &Options::setMatchRegex)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/VerilatorXMLTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ BOOST_AUTO_TEST_CASE(assign_alias_regs) {
/// have a corresponding variable declaration in a varscope. See
/// https://github.com/jameshanlon/netlist-paths/issues/7
BOOST_AUTO_TEST_CASE(var_no_scope) {
netlist_paths::Options::getInstance().setNoWarnings(); // Supress warning about missing scope.
netlist_paths::Options::getInstance().setLoggingErrorOnly(); // Supress warning about missing scope.
BOOST_CHECK_NO_THROW(compile("var_no_scope.sv"));
BOOST_TEST(!np->isEmpty());
netlist_paths::Options::getInstance().setQuiet();
netlist_paths::Options::getInstance().setLoggingQuiet();
}

BOOST_AUTO_TEST_SUITE_END();
4 changes: 2 additions & 2 deletions tools/netlist-paths/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ int main(int argc, char **argv) {
po::store(po::command_line_parser(argc, argv).
options(allOptions).positional(p).run(), vm);
if (vm.count("debug") > 0) {
netlist_paths::Options::getInstance().setDebug();
netlist_paths::Options::getInstance().setLoggingDebug();
}
if (vm.count("verbose") > 0) {
netlist_paths::Options::getInstance().setVerbose();
netlist_paths::Options::getInstance().setLoggingVerbose();
}
bool displayHelp = vm.count("help") > 0;
bool compile = vm.count("compile") > 0;
Expand Down
4 changes: 2 additions & 2 deletions tools/netlist_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ def main():
help='Ignore hierarchy markers: _ . /')
parser.add_argument('-v', '--verbose',
action='store_const',
const=lambda: Options.get_instance().set_verbose(),
const=lambda: Options.get_instance().set_logging_verbose(),
default=lambda *args: None,
help='Print execution information')
parser.add_argument('-d', '--debug',
action='store_const',
const=lambda: Options.get_instance().set_debug(),
const=lambda: Options.get_instance().set_logging_debug(),
default=lambda *args: None,
help='Print debugging information')
args = parser.parse_args()
Expand Down

0 comments on commit 4fa3c36

Please sign in to comment.