Module: Airbrake
- Defined in:
- lib/airbrake.rb,
lib/airbrake/rack.rb,
lib/airbrake/rails.rb,
lib/airbrake/notice.rb,
lib/airbrake/sender.rb,
lib/airbrake/railtie.rb,
lib/airbrake/version.rb,
lib/airbrake/backtrace.rb,
lib/airbrake/capistrano.rb,
lib/airbrake/configuration.rb,
lib/airbrake/user_informer.rb,
lib/airbrake/rails/error_lookup.rb,
lib/airbrake/rails/controller_methods.rb,
lib/airbrake/rails/javascript_notifier.rb,
lib/airbrake/rails/action_controller_catcher.rb
Overview
Gem for applications to automatically post errors to the Airbrake of their choice.
Defined Under Namespace
Modules: Capistrano, Rails, RakeHandler Classes: Backtrace, Configuration, Notice, Rack, Railtie, Sender, UserInformer
Constant Summary collapse
- API_VERSION =
"2.2"
- LOG_PREFIX =
"** [Airbrake] "
- HEADERS =
{ 'Content-type' => 'text/xml', 'Accept' => 'text/xml, application/xml' }
- VERSION =
"3.0.9"
Class Attribute Summary collapse
-
.configuration ⇒ Object
The configuration object.
-
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Airbrake server.
Class Method Summary collapse
- .build_lookup_hash_for(exception, options = {}) ⇒ Object
-
.configure(silent = false) {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
-
.environment_info ⇒ Object
Returns the Ruby version, Rails version, and current Rails environment.
-
.logger ⇒ Object
Look for the Rails logger currently defined.
-
.notify(exception, opts = {}) ⇒ Object
Sends an exception manually using this method, even when you are not in a controller.
-
.notify_or_ignore(exception, opts = {}) ⇒ Object
Sends the notice unless it is one of the default ignored exceptions.
-
.report_environment_info ⇒ Object
Prints out the environment info to the log for debugging help.
-
.report_ready ⇒ Object
Tell the log that the Notifier is good to go.
-
.report_response_body(response) ⇒ Object
Prints out the response body from Airbrake for debugging help.
-
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger.
Class Attribute Details
.configuration ⇒ Object
The configuration object.
88 89 90 |
# File 'lib/airbrake.rb', line 88 def configuration @configuration ||= Configuration.new end |
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Airbrake server. Must respond to #send_to_airbrake. See Airbrake::Sender.
34 35 36 |
# File 'lib/airbrake.rb', line 34 def sender @sender end |
Class Method Details
.build_lookup_hash_for(exception, options = {}) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/airbrake.rb', line 114 def build_lookup_hash_for(exception, = {}) notice = build_notice_for(exception, ) result = {} result[:action] = notice.action rescue nil result[:component] = notice.component rescue nil result[:error_class] = notice.error_class if notice.error_class result[:environment_name] = 'production' unless notice.backtrace.lines.empty? result[:file] = notice.backtrace.lines.first.file result[:line_number] = notice.backtrace.lines.first.number end result end |
.configure(silent = false) {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
79 80 81 82 83 84 |
# File 'lib/airbrake.rb', line 79 def configure(silent = false) yield(configuration) self.sender = Sender.new(configuration) report_ready unless silent self.sender end |
.environment_info ⇒ Object
Returns the Ruby version, Rails version, and current Rails environment
56 57 58 59 60 |
# File 'lib/airbrake.rb', line 56 def environment_info info = "[Ruby: #{RUBY_VERSION}]" info << " [#{configuration.framework}]" info << " [Env: #{configuration.environment_name}]" end |
.logger ⇒ Object
Look for the Rails logger currently defined
68 69 70 |
# File 'lib/airbrake.rb', line 68 def logger self.configuration.logger end |
.notify(exception, opts = {}) ⇒ Object
Sends an exception manually using this method, even when you are not in a controller.
103 104 105 |
# File 'lib/airbrake.rb', line 103 def notify(exception, opts = {}) send_notice(build_notice_for(exception, opts)) end |
.notify_or_ignore(exception, opts = {}) ⇒ Object
Sends the notice unless it is one of the default ignored exceptions
109 110 111 112 |
# File 'lib/airbrake.rb', line 109 def notify_or_ignore(exception, opts = {}) notice = build_notice_for(exception, opts) send_notice(notice) unless notice.ignore? end |
.report_environment_info ⇒ Object
Prints out the environment info to the log for debugging help
46 47 48 |
# File 'lib/airbrake.rb', line 46 def report_environment_info write_verbose_log("Environment Info: #{environment_info}") end |
.report_ready ⇒ Object
Tell the log that the Notifier is good to go
41 42 43 |
# File 'lib/airbrake.rb', line 41 def report_ready write_verbose_log("Notifier #{VERSION} ready to catch errors") end |
.report_response_body(response) ⇒ Object
Prints out the response body from Airbrake for debugging help
51 52 53 |
# File 'lib/airbrake.rb', line 51 def report_response_body(response) write_verbose_log("Response from Airbrake: \n#{response}") end |
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger
63 64 65 |
# File 'lib/airbrake.rb', line 63 def write_verbose_log() logger.info LOG_PREFIX + if logger end |