Sha256: 25c2a19fe6aa69fa1d1f4062d3b27bd6efe5c68297d5f74b5c41c30fb9ccbd74

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'logger'

module Binnacle
  module Logging

    attr_writer :asynch

    def self.new(client, logging_channel_id, params = {})
      client.logging_channel_id = logging_channel_id || Binnacle.configuration.logging_channel
      client.client_id = params[:client_id] || ''
      client.session_id = params[:session_id] || ''

      if defined?(ActiveSupport::TaggedLogging)
        logger = ActiveSupport::TaggedLogging.new(Logger.new(client))
        logger.formatter = client.formatter
      elsif defined?(ActiveSupport::Logger)
        logger = ActiveSupport::Logger.new(client)
        logger.formatter = client.formatter
      else
        logger = Logger.new(client)
        logger.formatter = client.formatter
      end
      logger
    end

    def self.build(api_key = nil, api_secret = nil, endpoint = nil, logging_channel_id = nil, params = {})
      client = Binnacle::Client.new(api_key, api_secret, endpoint, logging_channel_id)
      self.new(client, logging_channel_id, params)
    end

    def asynch
      @asynch.nil? ? true : @asynch
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
binnacle-0.5.0 lib/binnacle/logging/logging.rb
binnacle-0.4.9 lib/binnacle/logging/logging.rb
binnacle-0.4.8 lib/binnacle/logging/logging.rb