From c4d393b562cb0feb90f75de6e021e746af45295a Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 8 May 2023 12:22:37 +0200 Subject: [PATCH 1/3] Changed default -v level --- conan/api/output.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/conan/api/output.py b/conan/api/output.py index 8267d0ef111..85ae2ec7fc1 100644 --- a/conan/api/output.py +++ b/conan/api/output.py @@ -51,6 +51,17 @@ class ConanOutput: # Singleton _conan_output_level = LEVEL_STATUS _silent_warn_tags = [] + _output_levels = {"quiet": LEVEL_QUIET, # -vquiet 80 + "error": LEVEL_ERROR, # -verror 70 + "warning": LEVEL_WARNING, # -vwaring 60 + "notice": LEVEL_NOTICE, # -vnotice 50 + "status": LEVEL_STATUS, # -vstatus 40 + None: LEVEL_VERBOSE, # -v 30 + "verbose": LEVEL_VERBOSE, # -vverbose 30 + "debug": LEVEL_DEBUG, # -vdebug 20 + "v": LEVEL_DEBUG, # -vv 20 + "trace": LEVEL_TRACE, # -vtrace 10 + "vv": LEVEL_TRACE} # -vvv 10 def __init__(self, scope=""): self.stream = sys.stderr @@ -65,23 +76,18 @@ def define_silence_warnings(cls, warnings): @classmethod def define_log_level(cls, v): - levels = {"quiet": LEVEL_QUIET, # -vquiet 80 - "error": LEVEL_ERROR, # -verror 70 - "warning": LEVEL_WARNING, # -vwaring 60 - "notice": LEVEL_NOTICE, # -vnotice 50 - "status": LEVEL_STATUS, # -vstatus 40 - None: LEVEL_STATUS, # -v 40 - "verbose": LEVEL_VERBOSE, # -vverbose 30 - "debug": LEVEL_DEBUG, # -vdebug 20 - "v": LEVEL_DEBUG, # -vv 20 - "trace": LEVEL_TRACE, # -vtrace 10 - "vv": LEVEL_TRACE, # -vvv 10 - } - - level = levels.get(v) - if not level: + """ + Translates the verbosity level entered by a Conan command. If it's `None` (-v), + it will be defaulted to `verbose` level. + + :param v: `str` or `None`, where `None` is the same as `verbose`. + """ + try: + level = cls._output_levels[v] + except KeyError: raise ConanException(f"Invalid argument '-v{v}'") - cls._conan_output_level = level + else: + cls._conan_output_level = level @classmethod def level_allowed(cls, level): From f0a310915da246f905dfb0a0c3efac82bea6baa9 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 8 May 2023 12:27:56 +0200 Subject: [PATCH 2/3] fix test --- conans/test/integration/command_v2/test_output_level.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conans/test/integration/command_v2/test_output_level.py b/conans/test/integration/command_v2/test_output_level.py index ade77607ce6..f485424924e 100644 --- a/conans/test/integration/command_v2/test_output_level.py +++ b/conans/test/integration/command_v2/test_output_level.py @@ -37,11 +37,11 @@ def test_output_level(): assert "This is a warning" in t.out assert "This is a error" in t.out - # Print also verbose traces + # Check if -v argument is equal to VERBOSE level t.run("create . --name foo --version 1.0 -v") assert "This is a trace" not in t.out assert "This is a debug" not in t.out - assert "This is a verbose" not in t.out + assert "This is a verbose" in t.out assert "This is a info" in t.out assert "This is a highlight" in t.out assert "This is a success" in t.out From a0c6b2b727811bc5842e2811a994f978d43aed8f Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 8 May 2023 13:02:22 +0200 Subject: [PATCH 3/3] reverted --- conan/api/output.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/conan/api/output.py b/conan/api/output.py index 85ae2ec7fc1..0e856477e8b 100644 --- a/conan/api/output.py +++ b/conan/api/output.py @@ -51,17 +51,6 @@ class ConanOutput: # Singleton _conan_output_level = LEVEL_STATUS _silent_warn_tags = [] - _output_levels = {"quiet": LEVEL_QUIET, # -vquiet 80 - "error": LEVEL_ERROR, # -verror 70 - "warning": LEVEL_WARNING, # -vwaring 60 - "notice": LEVEL_NOTICE, # -vnotice 50 - "status": LEVEL_STATUS, # -vstatus 40 - None: LEVEL_VERBOSE, # -v 30 - "verbose": LEVEL_VERBOSE, # -vverbose 30 - "debug": LEVEL_DEBUG, # -vdebug 20 - "v": LEVEL_DEBUG, # -vv 20 - "trace": LEVEL_TRACE, # -vtrace 10 - "vv": LEVEL_TRACE} # -vvv 10 def __init__(self, scope=""): self.stream = sys.stderr @@ -83,7 +72,18 @@ def define_log_level(cls, v): :param v: `str` or `None`, where `None` is the same as `verbose`. """ try: - level = cls._output_levels[v] + level = {"quiet": LEVEL_QUIET, # -vquiet 80 + "error": LEVEL_ERROR, # -verror 70 + "warning": LEVEL_WARNING, # -vwaring 60 + "notice": LEVEL_NOTICE, # -vnotice 50 + "status": LEVEL_STATUS, # -vstatus 40 + None: LEVEL_VERBOSE, # -v 30 + "verbose": LEVEL_VERBOSE, # -vverbose 30 + "debug": LEVEL_DEBUG, # -vdebug 20 + "v": LEVEL_DEBUG, # -vv 20 + "trace": LEVEL_TRACE, # -vtrace 10 + "vv": LEVEL_TRACE # -vvv 10 + }[v] except KeyError: raise ConanException(f"Invalid argument '-v{v}'") else: