Skip to content

Commit

Permalink
Use warnings module for deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
coroa committed Oct 20, 2020
1 parent c08da61 commit da2b669
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyam/logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from contextlib import contextmanager
import logging
import warnings

logger = logging.getLogger(__name__)

Expand All @@ -15,4 +16,8 @@ def adjust_log_level(logger, level='ERROR'):
def deprecation_warning(msg, type='This method'):
"""Write deprecation warning to log"""
warn = 'is deprecated and will be removed in future versions.'
logger.warning('{} {} {}'.format(type, warn, msg))
warnings.warn(
'{} {} {}'.format(type, warn, msg),
DeprecationWarning,
stacklevel=2
)

0 comments on commit da2b669

Please sign in to comment.