Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Multiplexing into syslog #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions mesos-init-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,18 @@ function master {

# Send all output to syslog and tag with PID and executable basename.
function logged {
local pattern="[0-9]\{4\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}.[0-9]* "
local tag="${1##*/}[$$]"
exec 1> >(exec logger -p user.info -t "$tag")
exec 2> >(exec logger -p user.err -t "$tag")
exec 1> >(
tee \
>(sed -n "/^I$pattern/ s/// p" | logger -p user.info -t "$tag" ) \
>(sed -n "/^W$pattern/ s/// p" | logger -p user.warn -t "$tag" ) \
>(sed -n "/^E$pattern/ s/// p" | logger -p user.err -t "$tag" ) \
>(sed -n "/^F$pattern/ s/// p" | logger -p user.crit -t "$tag" ) \
>(grep -v "^[IWEF]$pattern" | logger -p user.crit -t "$tag" ) \
> /dev/null
)
exec 2>&1
exec "$@"
}

Expand Down