mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
Add syslog_facility parameter handling with systemd.journal (#41078)
* Add syslog_facility parameter handling with systemd.journal - Fixed issue #41072 Signed-off-by: Hideki Saito <saito@fgrep.org>
This commit is contained in:
parent
89cea78e30
commit
d7df072b96
3 changed files with 26 additions and 1 deletions
|
@ -2185,7 +2185,19 @@ class AnsibleModule(object):
|
|||
for arg in log_args:
|
||||
journal_args.append((arg.upper(), str(log_args[arg])))
|
||||
try:
|
||||
journal.send(u"%s %s" % (module, journal_msg), **dict(journal_args))
|
||||
if HAS_SYSLOG:
|
||||
# If syslog_facility specified, it needs to convert
|
||||
# from the facility name to the facility code, and
|
||||
# set it as SYSLOG_FACILITY argument of journal.send()
|
||||
facility = getattr(syslog,
|
||||
self._syslog_facility,
|
||||
syslog.LOG_USER) >> 3
|
||||
journal.send(MESSAGE=u"%s %s" % (module, journal_msg),
|
||||
SYSLOG_FACILITY=facility,
|
||||
**dict(journal_args))
|
||||
else:
|
||||
journal.send(MESSAGE=u"%s %s" % (module, journal_msg),
|
||||
**dict(journal_args))
|
||||
except IOError:
|
||||
# fall back to syslog since logging to journal failed
|
||||
self._log_to_syslog(syslog_msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue