Module: HydraulicBrake
- Defined in:
- lib/hydraulic_brake.rb,
lib/hydraulic_brake/notice.rb,
lib/hydraulic_brake/sender.rb,
lib/hydraulic_brake/version.rb,
lib/hydraulic_brake/backtrace.rb,
lib/hydraulic_brake/async_sender.rb,
lib/hydraulic_brake/configuration.rb,
lib/hydraulic_brake/test_notification.rb
Defined Under Namespace
Modules: TestNotification Classes: AsyncSender, Backtrace, Configuration, Notice, Sender
Constant Summary collapse
- API_VERSION =
"2.3"
- LOG_PREFIX =
"** [HydraulicBrake] "
- HEADERS =
{ 'Content-type' => 'text/xml', 'Accept' => 'text/xml, application/xml' }
- VERSION =
File.read(File.join(File.dirname(__FILE__), "../../VERSION"))
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.
-
.report_environment_info ⇒ Object
Prints out the environment info to the log for debugging help.
-
.report_notice(notice) ⇒ Object
Prints out the details about the notice that wasn’t sent to server.
-
.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.
94 95 96 |
# File 'lib/hydraulic_brake.rb', line 94 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 HydraulicBrake::Sender.
26 27 28 |
# File 'lib/hydraulic_brake.rb', line 26 def sender @sender end |
Class Method Details
.build_lookup_hash_for(exception, options = {}) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/hydraulic_brake.rb', line 117 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.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/hydraulic_brake.rb', line 77 def configure(silent = false) yield(configuration) if configuration.async self.sender = AsyncSender.new( :sync_sender => Sender.new(configuration), :capacity => configuration.async_queue_capacity) else self.sender = Sender.new(configuration) end report_ready unless silent self.sender end |
.environment_info ⇒ Object
Returns the Ruby version, Rails version, and current Rails environment
54 55 56 57 58 |
# File 'lib/hydraulic_brake.rb', line 54 def environment_info info = "[Ruby: #{RUBY_VERSION}]" info << " [#{configuration.framework}]" if configuration.framework info << " [Env: #{configuration.environment_name}]" if configuration.environment_name end |
.logger ⇒ Object
Look for the Rails logger currently defined
66 67 68 |
# File 'lib/hydraulic_brake.rb', line 66 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.
113 114 115 |
# File 'lib/hydraulic_brake.rb', line 113 def notify(exception, opts = {}) send_notice build_notice_for(exception, opts) end |
.report_environment_info ⇒ Object
Prints out the environment info to the log for debugging help
39 40 41 |
# File 'lib/hydraulic_brake.rb', line 39 def report_environment_info write_verbose_log("Environment Info: #{environment_info}") end |
.report_notice(notice) ⇒ Object
Prints out the details about the notice that wasn’t sent to server
49 50 51 |
# File 'lib/hydraulic_brake.rb', line 49 def report_notice(notice) write_verbose_log("Notice details: \n#{notice}") end |
.report_ready ⇒ Object
Tell the log that the Notifier is good to go
34 35 36 |
# File 'lib/hydraulic_brake.rb', line 34 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
44 45 46 |
# File 'lib/hydraulic_brake.rb', line 44 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
61 62 63 |
# File 'lib/hydraulic_brake.rb', line 61 def write_verbose_log() logger.debug LOG_PREFIX + if logger end |