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)
|
||||
contact_inbox
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
|
|||
end
|
||||
ensure_contact_avatar
|
||||
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
|
||||
Sentry.capture_exception(e)
|
||||
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.exchange_access_token_info(omniauth_token)['access_token']
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
redirect_to twitter_app_redirect_url
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class Webhooks::InstagramController < ApplicationController
|
|||
::Webhooks::InstagramEventsJob.perform_later(params.to_unsafe_hash[:entry])
|
||||
render json: :ok
|
||||
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
|
||||
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)
|
||||
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
|
||||
|
|
|
@ -8,7 +8,7 @@ class ContactIpLookupJob < ApplicationJob
|
|||
|
||||
update_contact_location_from_ip(contact)
|
||||
rescue Errno::ETIMEDOUT => e
|
||||
Rails.logger.info "Exception: ip resolution failed : #{e.message}"
|
||||
Rails.logger.warn "Exception: ip resolution failed : #{e.message}"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -25,8 +25,8 @@ class ApplicationMailer < ActionMailer::Base
|
|||
private
|
||||
|
||||
def handle_smtp_exceptions(message)
|
||||
Rails.logger.info 'Failed to send Email'
|
||||
Rails.logger.info "Exception: #{message}"
|
||||
Rails.logger.warn 'Failed to send Email'
|
||||
Rails.logger.error "Exception: #{message}"
|
||||
end
|
||||
|
||||
def send_mail_with_liquid(*args)
|
||||
|
|
|
@ -45,7 +45,7 @@ class Channel::FacebookPage < ApplicationRecord
|
|||
source_id: instagram_id
|
||||
)
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class Channel::TwitterProfile < ApplicationRecord
|
|||
source_id: profile_id
|
||||
)
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,6 +62,6 @@ class Channel::TwitterProfile < ApplicationRecord
|
|||
unsubscribe_response = twitter_client.remove_subscription(user_id: profile_id)
|
||||
Rails.logger.info "TWITTER_UNSUBSCRIBE: #{unsubscribe_response.body}"
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
end
|
||||
end
|
||||
|
|
|
@ -86,7 +86,7 @@ class Channel::WebWidget < ApplicationRecord
|
|||
)
|
||||
contact_inbox
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ class Instagram::SendOnInstagramService < Base::SendOnChannelService
|
|||
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?
|
||||
|
||||
response
|
||||
|
|
|
@ -66,7 +66,7 @@ class Notification::PushNotificationService
|
|||
rescue Webpush::ExpiredSubscription
|
||||
subscription.destroy!
|
||||
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
|
||||
|
||||
def send_fcm_push(subscription)
|
||||
|
|
|
@ -5,14 +5,14 @@ class Twilio::WebhookSetupService
|
|||
|
||||
def perform
|
||||
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
|
||||
twilio_client
|
||||
.incoming_phone_numbers(phonenumber_sid)
|
||||
.update(sms_method: 'POST', sms_url: twilio_callback_index_url)
|
||||
end
|
||||
rescue Twilio::REST::TwilioError => e
|
||||
Rails.logger.info "TWILIO_FAILURE: #{e.message}"
|
||||
Rails.logger.error "TWILIO_FAILURE: #{e.message}"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -58,7 +58,7 @@ class Twitter::SendOnTwitterService < Base::SendOnChannelService
|
|||
tweet_data = response.body
|
||||
message.update!(source_id: tweet_data['id_str'])
|
||||
else
|
||||
Rails.logger.info "TWITTER_TWEET_REPLY_ERROR #{response.body}"
|
||||
Rails.logger.error "TWITTER_TWEET_REPLY_ERROR #{response.body}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,7 +91,7 @@ end
|
|||
|
||||
# Log blocked events
|
||||
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
|
||||
|
||||
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 })
|
||||
version = JSON.parse(response)['version']
|
||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||
Rails.logger.info "Exception: #{e.message}"
|
||||
Rails.logger.error "Exception: #{e.message}"
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e)
|
||||
end
|
||||
|
@ -50,7 +50,7 @@ class ChatwootHub
|
|||
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 })
|
||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||
Rails.logger.info "Exception: #{e.message}"
|
||||
Rails.logger.error "Exception: #{e.message}"
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e)
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ class ChatwootHub
|
|||
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 })
|
||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||
Rails.logger.info "Exception: #{e.message}"
|
||||
Rails.logger.error "Exception: #{e.message}"
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e)
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ class ChatwootHub
|
|||
info = { event_name: event_name, event_data: event_data }
|
||||
RestClient.post(EVENTS_URL, info.merge(instance_config).to_json, { content_type: :json, accept: :json })
|
||||
rescue *ExceptionList::REST_CLIENT_EXCEPTIONS => e
|
||||
Rails.logger.info "Exception: #{e.message}"
|
||||
Rails.logger.error "Exception: #{e.message}"
|
||||
rescue StandardError => e
|
||||
Sentry.capture_exception(e)
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
|
|||
post_message if message_content.present?
|
||||
upload_file if message.attachments.any?
|
||||
rescue Slack::Web::Api::Errors::AccountInactive => e
|
||||
Rails.logger.info e
|
||||
Rails.logger.error e
|
||||
hook.authorization_error!
|
||||
hook.disable if hook.enabled?
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ if defined?(ActiveRecord::Base)
|
|||
ActiveRecord::Base.descendants.each_with_object({}) do |record_class, records|
|
||||
records[record_class.to_s] = record_class.limit(100).map(&:attributes)
|
||||
rescue StandardError => e
|
||||
Rails.logger.info e.message
|
||||
Rails.logger.error e.message
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue