Sha256: 0dfdbbb7cbd998864cf2789f598344d4b2f12fddcc7f077805344ba63231749d

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "active_support/logger"
require "active_support/core_ext/module/attribute_accessors"

require "net/http"
require "net/https"
require "uri"

require "slack_webhook_logger/logger"
require "slack_webhook_logger/formatter"
require "slack_webhook_logger/request_io"

module SlackWebhookLogger
  # Can be modified in Rails app
  mattr_accessor :webhook_url
  mattr_accessor :level
  mattr_accessor :formatter
  mattr_accessor :ignore_patterns

  # Used internally
  mattr_reader :webhook_uri
  mattr_reader :logger
  mattr_reader :https

  class << self
    # rubocop:disable Style/ClassVars
    def setup
      @@logger = SlackWebhookLogger::Logger.new(SlackWebhookLogger::RequestIO)

      yield self

      @@logger.formatter = @@formatter || SlackWebhookLogger::Formatter.new
      @@logger.level = @@level || :warn

      begin
        @@webhook_uri = URI.parse(@@webhook_url)
      rescue URI::InvalidURIError
        raise ArgumentError, "Invalid URI for webhook_url"
      end

      @@ignore_patterns ||= []
    end
    # rubocop:enable Style/ClassVars
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack_webhook_logger-0.5.5 lib/slack_webhook_logger.rb
slack_webhook_logger-0.5.4 lib/slack_webhook_logger.rb
slack_webhook_logger-0.5.2 lib/slack_webhook_logger.rb
slack_webhook_logger-0.5.1 lib/slack_webhook_logger.rb
slack_webhook_logger-0.5.0 lib/slack_webhook_logger.rb