diff --git a/openrelik_worker_common/logging.py b/openrelik_worker_common/logging.py index 8a0ed81..15c6efa 100644 --- a/openrelik_worker_common/logging.py +++ b/openrelik_worker_common/logging.py @@ -1,12 +1,30 @@ +# WARNNING: This Logger class is deprecated, please use the Logger class in +# https://github.com/openrelik/openrelik-common/ import logging import structlog import os +import warnings OPENRELIK_LOG_TYPE = "OPENRELIK_LOG_TYPE" +DEPRECATED = """WARNING: This Logger class is deprecated and will be removed, please use the Logger class in +https://github.com/openrelik/openrelik-common/""" + +warnings.warn( + DEPRECATED, + DeprecationWarning, + stacklevel=2, +) + class Logger: def __init__(self): + warnings.warn( + DEPRECATED, + DeprecationWarning, + stacklevel=2, + ) + if os.environ.get(OPENRELIK_LOG_TYPE, "").startswith("structlog"): base_processors = [ # Merge bind context variables @@ -65,6 +83,12 @@ def get_logger(self, name="", wrap_logger=None, **kwargs): """ Returns a wrapper, structlog or plain python logger and binds key-value kwargs. """ + warnings.warn( + DEPRECATED, + DeprecationWarning, + stacklevel=2, + ) + if wrap_logger: # This can be used to wrap e.g. the Celery logger in a structlog self.logger = structlog.wrap_logger(wrap_logger) @@ -81,5 +105,10 @@ def get_logger(self, name="", wrap_logger=None, **kwargs): return self.logger def bind(self, **kwargs): + warnings.warn( + DEPRECATED, + DeprecationWarning, + stacklevel=2, + ) if os.environ.get(OPENRELIK_LOG_TYPE, "").startswith("structlog"): structlog.contextvars.bind_contextvars(**kwargs)