-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
accepting pull requestContribute by raising a pull request to resolve this issue!Contribute by raising a pull request to resolve this issue!bugSomething isn't workingSomething isn't working
Description
Setting the following configuration for logging in climada configuration
"logging": {
"managed": false
}
Raises the following error when importing anything from petals due to CONSOLE not being defined:
ImportError Traceback (most recent call last)
22 from pathlib import Path
24 import climada
---> 25 import climada_petals.util.config
26 from .util.constants import *
28 REPO_DATA = {
29 'climada_petals[/data/gdp_asset](http://localhost:8888/data/gdp_asset)': [
30 SYSTEM_DIR.joinpath('GDP2Asset_converter_2.5arcmin.nc'),
(...) 57 ],
58 }
1 """
2 This file is part of CLIMADA.
3
(...) 19 init util
20 """
---> 21 from .config import *
22 from .constants import *
30 import climada
31 import climada.util.config
---> 32 from climada.util.config import (
33 Config, _fetch_conf, CONFIG_NAME, CONFIG, CONSOLE)
35 LOGGER = logging.getLogger('climada_petals')
36 LOGGER.propagate = False
ImportError: cannot import name 'CONSOLE' from 'climada.util.config'
This comes from the fact that config.py in climada core only defines CONSOLE if CONFIG.logging.managed is True:
# set climada style logging
if CONFIG.logging.managed.bool():
LOGGER = logging.getLogger("climada")
LOGGER.propagate = False
FORMATTER = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
CONSOLE = logging.StreamHandler(stream=sys.stdout)
CONSOLE.setFormatter(FORMATTER)
LOGGER.addHandler(CONSOLE)
LOGGER.setLevel(getattr(logging, CONFIG.log_level.str()))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
accepting pull requestContribute by raising a pull request to resolve this issue!Contribute by raising a pull request to resolve this issue!bugSomething isn't workingSomething isn't working