Module: ValidationTrackerClient
- Defined in:
- lib/validation_tracker_client.rb,
lib/validation_tracker_client/rails.rb,
lib/validation_tracker_client/notice.rb,
lib/validation_tracker_client/sender.rb,
lib/validation_tracker_client/railtie.rb,
lib/validation_tracker_client/version.rb,
lib/validation_tracker_client/configuration.rb,
lib/validation_tracker_client/rails/controller_methods.rb
Overview
Gem for applications to automatically post errors to the Validation Tracker of their choice.
Defined Under Namespace
Modules: Rails Classes: Configuration, Notice, Railtie, Sender
Constant Summary collapse
- API_VERSION =
"2.0"- LOG_PREFIX =
"** [Validation Tracker] "- HEADERS =
{ 'Content-type' => 'text/xml', 'Accept' => 'text/xml, application/xml' }
- VERSION =
"2.4.12"
Class Attribute Summary collapse
-
.configuration ⇒ Object
A Validation Tracker configuration object.
-
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Validation Tracker 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(error_message, 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 Validation Tracker for debugging help.
-
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger.
Class Attribute Details
.configuration ⇒ Object
A Validation Tracker configuration object. Must act like a hash and return sensible values for all Validation Tracker configuration options. See ValidationTrackerClient::Configuration.
34 35 36 |
# File 'lib/validation_tracker_client.rb', line 34 def configuration @configuration end |
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Validation Tracker server. Must respond to #send_to_validation_tracker. See ValidationTrackerClient::Sender.
30 31 32 |
# File 'lib/validation_tracker_client.rb', line 30 def sender @sender end |
Class Method Details
.build_lookup_hash_for(exception, options = {}) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/validation_tracker_client.rb', line 104 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[: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.
75 76 77 78 79 80 |
# File 'lib/validation_tracker_client.rb', line 75 def configure(silent = false) self.configuration ||= Configuration.new yield(configuration) self.sender = Sender.new(configuration) report_ready unless silent end |
.environment_info ⇒ Object
Returns the Ruby version, Rails version, and current Rails environment
52 53 54 55 56 |
# File 'lib/validation_tracker_client.rb', line 52 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
64 65 66 |
# File 'lib/validation_tracker_client.rb', line 64 def logger self.configuration.logger end |
.notify(error_message, opts = {}) ⇒ Object
Sends an exception manually using this method, even when you are not in a controller.
93 94 95 |
# File 'lib/validation_tracker_client.rb', line 93 def notify(, opts = {}) send_notice(build_notice_for(, opts)) end |
.notify_or_ignore(exception, opts = {}) ⇒ Object
Sends the notice unless it is one of the default ignored exceptions
99 100 101 102 |
# File 'lib/validation_tracker_client.rb', line 99 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
42 43 44 |
# File 'lib/validation_tracker_client.rb', line 42 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
37 38 39 |
# File 'lib/validation_tracker_client.rb', line 37 def report_ready write_verbose_log("Notifier #{VERSION} ready to catch errors") end |
.report_response_body(response) ⇒ Object
Prints out the response body from Validation Tracker for debugging help
47 48 49 |
# File 'lib/validation_tracker_client.rb', line 47 def report_response_body(response) write_verbose_log("Response from Validation Tracker: \n#{response}") end |
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger
59 60 61 |
# File 'lib/validation_tracker_client.rb', line 59 def write_verbose_log() logger.info LOG_PREFIX + if logger end |