From e8fa41119eed9f56d1c2d03fa09ef915d148120b Mon Sep 17 00:00:00 2001 From: Ilya Sytchev Date: Sun, 3 Dec 2023 16:24:18 -0500 Subject: [PATCH] Avoid using the root logger (#229) --- docs/source/logging.md | 7 ------- forest/bonsai/simulate_gps_data.py | 4 ++-- forest/jasmine/data2mobmat.py | 4 ++-- forest/jasmine/mobmat2traj.py | 4 ++-- forest/jasmine/sogp_gps.py | 4 ++-- forest/jasmine/traj2stats.py | 4 ++-- forest/willow/log_stats.py | 4 ++-- 7 files changed, 12 insertions(+), 19 deletions(-) diff --git a/docs/source/logging.md b/docs/source/logging.md index 581f345b..a47d9e87 100644 --- a/docs/source/logging.md +++ b/docs/source/logging.md @@ -37,13 +37,6 @@ import logging logger = logging.getLogger(__name__) ``` -Or like this: - -``` -from logging import getLogger -logger = getLogger(__name__) -``` - ## 3. How to insert log messages into definitions Basic `logging` messages: diff --git a/forest/bonsai/simulate_gps_data.py b/forest/bonsai/simulate_gps_data.py index 1f0c6249..2e3b77a3 100644 --- a/forest/bonsai/simulate_gps_data.py +++ b/forest/bonsai/simulate_gps_data.py @@ -27,8 +27,8 @@ TRAVELLING_STATUS_LIST = range(11) -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) class PossibleExits(Enum): diff --git a/forest/jasmine/data2mobmat.py b/forest/jasmine/data2mobmat.py index 2d8a78a5..da282397 100644 --- a/forest/jasmine/data2mobmat.py +++ b/forest/jasmine/data2mobmat.py @@ -15,8 +15,8 @@ TOLERANCE = 1e-6 -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) def cartesian( diff --git a/forest/jasmine/mobmat2traj.py b/forest/jasmine/mobmat2traj.py index 1527a982..e4579ed8 100644 --- a/forest/jasmine/mobmat2traj.py +++ b/forest/jasmine/mobmat2traj.py @@ -13,8 +13,8 @@ from .data2mobmat import great_circle_dist, exist_knot -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) # the details of the functions are in paper [Liu and Onnela (2020)] diff --git a/forest/jasmine/sogp_gps.py b/forest/jasmine/sogp_gps.py index 86931e72..e5532e95 100644 --- a/forest/jasmine/sogp_gps.py +++ b/forest/jasmine/sogp_gps.py @@ -14,8 +14,8 @@ import numpy as np -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) def calculate_k0(x1: np.ndarray, x2: np.ndarray, pars: list) -> float: diff --git a/forest/jasmine/traj2stats.py b/forest/jasmine/traj2stats.py index da6ca15c..ca13b384 100644 --- a/forest/jasmine/traj2stats.py +++ b/forest/jasmine/traj2stats.py @@ -32,8 +32,8 @@ from forest.utils import get_ids -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) @dataclass diff --git a/forest/willow/log_stats.py b/forest/willow/log_stats.py index 6bf12ae5..3eee8a25 100644 --- a/forest/willow/log_stats.py +++ b/forest/willow/log_stats.py @@ -17,8 +17,8 @@ ) -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) def text_analysis(