Skip to content
Snippets Groups Projects
Commit 0e6df4c0 authored by Ludovico de Nittis's avatar Ludovico de Nittis
Browse files

Merge branch 'wip/more-logs' into 'master'

Improve logging

See merge request steamlinuxruntime!27
parents 838f1b2b d8dfd80a
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ me="${me##*/}" ...@@ -10,6 +10,7 @@ me="${me##*/}"
deploy= deploy=
force= force=
info=
rendezvous= rendezvous=
suite=scout suite=scout
use_timestamp= use_timestamp=
...@@ -23,24 +24,31 @@ fi ...@@ -23,24 +24,31 @@ fi
if [ "${STEAM_LINUX_RUNTIME_LOG-}" = 1 ]; then if [ "${STEAM_LINUX_RUNTIME_LOG-}" = 1 ]; then
# If we are logging to a file, use the timestamp # If we are logging to a file, use the timestamp
info=yes
use_timestamp=yes use_timestamp=yes
fi fi
log () { log () {
if [ -n "$use_timestamp" ]; then if [ -n "$use_timestamp" ]; then
printf '%s\n' "$(date +'%H:%M:%S.%6N'): ${me}[$$]: $*" >&2 printf '%s\n' "$(LD_PRELOAD= date +'%H:%M:%S.%6N'): ${me}[$$]: $*" >&2
else else
printf '%s\n' "${me}[$$]: $*" >&2 printf '%s\n' "${me}[$$]: $*" >&2
fi fi
} }
info () {
if [ -n "${info}${verbose}" ]; then
log "$@"
fi
}
verbose () { verbose () {
if [ -n "$verbose" ]; then if [ -n "$verbose" ]; then
log "$@" log "$@"
fi fi
} }
verbose "argv: $(printf '%q ' "$@")" info "argv: $(printf '%q ' "$@")"
usage () { usage () {
local code="$1" local code="$1"
...@@ -147,7 +155,7 @@ if [ -z "$rendezvous" ]; then ...@@ -147,7 +155,7 @@ if [ -z "$rendezvous" ]; then
fi fi
if [ -S "$rendezvous/socket" ]; then if [ -S "$rendezvous/socket" ]; then
verbose "Session already started in $rendezvous" info "Session already started in $rendezvous"
exit 0 exit 0
fi fi
...@@ -160,7 +168,7 @@ fi ...@@ -160,7 +168,7 @@ fi
rm -f "$rendezvous/fifo" rm -f "$rendezvous/fifo"
mkfifo "$rendezvous/fifo" mkfifo "$rendezvous/fifo"
verbose "Starting pressure-vessel-launcher in background" info "Starting pressure-vessel-launcher in background"
"${run_in_steamrt}" \ "${run_in_steamrt}" \
--arch=amd64,i386 \ --arch=amd64,i386 \
--deploy \ --deploy \
...@@ -178,7 +186,7 @@ verbose "Starting pressure-vessel-launcher in background" ...@@ -178,7 +186,7 @@ verbose "Starting pressure-vessel-launcher in background"
--socket-directory="$rendezvous" \ --socket-directory="$rendezvous" \
< /dev/null >&2 3>"$rendezvous/fifo" & < /dev/null >&2 3>"$rendezvous/fifo" &
container_pid="$!" container_pid="$!"
verbose "Started pressure-vessel-launcher in background, pid $container_pid" info "Started pressure-vessel-launcher in background, pid $container_pid"
socket=$( socket=$(
while read -r line; do while read -r line; do
case "$line" in case "$line" in
......
...@@ -34,13 +34,19 @@ fi ...@@ -34,13 +34,19 @@ fi
log () { log () {
if [ -n "$use_timestamp" ]; then if [ -n "$use_timestamp" ]; then
timestamp=$(date +'%H:%M:%S.%6N') timestamp=$(LD_PRELOAD= date +'%H:%M:%S.%6N')
printf '%s\n' "${timestamp}: ${me}[$$]: $*" >&2 printf '%s\n' "${timestamp}: ${me}[$$]: $*" >&2
else else
printf '%s\n' "${me}[$$]: $*" >&2 printf '%s\n' "${me}[$$]: $*" >&2
fi fi
} }
info () {
if [ -n "${log_to_file}${verbose}" ]; then
log "$@"
fi
}
verbose () { verbose () {
if [ -n "$verbose" ]; then if [ -n "$verbose" ]; then
log "$@" log "$@"
...@@ -192,7 +198,7 @@ if [ -n "$log_to_file" ]; then ...@@ -192,7 +198,7 @@ if [ -n "$log_to_file" ]; then
export PRESSURE_VESSEL_LOG_WITH_TIMESTAMP=1 export PRESSURE_VESSEL_LOG_WITH_TIMESTAMP=1
fi fi
verbose "argv: $(printf '%q ' "$@")" info "argv: $(printf '%q ' "$@")"
if [ "$#" -eq 0 ] || [ "x$1" = x-- ]; then if [ "$#" -eq 0 ] || [ "x$1" = x-- ]; then
log "Error: A command to run is required" log "Error: A command to run is required"
...@@ -200,24 +206,22 @@ if [ "$#" -eq 0 ] || [ "x$1" = x-- ]; then ...@@ -200,24 +206,22 @@ if [ "$#" -eq 0 ] || [ "x$1" = x-- ]; then
fi fi
# Steam App ID of this app or game # Steam App ID of this app or game
log "STEAM_COMPAT_APP_ID=${STEAM_COMPAT_APP_ID-}" verbose "STEAM_COMPAT_APP_ID=${STEAM_COMPAT_APP_ID-}"
# Session ID used for coordination between processes involving the same game. # Session ID used for coordination between processes involving the same game.
# If unset/empty, only execute a single command. # If unset/empty, only execute a single command.
log "STEAM_COMPAT_SESSION_ID=${STEAM_COMPAT_SESSION_ID-}" verbose "STEAM_COMPAT_SESSION_ID=${STEAM_COMPAT_SESSION_ID-}"
# Used to create sockets. # Used to create sockets.
# A future version will fall back to /tmp, but only when this can be verbose "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}"
# done securely.
log "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR-}"
relaunch= relaunch=
if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
verbose "Non-session mode, behaving like the main program" info "Non-session mode, behaving like the main program"
is_main=yes is_main=yes
elif [ -n "$is_main" ]; then elif [ -n "$is_main" ]; then
verbose "Main program in session mode" info "Main program in session mode"
case "${PRESSURE_VESSEL_RELAUNCH_CONTAINER-0}" in case "${PRESSURE_VESSEL_RELAUNCH_CONTAINER-0}" in
(1) (1)
relaunch=yes relaunch=yes
...@@ -349,7 +353,7 @@ terminate_container () { ...@@ -349,7 +353,7 @@ terminate_container () {
} }
if [ -n "$relaunch" ]; then if [ -n "$relaunch" ]; then
verbose "Terminating and re-launching container for main game" info "Terminating and re-launching container for main game"
terminate_container || : terminate_container || :
exec_container "$@" exec_container "$@"
# not reached # not reached
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment