From a1489e628033da56f3ea87b1050754e80117d17c Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 26 Jul 2021 21:03:28 +0200 Subject: [PATCH] YoutubeAPI: add debug/trace logging --- src/invidious/helpers/youtube_api.cr | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/invidious/helpers/youtube_api.cr b/src/invidious/helpers/youtube_api.cr index fb5e0143..fa2634e9 100644 --- a/src/invidious/helpers/youtube_api.cr +++ b/src/invidious/helpers/youtube_api.cr @@ -84,6 +84,15 @@ module YoutubeAPI def api_key : String HARDCODED_CLIENTS[@client_type][:api_key] end + + # Convert to string, for logging purposes + def to_s + return { + client_type: self.name, + region: @region, + proxy_region: @proxy_region, + }.to_s + end end # Default client config, used if nothing is passed @@ -341,6 +350,11 @@ module YoutubeAPI "Accept-Encoding" => "gzip", } + # Logging + LOGGER.debug("YoutubeAPI: Using endpoint: \"#{endpoint}\"") + LOGGER.trace("YoutubeAPI: ClientConfig: #{client_config.to_s}") + LOGGER.trace("YoutubeAPI: POST data: #{data.to_s}") + # Send the POST request if client_config.proxy_region response = YT_POOL.client(