diff --git a/src/debugpy/common/log.py b/src/debugpy/common/log.py index 0bb70f5a..4c243c0a 100644 --- a/src/debugpy/common/log.py +++ b/src/debugpy/common/log.py @@ -12,13 +12,23 @@ import platform import sys import threading import traceback -from typing import Callable, Dict, FrozenSet, Iterable, Literal, Sequence, TextIO, Tuple, Union, cast +from typing import ( + Callable, + Dict, + FrozenSet, + Iterable, + Sequence, + TextIO, + Tuple, + Union, + cast, +) +from typing_extensions import Literal import debugpy from debugpy.common import json, timestamp, util -LevelTypes = Literal['debug', 'info', 'warning', 'error'] - +LevelTypes = Literal["debug", "info", "warning", "error"] LEVELS = ("debug", "info", "warning", "error") """Logging levels, lowest to highest importance. """ @@ -44,7 +54,13 @@ def _update_levels(): class LogFile(object): - def __init__(self, filename: str, file: TextIO, levels: Sequence[LevelTypes]=LEVELS, close_file=True): + def __init__( + self, + filename: str, + file: TextIO, + levels: Sequence[LevelTypes] = LEVELS, + close_file=True, + ): info("Also logging to {0}.", json.repr(filename)) self.filename = filename self.file = file @@ -375,7 +391,9 @@ def describe_environment(header): stderr = LogFile( "", sys.stderr, - levels=cast(Sequence[LevelTypes], os.getenv("DEBUGPY_LOG_STDERR", "warning error").split()), + levels=cast( + Sequence[LevelTypes], os.getenv("DEBUGPY_LOG_STDERR", "warning error").split() + ), close_file=False, )