Remove timestamp from logs in notebooks
This commit is contained in:
parent
8d1ad9a242
commit
68c7da38b8
2 changed files with 159 additions and 33 deletions
|
|
@ -9,13 +9,22 @@ loggers: Dict[str, logging.Logger] = {}
|
|||
def get_logger(
|
||||
name: str, level: int = logging.INFO, disable_colors: bool = False
|
||||
) -> logging.Logger:
|
||||
"""Return a customised logger used throughout the GreatAI codebase."""
|
||||
"""Return a customised logger used throughout the GreatAI codebase.
|
||||
|
||||
Uses colors, and only prints timestamps when not running inside notebook.
|
||||
"""
|
||||
|
||||
if name not in loggers:
|
||||
logger = logging.getLogger(name)
|
||||
logger.setLevel(level)
|
||||
|
||||
log_format = "%(asctime)s | %(levelname)8s | %(message)s"
|
||||
try:
|
||||
get_ipython() # type: ignore
|
||||
log_format = "%(message)s"
|
||||
except NameError:
|
||||
# will fail outside of a notebook https://ipython.org/
|
||||
log_format = "%(asctime)s | %(levelname)8s | %(message)s"
|
||||
|
||||
stdout_handler = logging.StreamHandler()
|
||||
stdout_handler.setLevel(level)
|
||||
if not disable_colors:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue