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

[DO Not Merge] Avoid using 'default' keyword while invoking 'get' method #473

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 4 additions & 4 deletions smdebug/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def filter(self, record):

def _get_log_level():
default = "info"
log_level = os.environ.get("SMDEBUG_LOG_LEVEL", default=default)
log_level = os.environ.get("SMDEBUG_LOG_LEVEL", default)
log_level = log_level.lower()
allowed_levels = ["info", "debug", "warning", "error", "critical", "off"]
if log_level not in allowed_levels:
Expand All @@ -64,7 +64,7 @@ def get_logger(name="smdebug"):
global _logger_initialized
if not _logger_initialized:
worker_pid = f"{socket.gethostname()}:{os.getpid()}"
log_context = os.environ.get("SMDEBUG_LOG_CONTEXT", default=worker_pid)
log_context = os.environ.get("SMDEBUG_LOG_CONTEXT", worker_pid)
level = _get_log_level()
logger = logging.getLogger(name)

Expand All @@ -79,7 +79,7 @@ def get_logger(name="smdebug"):
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(log_formatter)

if os.environ.get("SMDEBUG_LOG_ALL_TO_STDOUT", default="TRUE").lower() == "false":
if os.environ.get("SMDEBUG_LOG_ALL_TO_STDOUT", "TRUE").lower() == "false":
stderr_handler = logging.StreamHandler(sys.stderr)
min_level = logging.DEBUG
# lets through all levels less than ERROR
Expand All @@ -96,7 +96,7 @@ def get_logger(name="smdebug"):
# SMDEBUG_LOG_PATH is the full path to log file
# by default, log is only written to stdout&stderr
# if this is set, it is written to file
path = os.environ.get("SMDEBUG_LOG_PATH", default=None)
path = os.environ.get("SMDEBUG_LOG_PATH", None)
if path is not None:
fh = logging.FileHandler(path)
fh.setFormatter(log_formatter)
Expand Down