Skip to content

Commit

Permalink
[SCons] Add default logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and bryanwweber committed Jun 12, 2022
1 parent 8ee17a4 commit 5b689df
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions SConstruct
Expand Up @@ -101,11 +101,21 @@ valid_commands = ("build", "clean", "install", "uninstall",
"help", "msi", "samples", "sphinx", "doxygen", "dump",
"sdist")

# set default logging level
if GetOption("silent"):
logger.logger.setLevel("ERROR")
else:
logger.logger.setLevel("WARNING")

for command in COMMAND_LINE_TARGETS:
if command not in valid_commands and not command.startswith('test'):
logger.error("Unrecognized command line target: {!r}", command)
sys.exit(1)

# update default logging level
if command in ["build"] and not GetOption("silent"):
logger.logger.setLevel("INFO")

if "clean" in COMMAND_LINE_TARGETS:
remove_directory("build")
remove_directory("stage")
Expand Down Expand Up @@ -511,7 +521,7 @@ config_options = [
EnumOption(
"logging",
"""Select logging level for SCons output. """,
"info", ("debug", "info", "warning", "error")),
"default", ("debug", "info", "warning", "error", "default")),
Option(
"gtest_flags",
"""Additional options passed to each GTest test suite, for example,
Expand Down Expand Up @@ -884,7 +894,8 @@ logger.info(textwrap.indent(cantera_conf, " "), print_level=False)
# ********************************************

loglevel = env["logging"]
logger.logger.setLevel(loglevel.upper())
if loglevel != "default":
logger.logger.setLevel(loglevel.upper())

if env["VERBOSE"]:
# @todo: Remove after Cantera 3.0
Expand Down

0 comments on commit 5b689df

Please sign in to comment.