class RfLogger::Configuration
Stores configuration information
Configuration
information is loaded from a configuration block defined within the client application.
@example Standard settings
RfLogger.configure do |c| c.notification_subject = "Oh no!" c.set_notifier_list do |n| c.add_notifier Notification::DefinedElsewhere, :levels => [:error], :except => ['test', 'development'] c.add_notifier Notification::OhNo, :levels => [:fatal, :error], :only => ['production'] c.add_notifer Notifcation:VeryVerbose end # ... end
Public Class Methods
define_setting(name)
click to toggle source
# File lib/rf_logger/configuration.rb, line 20 def define_setting(name) defined_settings << name attr_accessor name end
defined_settings()
click to toggle source
# File lib/rf_logger/configuration.rb, line 25 def defined_settings @defined_settings ||= [] end
new()
click to toggle source
# File lib/rf_logger/configuration.rb, line 48 def initialize end
Public Instance Methods
clear!()
click to toggle source
# File lib/rf_logger/configuration.rb, line 51 def clear! defined_settings.each {|setting| instance_variable_set("@#{setting}", nil)} ErrorNotification.reset! end
environment()
click to toggle source
# File lib/rf_logger/configuration.rb, line 33 def environment @environment ||= begin raise UndefinedSetting.new('RfLogger.environment must be set') unless framework_environment framework_environment end end
notifiers()
click to toggle source
# File lib/rf_logger/configuration.rb, line 40 def notifiers ErrorNotification.notifiers end
set_notifier_list() { |ErrorNotification| ... }
click to toggle source
# File lib/rf_logger/configuration.rb, line 44 def set_notifier_list yield(ErrorNotification) end
Private Instance Methods
defined_settings()
click to toggle source
# File lib/rf_logger/configuration.rb, line 58 def defined_settings self.class.defined_settings end
framework_environment()
click to toggle source
# File lib/rf_logger/configuration.rb, line 62 def framework_environment case when defined?(::Rails) then ::Rails.env when defined?(Rory) then ENV['RORY_STAGE'] when defined?(Padrino) then Padrino.environment when defined?(Sinatra::Application) then Sinatra::Application.environment end end