Skip to content

Commit 0fdb797

Browse files
committed
Enable debug logging only if JOFT_DEBUG env var is defined
1 parent 1705324 commit 0fdb797

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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)