class EnvChecker::Notifier

Public Class Methods

format_error_message(environment, error_message) click to toggle source
# File lib/env_checker/notifier.rb, line 11
def format_error_message(environment, error_message)
  return [] unless error_message

  messages = %w([EnvChecker])
  messages << "[#{environment}]" if environment
  messages << error_message
  messages.join(' ')
end
log_message(configuration, type, environment, error_message) click to toggle source
# File lib/env_checker/notifier.rb, line 4
def log_message(configuration, type, environment, error_message)
  return unless error_message

  message = format_error_message(environment, error_message)
  notify(configuration, type, message)
end
notify(configuration, type, message) click to toggle source
# File lib/env_checker/notifier.rb, line 20
def notify(configuration, type, message)
  notify_slack(configuration, message)
  notify_rollbar(configuration, message)
  notify_email(configuration, message)
  notify_logger(configuration, type, message)
end
notify_email(configuration, message) click to toggle source
# File lib/env_checker/notifier.rb, line 31
def notify_email(configuration, message)
  # TODO: implement email
end
notify_logger(configuration, type, message) click to toggle source
# File lib/env_checker/notifier.rb, line 42
def notify_logger(configuration, type, message)
  configuration.logger &&
    case type
    when :warning
      configuration.logger.warn(message)
    when :error
      configuration.logger.error(message)
    else
      configuration.logger.info(message)
    end
end
notify_rollbar(configuration, message) click to toggle source
# File lib/env_checker/notifier.rb, line 27
def notify_rollbar(configuration, message)
  # TODO: implement rollbar
end
notify_slack(configuration, message) click to toggle source
# File lib/env_checker/notifier.rb, line 35
def notify_slack(configuration, message)
  configuration.slack_notifier &&
    configuration.slack_notifier.ping(message)
rescue StandardError => e
  notify_logger(:error, e)
end