From f9e4de3149fc34dabcfe202ff722ac20fbd00b0a Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Mon, 26 Nov 2018 15:30:45 +0200 Subject: [PATCH] Added log environment variables (#6) * Added verbose env variables - `LOG_DEBUG` or `LOG_VERBOSE` do not change anything it they are unset (same as before) - `LOG_DEBUG` or `LOG_VERBOSE` take precedence on Plex configuration file at start when set to `0` or `1`. The user can change the Preferences once the container is started which will overwrite the environment variables. --- README.md | 2 ++ entrypoint | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 8d56b26..0a6ffe4 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Finally, navigate to [app.plex.tv/desktop](https://app.plex.tv/desktop) or [your - `$ADVERTISE_IP` - This variable defines the additional IPs on which the server may be be found. For example: `http://10.1.1.23:32400`. This adds to the list where the server advertises that it can be found. - `$DISABLE_REMOTE_SEC` - - `$PLEX_CLAIM` - The claim token for the server to obtain a real server token. If not provided, server will not be automatically logged in. If server is already logged in, this parameter is ignored. +- `$LOG_DEBUG` - Disables debug logging if set to 0, and enables it if set to 1. This overwrites preferences set in the Plex Web user interface. +- `$LOG_VERBOSE` - Disables logging (except warnings and errors) if set to 0, and enables it if set to 1. This overwrites preferences set in the Plex Web user interface. ### Network diff --git a/entrypoint b/entrypoint index 8b9ae67..80455d2 100755 --- a/entrypoint +++ b/entrypoint @@ -51,6 +51,26 @@ if [ ! -e "\$PREF_FILE" ]; then source gen-config.sh fi +# Changes the log verbosity (Environment variable takes precedence on Plex Config) +if [ "$LOG_VERBOSE" = "1" ]; then + setPref "LogVerbose" "1" +elif [ "$LOG_VERBOSE" = "0" ]; then + setPref "LogVerbose" "0" +elif [ ! -z "$LOG_VERBOSE" ]; then + 2>&1 echo -e "${RED}LOG_VERBOSE value '$LOG_VERBOSE' is invalid${RESET}" + exit 1 +fi + +# Changes the debug verbosity (Environment variable takes precedence on Plex Config) +if [ "$LOG_DEBUG" = "1" ]; then + setPref "logDebug" "1" +elif [ "$LOG_DEBUG" = "0" ]; then + setPref "logDebug" "0" +elif [ ! -z "$LOG_DEBUG" ]; then + 2>&1 echo -e "${RED}LOG_DEBUG value '$LOG_DEBUG' is invalid${RESET}" + exit 1 +fi + # Always attempt to claim an unclaimed server in case it was signed out token="\$(getPref "PlexOnlineToken")" if [ ! -z "\${PLEX_CLAIM}" ] && [ -z "\${token}" ]; then