diff --git a/bin/launch-client.md b/bin/launch-client.md index ee55cabf09c62ddbc4d7b2c2209eb1e2b431f05a..d6848ec7d3bf1fa56d39437e4f45539c713702d9 100644 --- a/bin/launch-client.md +++ b/bin/launch-client.md @@ -262,17 +262,19 @@ Some variables will be set programmatically by Some variables affect the behaviour of **steam-runtime-launch-client**: `PRESSURE_VESSEL_LOG_INFO` (boolean) -: If set to `1`, increase the log verbosity up to the info level. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=info` `PRESSURE_VESSEL_LOG_WITH_TIMESTAMP` (boolean) -: If set to `1`, prepend the log entries with a timestamp. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=timestamp` `SHELL` : If set to a non-empty value, it is used as the default shell when no *COMMAND* is provided. +`SRT_LOG` +: A sequence of tokens separated by colons, spaces or commas + affecting how output is recorded. See source code for details. + `TERM` : If standard input, standard output or standard error is a terminal, then this environment variable is passed to the *COMMAND* by default. diff --git a/bin/launcher-interface-0.md b/bin/launcher-interface-0.md index 5ac5087e49bd1cce8fac15bf8085e36708724c89..9f79350db00fb4db486d50d08bab26527443d2d7 100644 --- a/bin/launcher-interface-0.md +++ b/bin/launcher-interface-0.md @@ -91,6 +91,10 @@ version of the Steam Runtime, the tool should be renamed to Even if its D-Bus well-known name is taken over by another process, it can still be contacted via its D-Bus unique name. +`SRT_LOG` +: A sequence of tokens separated by colons, spaces or commas + affecting how output is recorded. See source code for details. + # OUTPUT Unstructured diagnostic messages are printed on standard error. diff --git a/bin/launcher-service.md b/bin/launcher-service.md index e208575cf665d69d982335743088daeeb47ee8d6..d1b723673c0ecf3442a72429dca1beff85cbc3f4 100644 --- a/bin/launcher-service.md +++ b/bin/launcher-service.md @@ -179,12 +179,10 @@ manipulate environment variables on a per-command basis. ## Variables read by steam-runtime-launcher-service `PRESSURE_VESSEL_LOG_INFO` (boolean) -: If set to `1`, increase the log verbosity up to the info level. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=info` `PRESSURE_VESSEL_LOG_WITH_TIMESTAMP` (boolean) -: If set to `1`, prepend the log entries with a timestamp. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=timestamp` `SRT_LAUNCHER_SERVICE_STOP_ON_EXIT` (boolean) : If set to `0`, the default behaviour changes to be equivalent to @@ -196,6 +194,10 @@ manipulate environment variables on a per-command basis. **--no-stop-on-name-loss**, unless overridden by **--stop-on-name-loss**. If set to `1`, no effect. +`SRT_LOG` +: A sequence of tokens separated by colons, spaces or commas + affecting how output is recorded. See source code for details. + `STEAM_COMPAT_APP_ID` (integer) : Used by **--session** to identify the Steam app ID (game ID). diff --git a/pressure-vessel/adverb.1.md b/pressure-vessel/adverb.1.md index f8f06c757c5405247ef051e6e22d28a63294bfbe..0295fba060347e4bd68ea30853757e5e26747d40 100644 --- a/pressure-vessel/adverb.1.md +++ b/pressure-vessel/adverb.1.md @@ -222,12 +222,14 @@ exit status. # ENVIRONMENT `PRESSURE_VESSEL_LOG_INFO` (boolean) -: If set to `1`, increase the log verbosity up to the info level. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=info` `PRESSURE_VESSEL_LOG_WITH_TIMESTAMP` (boolean) -: If set to `1`, prepend the log entries with a timestamp. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=timestamp` + +`SRT_LOG` +: A sequence of tokens separated by colons, spaces or commas + affecting how output is recorded. See source code for details. # OUTPUT diff --git a/pressure-vessel/wrap.1.md b/pressure-vessel/wrap.1.md index 3b9a6e29e44170a4ac1db55b09badb7f700dba78..a684b80eaf909837df7e31848c55862d3c9ff73a 100644 --- a/pressure-vessel/wrap.1.md +++ b/pressure-vessel/wrap.1.md @@ -380,12 +380,10 @@ The following environment variables (among others) are read by If set to `0`, equivalent to `--no-import-vulkan-layers`. `PRESSURE_VESSEL_LOG_INFO` (boolean) -: If set to `1`, increase the log verbosity up to the info level. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=info` `PRESSURE_VESSEL_LOG_WITH_TIMESTAMP` (boolean) -: If set to `1`, prepend the log entries with a timestamp. - If set to `0`, no effect. +: If set to 1, same as `SRT_LOG=timestamp` `PRESSURE_VESSEL_REMOVE_GAME_OVERLAY` (boolean) : If set to `1`, equivalent to `--remove-game-overlay`. @@ -437,6 +435,10 @@ The following environment variables (among others) are read by : Used to choose between logically equivalent names for the current working directory (see **get_current_dir_name**(3)). +`SRT_LOG` +: A sequence of tokens separated by colons, spaces or commas + affecting how output is recorded. See source code for details. + `STEAM_COMPAT_APP_ID` (integer) : Equivalent to `--steam-app-id="$STEAM_COMPAT_APP_ID"`. diff --git a/steam-runtime-tools/log.c b/steam-runtime-tools/log.c index 5d529a3e0089ab26cb1dc41397f9438cc89a713a..ecfd45c056f1b574a5c510f4f0546026cbcc63cb 100644 --- a/steam-runtime-tools/log.c +++ b/steam-runtime-tools/log.c @@ -326,6 +326,13 @@ log_handler (const gchar *log_domain, * Flags affecting logging. */ +static const GDebugKey log_enable[] = +{ + { "debug", SRT_LOG_FLAGS_DEBUG }, + { "info", SRT_LOG_FLAGS_INFO }, + { "timestamp", SRT_LOG_FLAGS_TIMESTAMP }, +}; + /* * _srt_util_set_glib_log_handler: * @extra_log_domain: (nullable): A log domain, usually %G_LOG_DOMAIN @@ -341,6 +348,11 @@ log_handler (const gchar *log_domain, * The chosen message format is used for @extra_log_domain, and also * for the `steam-runtime-tools` log domain used by the * steam-runtime-tools library. + * + * Logging can be configured by the `SRT_LOG` environment variable, + * which is a sequence of tokens separated by colons, spaces or commas + * matching the nicknames of #SrtLogFlags members. See + * g_parse_debug_string(). */ void _srt_util_set_glib_log_handler (const char *extra_log_domain, @@ -351,6 +363,9 @@ _srt_util_set_glib_log_handler (const char *extra_log_domain, | SRT_LOG_LEVEL_FAILURE | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE); + const char *log_env = g_getenv ("SRT_LOG"); + + flags |= g_parse_debug_string (log_env, log_enable, G_N_ELEMENTS (log_enable)); if (_srt_boolean_environment ("PRESSURE_VESSEL_LOG_WITH_TIMESTAMP", FALSE)) flags |= SRT_LOG_FLAGS_TIMESTAMP;