Skip to content

Commit

Permalink
Rewire podman logfile to ours
Browse files Browse the repository at this point in the history
  • Loading branch information
efrecon committed Mar 7, 2024
1 parent 04f289a commit 3bc2121
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,18 @@ verbose() { if [ "${KRUNVM_RUNNER_VERBOSE:-0}" -ge "1" ]; then _log NFO "$@"; fi
info() { if [ "${KRUNVM_RUNNER_VERBOSE:-0}" -ge "1" ]; then _log NFO "$@"; fi; }
warn() { _log WRN "$@"; }
error() { _log ERR "$@" && exit 1; }

sublog() {
# Eagerly wait for the log file to exist
while ! [ -f "${1-0}" ]; do sleep 0.1; done
verbose "$1 now present on disk"

# Then reroute its content through our logging printf style
tail -n +0 -f "$1" | while IFS= read -r line; do
printf '[%s] [%s] %s\n' \
"${2-"${KRUNVM_RUNNER_BIN:-$(basename "$0")}"}" \
"$(date +'%Y%m%d-%H%M%S')" \
"$line" \
>&"$KRUNVM_RUNNER_LOG"
done
}
2 changes: 2 additions & 0 deletions runner/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ docker_daemon() {
# to be able to access the socket.
chgrp "docker" /var/run/docker.sock
chmod g+rw /var/run/docker.sock
# Forwards podman's log file (must be same as in containers.conf)
sublog /var/log/podman.log podman &
elif [ -n "$dockerd" ]; then
# For docker, the user must be in the docker group to access the daemon.
verbose "Starting $dockerd as a daemon"
Expand Down

0 comments on commit 3bc2121

Please sign in to comment.