made syslog import optional as intel's edison custom compiles python w/o it

pull/12747/head
Brian Coca 9 years ago
parent 2963bba901
commit c57200925f

@ -54,7 +54,6 @@ import pipes
import shlex import shlex
import subprocess import subprocess
import sys import sys
import syslog
import types import types
import time import time
import select import select
@ -68,6 +67,12 @@ import platform
import errno import errno
from itertools import repeat from itertools import repeat
try:
import syslog
HAS_SYSLOG=True
except ImportError:
HAS_SYSLOG=False
try: try:
# Python 2 # Python 2
from itertools import imap from itertools import imap
@ -1246,9 +1251,10 @@ class AnsibleModule(object):
return params return params
def _log_to_syslog(self, msg): def _log_to_syslog(self, msg):
module = 'ansible-%s' % os.path.basename(__file__) if HAS_SYSLOG:
syslog.openlog(str(module), 0, syslog.LOG_USER) module = 'ansible-%s' % os.path.basename(__file__)
syslog.syslog(syslog.LOG_INFO, msg) syslog.openlog(str(module), 0, syslog.LOG_USER)
syslog.syslog(syslog.LOG_INFO, msg)
def debug(self, msg): def debug(self, msg):
if self._debug: if self._debug:

Loading…
Cancel
Save