module Binnacle
Constants
- LOCK
- VERSION
Public Class Methods
binnacle_logger()
click to toggle source
# File lib/binnacle.rb, line 51 def self.binnacle_logger @internal_logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT) end
binnacle_logger=(logger)
click to toggle source
# File lib/binnacle.rb, line 55 def self.binnacle_logger=(logger) @internal_logger = logger end
client()
click to toggle source
# File lib/binnacle.rb, line 94 def self.client @client end
configuration()
click to toggle source
# File lib/binnacle.rb, line 34 def self.configuration @configuration || LOCK.synchronize { @configuration ||= Binnacle::Configuration.new } end
configure(options = {}) { |configuration| ... }
click to toggle source
# File lib/binnacle.rb, line 38 def self.configure(options = {}) set_options(options) yield(configuration) if block_given? configuration.prepare! if configuration.ready? create_client setup_logger end end
create_client()
click to toggle source
# File lib/binnacle.rb, line 65 def self.create_client binnacle_logger.info "Instantiating Binnacle Client..." begin @client = Client.new() rescue Faraday::ConnectionFailed => fcf binnacle_logger.error "Failed to connect to Binnacle. Check your settings!" end end
logger()
click to toggle source
# File lib/binnacle.rb, line 90 def self.logger @logger end
set_options(options)
click to toggle source
# File lib/binnacle.rb, line 59 def self.set_options(options) options.each do |k,v| configuration.send("#{k}=", v) rescue nil if configuration.respond_to?("#{k}=") end end
setup_logger()
click to toggle source
# File lib/binnacle.rb, line 74 def self.setup_logger if @client && configuration.can_setup_logger? if defined?(Rails) binnacle_logger.info "Configuring Binnacle Rails logger..." @logger = Logging.new(@client, configuration.logging_channel) @logger.level = Logger::INFO if configuration.rails_verbose_logging? Rails.logger.extend(ActiveSupport::Logger.broadcast(@logger)) end Rack::Timeout.unregister_state_change_observer(:logger) if Rails.env.development? else binnacle_logger.info "Skipping Binnacle Rails logger configuration..." end end end