Skip to content

Commit

Permalink
Opt-out of darts logging based on environment variable (#1010)
Browse files Browse the repository at this point in the history
* automatic linting

* don't add custom handlers and formatter to loggers

Co-authored-by: Julien Herzen <julien@unit8.co>
  • Loading branch information
brunnedu and hrzn committed Jun 21, 2022
1 parent b530dcd commit 524a28b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions darts/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ def get_logger(name):
"""

logger = logging.getLogger(name)
# default logging level is logging.INFO
logger.setLevel(logging.INFO)
stderr_handler = logging.StreamHandler()
formatter = logging.Formatter(
"[%(asctime)s] %(levelname)s | %(name)s | %(message)s"
)
stderr_handler.setFormatter(formatter)
logger.addHandler(stderr_handler)

return logger


Expand Down
8 changes: 4 additions & 4 deletions darts/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
from darts.models.forecasting.auto_arima import AutoARIMA
from darts.models.forecasting.tbats import BATS, TBATS
except ModuleNotFoundError:
logger.warning(
logger.info(
"Support for AutoARIMA, BATS and TBATS is not available."
"To enable it, install u8darts[pmdarima] or u8darts[all]."
)

try:
from darts.models.forecasting.prophet_model import Prophet
except ModuleNotFoundError:
logger.warning(
logger.info(
"Support for Facebook Prophet is not available. "
'To enable it, install "darts", "u8darts[prophet]" or "u8darts[all]" (with pip);'
'or "u8darts-all" (with conda).'
Expand All @@ -50,7 +50,7 @@
from darts.models.forecasting.transformer_model import TransformerModel

except ModuleNotFoundError:
logger.warning(
logger.info(
"Support for Torch based models not available. "
'To enable them, install "darts", "u8darts[torch]" or "u8darts[all]" (with pip); '
'or "u8darts-torch" or "u8darts-all" (with conda).'
Expand All @@ -59,7 +59,7 @@
try:
from darts.models.forecasting.gradient_boosted_model import LightGBMModel
except ModuleNotFoundError:
logger.warning(
logger.info(
"Support for LightGBM not available."
"To enable LightGBM support in Darts, follow the detailed "
"install instructions for LightGBM in the README: "
Expand Down

0 comments on commit 524a28b

Please sign in to comment.