From 7e9a2199f4f129eee6af9ba1c56ffc2c13754c17 Mon Sep 17 00:00:00 2001 From: KTachibanaM Date: Mon, 14 Oct 2024 22:21:41 -0700 Subject: [PATCH] flag for debug logs --- docker-compose.self-contained.yml | 1 + docs/self-contained-docker-image.md | 3 ++- scripts/dump_env_and_procfile.sh | 1 + scripts/gen_nitter_conf.py | 7 +++++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker-compose.self-contained.yml b/docker-compose.self-contained.yml index 5c3824041..367552608 100644 --- a/docker-compose.self-contained.yml +++ b/docker-compose.self-contained.yml @@ -34,6 +34,7 @@ services: # optional debugging flags - DEBUG=1 - RESET_NITTER_ACCOUNTS_FILE=1 + - INSTANCE_ENABLE_DEBUG=1 env_file: # should require from env # TWITTER_USERNAME diff --git a/docs/self-contained-docker-image.md b/docs/self-contained-docker-image.md index 323183313..d500a03c1 100644 --- a/docs/self-contained-docker-image.md +++ b/docs/self-contained-docker-image.md @@ -38,7 +38,8 @@ In addition to the [regular Nitter docker image](https://github.com/sekai-soft/n | INSTANCE_HOSTNAME | No | The hostname used to render public-facing URLs such as hyperlinks in RSS feeds. Defaults to `localhost:8080`. | | INSTANCE_HTTPS | No | Use `1` to enable serving https traffic. | | DEBUG | No | Use `1` to log debug messages. | -| RESET_NITTER_ACCOUNTS_FILE | No | Use `1` to remove the existing `/nitter-data/guest_accounts.json` file | +| RESET_NITTER_ACCOUNTS_FILE | No | Use `1` to remove the existing `/nitter-data/guest_accounts.json` file | +| INSTANCE_ENABLE_DEBUG | No | Use `1` to enable debug logging | * After the container is up, Nitter is available at port 8081 within the container if Nginx is enabled, and at port 8080 within the container if Nginx is disabled. diff --git a/scripts/dump_env_and_procfile.sh b/scripts/dump_env_and_procfile.sh index 2c60ca3b1..dfb67c0f9 100755 --- a/scripts/dump_env_and_procfile.sh +++ b/scripts/dump_env_and_procfile.sh @@ -25,6 +25,7 @@ echo INSTANCE_BASE64_MEDIA=$INSTANCE_BASE64_MEDIA >> /src/.env echo INSTANCE_TITLE=$INSTANCE_TITLE >> /src/.env echo INSTANCE_THEME=$INSTANCE_THEME >> /src/.env echo INSTANCE_INFINITE_SCROLL=$INSTANCE_INFINITE_SCROLL >> /src/.env +echo INSTANCE_ENABLE_DEBUG=$INSTANCE_ENABLE_DEBUG >> /src/.env echo Dumping instance guardian env... echo INSTANCE_RSS_PASSWORD=$INSTANCE_RSS_PASSWORD >> /src/.env diff --git a/scripts/gen_nitter_conf.py b/scripts/gen_nitter_conf.py index 7725880c9..20b08c1f2 100644 --- a/scripts/gen_nitter_conf.py +++ b/scripts/gen_nitter_conf.py @@ -12,6 +12,7 @@ BASE64_MEDIA_PLZ_CHANGE = "[BASE64_MEDIA_PLZ_CHANGE]" THEME_PLZ_CHANGE = "[THEME_PLZ_CHANGE]" INFINITE_SCROLL_PLZ_CHANGE = "[INFINITE_SCROLL_PLZ_CHANGE]" +ENABLE_DEBUG_PLZ_CHANGE = "[ENABLE_DEBUG_PLZ_CHANGE]" TEMPLATE = """[Server] hostname = "[HOSTNAME_PLZ_CHANGE]" # for generating links, change this to your own domain/ip @@ -38,7 +39,7 @@ hmacKey = "secretkey" # random key for cryptographic signing of video urls base64Media = [BASE64_MEDIA_PLZ_CHANGE] # use base64 encoding for proxied media urls enableRSS = true # set this to false to disable RSS feeds -enableDebug = false # enable request logs and debug endpoints (/.accounts) +enableDebug = [ENABLE_DEBUG_PLZ_CHANGE] # enable request logs and debug endpoints (/.accounts) proxy = "" # http/https url, SOCKS proxies are not supported proxyAuth = "" tokenCount = 10 @@ -89,6 +90,7 @@ def main() -> str: title = getenv_treat_empty_string_as_none("INSTANCE_TITLE", "My Nitter instance") theme = getenv_treat_empty_string_as_none("INSTANCE_THEME", "Nitter") infinite_scroll = "true" if os.getenv("INSTANCE_INFINITE_SCROLL") == "1" else "false" + enable_debug = "true" if os.getenv("INSTANCE_ENABLE_DEBUG") == "1" else "false" return TEMPLATE \ .replace(HOSTNAME_PLZ_CHANGE, hostname) \ @@ -100,7 +102,8 @@ def main() -> str: .replace(BASE64_MEDIA_PLZ_CHANGE, base64_media) \ .replace(TITLE_PLZ_CHANGE, title) \ .replace(THEME_PLZ_CHANGE, theme) \ - .replace(INFINITE_SCROLL_PLZ_CHANGE, infinite_scroll) + .replace(INFINITE_SCROLL_PLZ_CHANGE, infinite_scroll) \ + .replace(ENABLE_DEBUG_PLZ_CHANGE, enable_debug) if __name__ == "__main__": if len(sys.argv) != 2: