Commit d1d835a1 authored by Mik Vyatskov's avatar Mik Vyatskov Committed by Facebook GitHub Bot
Browse files

Configure the logging separately from the setup

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/510

This change allows to more granularly configure initial logging setup as part of a separate module.

Reviewed By: tglik

Differential Revision: D44278485

fbshipit-source-id: 2f421ee4e7f9017ef8ebccb9ff51f4177b8628b9
parent fe8680c1
...@@ -28,6 +28,7 @@ from d2go.distributed import ( ...@@ -28,6 +28,7 @@ from d2go.distributed import (
from d2go.runner import BaseRunner, DefaultTask, import_runner, RunnerV2Mixin from d2go.runner import BaseRunner, DefaultTask, import_runner, RunnerV2Mixin
from d2go.utils.helper import run_once from d2go.utils.helper import run_once
from d2go.utils.launch_environment import get_launch_environment from d2go.utils.launch_environment import get_launch_environment
from d2go.utils.logging import initialize_logging
from detectron2.utils.collect_env import collect_env_info from detectron2.utils.collect_env import collect_env_info
from detectron2.utils.file_io import PathManager from detectron2.utils.file_io import PathManager
from detectron2.utils.logger import setup_logger as _setup_logger from detectron2.utils.logger import setup_logger as _setup_logger
...@@ -48,8 +49,7 @@ def setup_root_logger(logging_level: int = logging.DEBUG) -> None: ...@@ -48,8 +49,7 @@ def setup_root_logger(logging_level: int = logging.DEBUG) -> None:
See https://docs.python.org/3/library/logging.html for a more in-depth See https://docs.python.org/3/library/logging.html for a more in-depth
description description
""" """
root_logger = logging.getLogger() initialize_logging(logging_level)
root_logger.setLevel(logging_level)
_replace_print_with_logging() _replace_print_with_logging()
...@@ -342,12 +342,10 @@ def setup_logger( ...@@ -342,12 +342,10 @@ def setup_logger(
color=color, color=color,
name=module_name, name=module_name,
abbrev_name=abbrev_name, abbrev_name=abbrev_name,
enable_propagation=True,
configure_stdout=False,
) )
# NOTE: the root logger might has been configured by other applications,
# since this already sub-top level, just don't propagate to root.
logger.propagate = False
return logger return logger
......
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from mobile_cv.common.misc.oss_utils import fb_overwritable
@fb_overwritable()
def initialize_logging(logging_level: int) -> None:
root_logger = logging.getLogger()
root_logger.setLevel(logging_level)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment