Skip to content

Commit b03f463

Browse files
committed
Change logging buffer to stderr. Same default as python builtin logging library.
- Changing order of astromodels import in init. It was using astromodels' setup_logger, not threeml's setup_logger - This revealed a circular import. I patched it with a local import and added a FIXME not about it.
1 parent 8fbb6df commit b03f463

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

threeML/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
from pathlib import Path
2323

24-
from threeML.io.logging import setup_logger
25-
2624
# Import everything from astromodels
2725
from astromodels import *
2826

27+
from .io.logging import setup_logger
28+
2929
from .config import (
3030
threeML_config,
3131
show_configuration,

threeML/config/config_utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
from omegaconf import OmegaConf
66
from omegaconf.dictconfig import DictConfig
77
from rich.tree import Tree
8-
from threeML.io.logging import setup_logger
98
from threeML.io.package_data import get_path_of_user_config
109

1110
from .config import threeML_config
1211

13-
log = setup_logger(__name__)
14-
12+
# FIXME: These lines were moved to local imports withing functions since
13+
# they were causing a circular import. The config module needs the logging setup,
14+
# and the logging setup needs the config module.
15+
#from threeML.io.logging import setup_logger
16+
#log = setup_logger(__name__)
1517

1618
def recurse_dict(d, tree):
1719

@@ -64,6 +66,8 @@ def show_configuration(sub_menu: Optional[str] = None):
6466

6567
msg = f"{sub_menu} is not in the threeml configuration"
6668

69+
from threeML.io.logging import setup_logger
70+
log = setup_logger(__name__)
6771
log.error(msg)
6872

6973
raise AssertionError(msg)
@@ -111,6 +115,10 @@ def get_value(name, user_value, par_type, config_value):
111115
:param config_value: value in config
112116
:returns: parameter value
113117
"""
118+
119+
from threeML.io.logging import setup_logger
120+
log = setup_logger(__name__)
121+
114122
if user_value is not None:
115123
value = user_value
116124
else:

threeML/io/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_path_of_log_file(log_file: str) -> Path:
118118
# mytheme = Theme().read(_get_data_file_path("log_theme.ini"))
119119
mytheme = Theme(_theme)
120120

121-
console = Console(theme=mytheme)
121+
console = Console(theme=mytheme, stderr=True)
122122

123123

124124
threeML_console_log_handler = RichHandler(

0 commit comments

Comments
 (0)