summaryrefslogtreecommitdiff
path: root/oslo_log/log.py
diff options
context:
space:
mode:
Diffstat (limited to 'oslo_log/log.py')
-rw-r--r--oslo_log/log.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/oslo_log/log.py b/oslo_log/log.py
index 365034a..74c9691 100644
--- a/oslo_log/log.py
+++ b/oslo_log/log.py
@@ -265,8 +265,25 @@ def register_options(conf):
conf.register_mutate_hook(_mutate_hook)
+def _fix_eventlet_logging():
+ """Properly setup logging with eventlet on native threads.
+
+ Workaround for: https://github.com/eventlet/eventlet/issues/432
+ """
+
+ # If eventlet was not loaded before call to setup assume it's not used.
+ eventlet = sys.modules.get('eventlet')
+ if eventlet:
+ import eventlet.green.threading
+ from oslo_log import pipe_mutex
+ logging.threading = eventlet.green.threading
+ logging._lock = logging.threading.RLock()
+ logging.Handler.createLock = pipe_mutex.pipe_createLock
+
+
def setup(conf, product_name, version='unknown'):
"""Setup logging for the current application."""
+ _fix_eventlet_logging()
if conf.log_config_append:
_load_log_config(conf.log_config_append)
else: