summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucian Petrut <lpetrut@cloudbasesolutions.com>2017-04-12 19:27:38 +0300
committerLucian Petrut <lpetrut@cloudbasesolutions.com>2017-04-12 19:31:05 +0300
commit5d5ace2c48e372ed07fd946e58ee2fde05ee8fce (patch)
tree3659fbebef41cf762c2ce6a9afa0edb7676353ab
parent3719d834c8ba35417e0a6f971411c3c482759d82 (diff)
downloadoslo-log-5d5ace2c48e372ed07fd946e58ee2fde05ee8fce.tar.gz
Fix syslog module usage breaking Windows compatibility
The following change removed the platform check that was preventing the syslog handler class from being defined on incompatible platforms: d61af05ff10e92e73ec8745be5f1828e6b2effda The only issue with that is the fact that one method default value uses a syslog module constant that gets evaluated even if the class itself is never instantiated. This patch fixes the issue by moving that default value within the init method. Closes-Bug: #1682177 Change-Id: Ie88e367957c5739f335cb96fcefc8501a9bf4bcd
-rw-r--r--oslo_log/handlers.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/oslo_log/handlers.py b/oslo_log/handlers.py
index 852d4bf..8e561a4 100644
--- a/oslo_log/handlers.py
+++ b/oslo_log/handlers.py
@@ -56,7 +56,10 @@ SYSLOG_MAP = {
class OSSysLogHandler(logging.Handler):
"""Syslog based handler. Only available on UNIX-like platforms."""
- def __init__(self, facility=syslog.LOG_USER):
+ def __init__(self, facility=None):
+ # Default values always get evaluated, for which reason we avoid
+ # using 'syslog' directly, which may not be available.
+ facility = facility if facility is not None else syslog.LOG_USER
# Do not use super() unless type(logging.Handler) is 'type'
# (i.e. >= Python 2.7).
if not syslog: