Skip to content

Commit

Permalink
set CYLC_DEBUG env var when set-verbosity DEBUG (cylc#5854)
Browse files Browse the repository at this point in the history
set CYLC_DEBUG env var when set-verbosity DEBUG

---------

Co-authored-by: Ronnie Dutta <[email protected]>
  • Loading branch information
markgrahamdawson and MetRonnie authored Jan 4, 2024
1 parent 69988b0 commit dd41648
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cylc/flow/option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ def log_level_to_verbosity(lvl: int) -> int:
>>> log_level_to_verbosity(logging.NOTSET)
2
>>> log_level_to_verbosity(logging.DEBUG)
1
2
>>> log_level_to_verbosity(logging.INFO)
0
>>> log_level_to_verbosity(logging.WARNING)
-1
>>> log_level_to_verbosity(logging.ERROR)
-1
"""
if lvl < logging.DEBUG:
if lvl <= logging.DEBUG:
return 2
if lvl < logging.INFO:
return 1
Expand Down
34 changes: 24 additions & 10 deletions tests/functional/cli/03-set-verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#-------------------------------------------------------------------------------
# Test "cylc set-verbosity"
. "$(dirname "$0")/test_header"
set_test_number 6
set_test_number 4

# Test illegal log level
TEST_NAME="${TEST_NAME_BASE}-bad"
Expand All @@ -28,18 +28,32 @@ grep_ok 'InputError: Illegal logging level, duck' "${TEST_NAME}.stderr"
TEST_NAME="${TEST_NAME_BASE}-good"
init_workflow "${TEST_NAME_BASE}" << '__FLOW__'
[scheduler]
allow implicit tasks = True
[[events]]
abort on stall timeout = True
stall timeout = PT0S
[scheduling]
[[graph]]
R1 = andor
R1 = setter => getter
[runtime]
[[setter]]
script = """
echo "CYLC_VERBOSE: $CYLC_VERBOSE"
[[ "$CYLC_VERBOSE" != 'true' ]]
echo "CYLC_DEBUG: $CYLC_DEBUG"
[[ "$CYLC_DEBUG" != 'true' ]]
cylc set-verbosity DEBUG "$CYLC_WORKFLOW_ID"
cylc__job__poll_grep_workflow_log 'Command actioned: set_verbosity'
"""
[[getter]]
script = """
echo "CYLC_VERBOSE: $CYLC_VERBOSE"
[[ "$CYLC_VERBOSE" == 'true' ]]
echo "CYLC_DEBUG: $CYLC_DEBUG"
[[ "$CYLC_DEBUG" == 'true' ]]
"""
__FLOW__

run_ok "${TEST_NAME}-validate" cylc validate "$WORKFLOW_NAME"
workflow_run_ok "${TEST_NAME}-run" cylc play --pause "$WORKFLOW_NAME"

run_ok "$TEST_NAME" cylc set-verbosity DEBUG "$WORKFLOW_NAME"
log_scan "${TEST_NAME}-grep" "${WORKFLOW_RUN_DIR}/log/scheduler/log" 5 1 \
'Command actioned: set_verbosity'

cylc stop "$WORKFLOW_NAME"
workflow_run_ok "${TEST_NAME}-run" cylc play --no-detach "$WORKFLOW_NAME"
purge

0 comments on commit dd41648

Please sign in to comment.