feat: fix logging levels (#4314)
https://ruby-doc.org/stdlib-2.7.0/libdoc/logger/rdoc/Logger.html Fixes https://github.com/chatwoot/chatwoot/issues/4313
This commit is contained in:
parent
823c0ab6a7
commit
8155024b6a
19 changed files with 25 additions and 25 deletions
|
@ -70,7 +70,7 @@ class ContactBuilder
|
||||||
update_contact_avatar(contact)
|
update_contact_avatar(contact)
|
||||||
contact_inbox
|
contact_inbox
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
||||||
end
|
end
|
||||||
ensure_contact_avatar
|
ensure_contact_avatar
|
||||||
rescue Koala::Facebook::AuthenticationError
|
rescue Koala::Facebook::AuthenticationError
|
||||||
Rails.logger.info "Facebook Authorization expired for Inbox #{@inbox.id}"
|
Rails.logger.error "Facebook Authorization expired for Inbox #{@inbox.id}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
true
|
true
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Api::V1::Accounts::CallbacksController < Api::V1::Accounts::BaseController
|
||||||
koala = Koala::Facebook::OAuth.new(GlobalConfigService.load('FB_APP_ID', ''), GlobalConfigService.load('FB_APP_SECRET', ''))
|
koala = Koala::Facebook::OAuth.new(GlobalConfigService.load('FB_APP_ID', ''), GlobalConfigService.load('FB_APP_SECRET', ''))
|
||||||
koala.exchange_access_token_info(omniauth_token)['access_token']
|
koala.exchange_access_token_info(omniauth_token)['access_token']
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_already_existing_facebook_pages(data)
|
def mark_already_existing_facebook_pages(data)
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Twitter::CallbacksController < Twitter::BaseController
|
||||||
redirect_to app_twitter_inbox_agents_url(account_id: account.id, inbox_id: inbox.id)
|
redirect_to app_twitter_inbox_agents_url(account_id: account.id, inbox_id: inbox.id)
|
||||||
end
|
end
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
redirect_to twitter_app_redirect_url
|
redirect_to twitter_app_redirect_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Webhooks::InstagramController < ApplicationController
|
||||||
::Webhooks::InstagramEventsJob.perform_later(params.to_unsafe_hash[:entry])
|
::Webhooks::InstagramEventsJob.perform_later(params.to_unsafe_hash[:entry])
|
||||||
render json: :ok
|
render json: :ok
|
||||||
else
|
else
|
||||||
Rails.logger.info("Message is not received from the instagram webhook event: #{params['object']}")
|
Rails.logger.warn("Message is not received from the instagram webhook event: #{params['object']}")
|
||||||
head :unprocessable_entity
|
head :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,6 @@ class ContactAvatarJob < ApplicationJob
|
||||||
)
|
)
|
||||||
contact.avatar.attach(io: avatar_file, filename: avatar_file.original_filename, content_type: avatar_file.content_type)
|
contact.avatar.attach(io: avatar_file, filename: avatar_file.original_filename, content_type: avatar_file.content_type)
|
||||||
rescue Down::Error => e
|
rescue Down::Error => e
|
||||||
Rails.logger.info "Exception: invalid avatar url #{avatar_url} : #{e.message}"
|
Rails.logger.error "Exception: invalid avatar url #{avatar_url} : #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ContactIpLookupJob < ApplicationJob
|
||||||
|
|
||||||
update_contact_location_from_ip(contact)
|
update_contact_location_from_ip(contact)
|
||||||
rescue Errno::ETIMEDOUT => e
|
rescue Errno::ETIMEDOUT => e
|
||||||
Rails.logger.info "Exception: ip resolution failed : #{e.message}"
|
Rails.logger.warn "Exception: ip resolution failed : #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -25,8 +25,8 @@ class ApplicationMailer < ActionMailer::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def handle_smtp_exceptions(message)
|
def handle_smtp_exceptions(message)
|
||||||
Rails.logger.info 'Failed to send Email'
|
Rails.logger.warn 'Failed to send Email'
|
||||||
Rails.logger.info "Exception: #{message}"
|
Rails.logger.error "Exception: #{message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_mail_with_liquid(*args)
|
def send_mail_with_liquid(*args)
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Channel::FacebookPage < ApplicationRecord
|
||||||
source_id: instagram_id
|
source_id: instagram_id
|
||||||
)
|
)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Channel::TwitterProfile < ApplicationRecord
|
||||||
source_id: profile_id
|
source_id: profile_id
|
||||||
)
|
)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,6 +62,6 @@ class Channel::TwitterProfile < ApplicationRecord
|
||||||
unsubscribe_response = twitter_client.remove_subscription(user_id: profile_id)
|
unsubscribe_response = twitter_client.remove_subscription(user_id: profile_id)
|
||||||
Rails.logger.info "TWITTER_UNSUBSCRIBE: #{unsubscribe_response.body}"
|
Rails.logger.info "TWITTER_UNSUBSCRIBE: #{unsubscribe_response.body}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Channel::WebWidget < ApplicationRecord
|
||||||
)
|
)
|
||||||
contact_inbox
|
contact_inbox
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Instagram::SendOnInstagramService < Base::SendOnChannelService
|
||||||
query: query
|
query: query
|
||||||
)
|
)
|
||||||
|
|
||||||
Rails.logger.info("Instagram response: #{response['error']} : #{message_content}") if response['error']
|
Rails.logger.error("Instagram response: #{response['error']} : #{message_content}") if response['error']
|
||||||
message.update!(source_id: response['message_id']) if response['message_id'].present?
|
message.update!(source_id: response['message_id']) if response['message_id'].present?
|
||||||
|
|
||||||
response
|
response
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Notification::PushNotificationService
|
||||||
rescue Webpush::ExpiredSubscription
|
rescue Webpush::ExpiredSubscription
|
||||||
subscription.destroy!
|
subscription.destroy!
|
||||||
rescue Errno::ECONNRESET, Net::OpenTimeout, Net::ReadTimeout => e
|
rescue Errno::ECONNRESET, Net::OpenTimeout, Net::ReadTimeout => e
|
||||||
Rails.logger.info "Webpush operation error: #{e.message}"
|
Rails.logger.error "Webpush operation error: #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_fcm_push(subscription)
|
def send_fcm_push(subscription)
|
||||||
|
|
|
@ -5,14 +5,14 @@ class Twilio::WebhookSetupService
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
if phone_numbers.empty?
|
if phone_numbers.empty?
|
||||||
Rails.logger.info "TWILIO_PHONE_NUMBER_NOT_FOUND: #{channel.phone_number}"
|
Rails.logger.warn "TWILIO_PHONE_NUMBER_NOT_FOUND: #{channel.phone_number}"
|
||||||
else
|
else
|
||||||
twilio_client
|
twilio_client
|
||||||
.incoming_phone_numbers(phonenumber_sid)
|
.incoming_phone_numbers(phonenumber_sid)
|
||||||
.update(sms_method: 'POST', sms_url: twilio_callback_index_url)
|
.update(sms_method: 'POST', sms_url: twilio_callback_index_url)
|
||||||
end
|
end
|
||||||
rescue Twilio::REST::TwilioError => e
|
rescue Twilio::REST::TwilioError => e
|
||||||
Rails.logger.info "TWILIO_FAILURE: #{e.message}"
|
Rails.logger.error "TWILIO_FAILURE: #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Twitter::SendOnTwitterService < Base::SendOnChannelService
|
||||||
tweet_data = response.body
|
tweet_data = response.body
|
||||||
message.update!(source_id: tweet_data['id_str'])
|
message.update!(source_id: tweet_data['id_str'])
|
||||||
else
|
else
|
||||||
Rails.logger.info "TWITTER_TWEET_REPLY_ERROR #{response.body}"
|
Rails.logger.error "TWITTER_TWEET_REPLY_ERROR #{response.body}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,7 +91,7 @@ end
|
||||||
|
|
||||||
# Log blocked events
|
# Log blocked events
|
||||||
ActiveSupport::Notifications.subscribe('throttle.rack_attack') do |_name, _start, _finish, _request_id, payload|
|
ActiveSupport::Notifications.subscribe('throttle.rack_attack') do |_name, _start, _finish, _request_id, payload|
|
||||||
Rails.logger.info "[Rack::Attack][Blocked] remote_ip: \"#{payload[:request].remote_ip}\", path: \"#{payload[:request].path}\""
|
Rails.logger.warn "[Rack::Attack][Blocked] remote_ip: \"#{payload[:request].remote_ip}\", path: \"#{payload[:request].path}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
Rack::Attack.enabled = Rails.env.production? ? ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_RACK_ATTACK', true)) : false
|
Rack::Attack.enabled = Rails.env.production? ? ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_RACK_ATTACK', true)) : false
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ChatwootHub
|
||||||
response = RestClient.post(PING_URL, info.to_json, { content_type: :json, accept: :json })
|
response = RestClient.post(PING_URL, info.to_json, { content_type: :json, accept: :json })
|
||||||
version = JSON.parse(response)['version']
|
version = JSON.parse(response)['version']
|
||||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||||
Rails.logger.info "Exception: #{e.message}"
|
Rails.logger.error "Exception: #{e.message}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ class ChatwootHub
|
||||||
info = { company_name: company_name, owner_name: owner_name, owner_email: owner_email, subscribed_to_mailers: true }
|
info = { company_name: company_name, owner_name: owner_name, owner_email: owner_email, subscribed_to_mailers: true }
|
||||||
RestClient.post(REGISTRATION_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
RestClient.post(REGISTRATION_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
||||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||||
Rails.logger.info "Exception: #{e.message}"
|
Rails.logger.error "Exception: #{e.message}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
|
@ -59,7 +59,7 @@ class ChatwootHub
|
||||||
info = { fcm_token_list: fcm_token_list, fcm_options: fcm_options }
|
info = { fcm_token_list: fcm_token_list, fcm_options: fcm_options }
|
||||||
RestClient.post(PUSH_NOTIFICATION_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
RestClient.post(PUSH_NOTIFICATION_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
||||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||||
Rails.logger.info "Exception: #{e.message}"
|
Rails.logger.error "Exception: #{e.message}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
|
@ -70,7 +70,7 @@ class ChatwootHub
|
||||||
info = { event_name: event_name, event_data: event_data }
|
info = { event_name: event_name, event_data: event_data }
|
||||||
RestClient.post(EVENTS_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
RestClient.post(EVENTS_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
||||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||||
Rails.logger.info "Exception: #{e.message}"
|
Rails.logger.error "Exception: #{e.message}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Sentry.capture_exception(e)
|
Sentry.capture_exception(e)
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
||||||
post_message if message_content.present?
|
post_message if message_content.present?
|
||||||
upload_file if message.attachments.any?
|
upload_file if message.attachments.any?
|
||||||
rescue Slack::Web::Api::Errors::AccountInactive => e
|
rescue Slack::Web::Api::Errors::AccountInactive => e
|
||||||
Rails.logger.info e
|
Rails.logger.error e
|
||||||
hook.authorization_error!
|
hook.authorization_error!
|
||||||
hook.disable if hook.enabled?
|
hook.disable if hook.enabled?
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ if defined?(ActiveRecord::Base)
|
||||||
ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
|
ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
|
||||||
records[record_class.to_s] = record_class.limit(100).map(&:attributes)
|
records[record_class.to_s] = record_class.limit(100).map(&:attributes)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
Rails.logger.info e.message
|
Rails.logger.error e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue