Skip to content

Commit

Permalink
made syslog import optional as intel's edison custom compiles python …
Browse files Browse the repository at this point in the history
…w/o it
  • Loading branch information
bcoca committed Oct 14, 2015
1 parent 2963bba commit c572009
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/ansible/module_utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import shlex
import subprocess
import sys
import syslog
import types
import time
import select
Expand All @@ -68,6 +67,12 @@
import errno
from itertools import repeat

try:
import syslog
HAS_SYSLOG=True
except ImportError:
HAS_SYSLOG=False

try:
# Python 2
from itertools import imap
Expand Down Expand Up @@ -1246,9 +1251,10 @@ def _load_params(self):
return params

def _log_to_syslog(self, msg):
module = 'ansible-%s' % os.path.basename(__file__)
syslog.openlog(str(module), 0, syslog.LOG_USER)
syslog.syslog(syslog.LOG_INFO, msg)
if HAS_SYSLOG:
module = 'ansible-%s' % os.path.basename(__file__)
syslog.openlog(str(module), 0, syslog.LOG_USER)
syslog.syslog(syslog.LOG_INFO, msg)

def debug(self, msg):
if self._debug:
Expand Down

0 comments on commit c572009

Please sign in to comment.