Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Fallback to file logging if system loggers not available #92

@vholer

Description

@vholer

If may happen the logging via systemd-cat or even logger is not available. The contextualization should fallback to the log on its own with a syslog line format. Also, the logging function should have neutral return code no matter if the function succeeds or fails.

logger -t "${SYSLOG_TAG}" \
-p "${SYSLOG_FACILITY}.${1}" \
"${2}" 2>/dev/null
elif [ "${1}" != 'debug' ]; then
local _txt="$(date "+%b %d %T") $(hostname -s) ${SYSLOG_TAG}: ${2}"
local _log=/var/log/messages
if [ -f /var/log/syslog ]; then
_log=/var/log/syslog
fi
echo "${_txt}" >>"${_log}" 2>/dev/null

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions