DEV: Add more verbose logging for image uploads (#13270)

Image optimization fails randomly (very rare) without a trace and it is
near impossible to find culprit image, reproduce the issue and attempt
to fix.
This commit is contained in:
Dan Ungureanu 2021-06-04 15:13:58 +03:00 committed by GitHub
parent 9431051ac1
commit da2889a7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 1 deletions

View File

@ -99,6 +99,10 @@ module Jobs
begin
retries ||= 3
if SiteSetting.verbose_upload_logging
Rails.logger.warn("Verbose Upload Logging: Downloading hotlinked image from #{src}")
end
downloaded = FileHelper.download(
src,
max_file_size: @max_size,

View File

@ -326,7 +326,7 @@ class OptimizedImage < ActiveRecord::Base
error << " unknown reason"
end
Discourse.warn(error, location: to, error_message: e.message)
Discourse.warn(error, location: to, error_message: e.message, instructions: instructions)
false
end
end

View File

@ -30,6 +30,10 @@ class UserAvatar < ActiveRecord::Base
email_hash = @@custom_user_gravatar_email_hash[user_id] || user.email_hash
gravatar_url = "https://#{SiteSetting.gravatar_base_url}/avatar/#{email_hash}.png?s=#{max}&d=404&reset_cache=#{SecureRandom.urlsafe_base64(5)}"
if SiteSetting.verbose_upload_logging
Rails.logger.warn("Verbose Upload Logging: Downloading gravatar from #{gravatar_url}")
end
# follow redirects in case gravatar change rules on us
tempfile = FileHelper.download(
gravatar_url,
@ -95,6 +99,10 @@ class UserAvatar < ActiveRecord::Base
end
def self.import_url_for_user(avatar_url, user, options = nil)
if SiteSetting.verbose_upload_logging
Rails.logger.warn("Verbose Upload Logging: Downloading sso-avatar from #{avatar_url}")
end
tempfile = FileHelper.download(
avatar_url,
max_file_size: SiteSetting.max_image_size_kb.kilobytes,

View File

@ -74,6 +74,10 @@ class UserProfile < ActiveRecord::Base
end
def self.import_url_for_user(background_url, user, options = nil)
if SiteSetting.verbose_upload_logging
Rails.logger.warn("Verbose Upload Logging: Downloading profile background from #{background_url}")
end
tempfile = FileHelper.download(
background_url,
max_file_size: SiteSetting.max_image_size_kb.kilobytes,

View File

@ -438,6 +438,9 @@ login:
discourse_connect_allows_all_return_paths: false
enable_discourse_connect_provider: false
verbose_discourse_connect_logging: false
verbose_upload_logging:
hidden: true
default: false
verbose_auth_token_logging:
hidden: true
default: true