Module: Coalmine

Defined in:
lib/coalmine/rails.rb,
lib/coalmine.rb,
lib/coalmine/rack.rb,
lib/coalmine/logger.rb,
lib/coalmine/sender.rb,
lib/coalmine/railtie.rb,
lib/coalmine/version.rb,
lib/coalmine/capistrano.rb,
lib/coalmine/notification.rb,
lib/coalmine/configuration.rb,
lib/coalmine/version_notification.rb,
lib/coalmine/rails/action_controller.rb,
lib/coalmine/rails/controller_methods.rb

Overview

Contains all data sent to the API. Responsible for serializing data into the correct format.

Defined Under Namespace

Modules: Capistrano, Rails Classes: Configuration, Logger, Notification, Rack, Railtie, Sender, VersionNotification

Constant Summary collapse

VERSION =
"0.5.3"

Class Method Summary collapse

Class Method Details

.configCoalmine::Configuration

Fetch the config.

Returns:



27
28
29
30
# File 'lib/coalmine.rb', line 27

def self.config
  @configuration ||= Configuration.new
  @configuration
end

.configure {|config| ... } ⇒ Object

Configure the coalmine client.

Examples:

Coalmine.configure do |config|
  config.signature = "abc"
  config.logger = Rails.logger
end

Yields:



19
20
21
# File 'lib/coalmine.rb', line 19

def self.configure
  yield(config)
end

.custom_variablesObject

Variables that may be set by the application.



86
87
88
# File 'lib/coalmine.rb', line 86

def self.custom_variables
  @custom_variables ||= {}
end

.debug(message) ⇒ Object



75
76
77
# File 'lib/coalmine.rb', line 75

def self.debug(message)
  notify(nil, :message => message, :severity => "DEBUG")
end

.err(message) ⇒ Object



59
60
61
# File 'lib/coalmine.rb', line 59

def self.err(message)
  notify(nil, :message => message, :severity => "ERROR")
end

.error(message) ⇒ Object



63
64
65
# File 'lib/coalmine.rb', line 63

def self.error(message)
  err(message)
end

.filter(hash) ⇒ Object



79
80
81
82
# File 'lib/coalmine.rb', line 79

def self.filter(hash)
  @filter ||= ActionDispatch::Http::ParameterFilter.new(config.filters)
  @filter.filter(hash)
end

.info(message) ⇒ Object



71
72
73
# File 'lib/coalmine.rb', line 71

def self.info(message)
  notify(nil, :message => message, :severity => "INFO")
end

.loggerObject



32
33
34
# File 'lib/coalmine.rb', line 32

def self.logger
  config.logger
end

.notify(exception, additional_data = {}) ⇒ Boolean

Send an exception manually to the API. This method packages up the exception and then sends it.

Parameters:

  • exception (Exception)

    The exception to log

Returns:

  • (Boolean)

    True if notification is sent OK



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/coalmine.rb', line 42

def self.notify(exception, additional_data = {})
  
  # We also log the exception locally.
  logger.error exception

  # Be paranoid about causing exceptions.
  begin
    notification = build_from_exception(exception, additional_data)
    
    # Send the exception to the remote.
    return send(notification)
  rescue Exception => e
    logger.error e
    return false
  end
end

.warn(message) ⇒ Object



67
68
69
# File 'lib/coalmine.rb', line 67

def self.warn(message)
  notify(nil, :message => message, :severity => "WARN")
end