Skip to content

Commit 70eac85

Browse files
Enable debug logging only if JOFT_DEBUG env var is defined (#30)
1 parent 1705324 commit 70eac85

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ To run the actions from your yaml template file run:
3636

3737
`joft run --template ./<path to your yaml template>`
3838

39+
If you need more verbose output for debugging, define `JOFT_DEBUG=1` environment variable.
40+
3941
## Docs
4042

4143
Documentation can be found [here](docs/introduction.md).

joft/cli.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
import sys
34

45
import click
@@ -8,6 +9,12 @@
89
import joft.utils
910

1011

12+
if os.getenv("JOFT_DEBUG"):
13+
logging_level = logging.DEBUG
14+
else:
15+
logging_level = logging.WARNING
16+
17+
1118
@click.group()
1219
@click.pass_context
1320
def main(ctx) -> None:
@@ -26,7 +33,7 @@ def validate(template) -> int:
2633
@click.option("--template", help="File path to the template file.")
2734
@click.pass_obj
2835
def run(ctx, template: str) -> int:
29-
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.DEBUG)
36+
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging_level)
3037
logging.info(
3138
f"Establishing session with jira server: {ctx['jira']['server']['hostname']}:"
3239
)
@@ -47,7 +54,7 @@ def run(ctx, template: str) -> int:
4754
@click.option("--template", help="File path to the template file.")
4855
@click.pass_obj
4956
def list_issues(ctx, template: str) -> None:
50-
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.DEBUG)
57+
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging_level)
5158
logging.info(
5259
f"Establishing session with jira server: {ctx['jira']['server']['hostname']}:"
5360
)

0 commit comments

Comments
 (0)