Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved log level from environment variable to CLI flag #299

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions torbot/modules/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import logging
import argparse

from dotenv import load_dotenv
from inspect import getsourcefile
Expand All @@ -18,13 +19,16 @@


def get_log_level() -> int:
log_level_str = os.getenv('LOG_LEVEL')
if log_level_str:
log_level_str = log_level_str.lower()
mapping = logging.getLevelNamesMapping()
if log_level_str in mapping:
return mapping[log_level_str]
return logging.INFO
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action='count', default=0, help='Increase verbosity level (-v for INFO, -vv for DEBUG)')
args = parser.parse_args()

if args.verbose >= 2:
return logging.DEBUG
elif args.verbose == 1:
return logging.INFO
else:
return logging.WARNING


def get_data_directory():
Expand Down