Class: ValidationTrackerClient::Notice
- Inherits:
-
Object
- Object
- ValidationTrackerClient::Notice
- Defined in:
- lib/validation_tracker_client/notice.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
The action (if any) that was called in this request.
-
#api_key ⇒ Object
readonly
The API key for the project to which this notice should be sent.
-
#backtrace_filters ⇒ Object
readonly
See Configuration#backtrace_filters.
-
#cgi_data ⇒ Object
readonly
CGI variables such as HTTP_METHOD.
-
#component ⇒ Object
(also: #controller)
readonly
The component (if any) which was used in this request (usually the controller).
-
#environment_name ⇒ Object
readonly
The name of the server environment (such as “production”).
-
#error_message ⇒ Object
readonly
The message from the exception, or a general description of the error.
-
#error_type ⇒ Object
Returns the value of attribute error_type.
-
#hostname ⇒ Object
readonly
The host name where this error occurred (if any).
-
#notifier_name ⇒ Object
readonly
The name of the notifier library sending this notice, such as “Validation Tracker Notifier”.
-
#notifier_url ⇒ Object
readonly
A URL for more information about the notifier library sending this notice.
-
#notifier_version ⇒ Object
readonly
The version number of the notifier library sending this notice, such as “2.1.3”.
-
#parameters ⇒ Object
(also: #params)
readonly
A hash of parameters from the query string or post body.
-
#params_filters ⇒ Object
readonly
See Configuration#params_filters.
-
#project_root ⇒ Object
readonly
The path to the project that caused the error (usually RAILS_ROOT).
-
#request_url ⇒ Object
Returns the value of attribute request_url.
-
#session_data ⇒ Object
readonly
A hash of session data from the request.
-
#url ⇒ Object
readonly
The URL at which the error occurred (if any).
Instance Method Summary collapse
-
#[](method) ⇒ Object
Allows properties to be accessed using a hash-like syntax.
-
#initialize(args) ⇒ Notice
constructor
A new instance of Notice.
-
#to_xml ⇒ Object
Converts the given notice to XML.
Constructor Details
#initialize(args) ⇒ Notice
Returns a new instance of Notice.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/validation_tracker_client/notice.rb', line 62 def initialize(args) self.args = args self.exception = args[:exception] self.api_key = args[:api_key] self.project_root = args[:project_root] self.url = args[:url] || rack_env(:url) self.notifier_name = args[:notifier_name] self.notifier_version = args[:notifier_version] self.notifier_url = args[:notifier_url] self.params_filters = args[:params_filters] || [] self.parameters = args[:parameters] || action_dispatch_params || rack_env(:params) || {} self.component = args[:component] || args[:controller] || parameters['controller'] self.action = args[:action] || parameters['action'] self.environment_name = args[:environment_name] self.cgi_data = args[:cgi_data] || args[:rack_env] self. = args[:error_message] self.error_type = args[:error_type] self.request_url = args[:request_url] self.hostname = local_hostname also_use_rack_params_filters find_session_data clean_params clean_rack_request_data end |
Instance Attribute Details
#action ⇒ Object
The action (if any) that was called in this request
35 36 37 |
# File 'lib/validation_tracker_client/notice.rb', line 35 def action @action end |
#api_key ⇒ Object
The API key for the project to which this notice should be sent
8 9 10 |
# File 'lib/validation_tracker_client/notice.rb', line 8 def api_key @api_key end |
#backtrace_filters ⇒ Object
See Configuration#backtrace_filters
21 22 23 |
# File 'lib/validation_tracker_client/notice.rb', line 21 def backtrace_filters @backtrace_filters end |
#cgi_data ⇒ Object
CGI variables such as HTTP_METHOD
15 16 17 |
# File 'lib/validation_tracker_client/notice.rb', line 15 def cgi_data @cgi_data end |
#component ⇒ Object Also known as: controller
The component (if any) which was used in this request (usually the controller)
31 32 33 |
# File 'lib/validation_tracker_client/notice.rb', line 31 def component @component end |
#environment_name ⇒ Object
The name of the server environment (such as “production”)
12 13 14 |
# File 'lib/validation_tracker_client/notice.rb', line 12 def environment_name @environment_name end |
#error_message ⇒ Object
The message from the exception, or a general description of the error
18 19 20 |
# File 'lib/validation_tracker_client/notice.rb', line 18 def end |
#error_type ⇒ Object
Returns the value of attribute error_type.
60 61 62 |
# File 'lib/validation_tracker_client/notice.rb', line 60 def error_type @error_type end |
#hostname ⇒ Object
The host name where this error occurred (if any)
56 57 58 |
# File 'lib/validation_tracker_client/notice.rb', line 56 def hostname @hostname end |
#notifier_name ⇒ Object
The name of the notifier library sending this notice, such as “Validation Tracker Notifier”
47 48 49 |
# File 'lib/validation_tracker_client/notice.rb', line 47 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
A URL for more information about the notifier library sending this notice
53 54 55 |
# File 'lib/validation_tracker_client/notice.rb', line 53 def notifier_url @notifier_url end |
#notifier_version ⇒ Object
The version number of the notifier library sending this notice, such as “2.1.3”
50 51 52 |
# File 'lib/validation_tracker_client/notice.rb', line 50 def notifier_version @notifier_version end |
#parameters ⇒ Object Also known as: params
A hash of parameters from the query string or post body.
27 28 29 |
# File 'lib/validation_tracker_client/notice.rb', line 27 def parameters @parameters end |
#params_filters ⇒ Object
See Configuration#params_filters
24 25 26 |
# File 'lib/validation_tracker_client/notice.rb', line 24 def params_filters @params_filters end |
#project_root ⇒ Object
The path to the project that caused the error (usually RAILS_ROOT)
41 42 43 |
# File 'lib/validation_tracker_client/notice.rb', line 41 def project_root @project_root end |
#request_url ⇒ Object
Returns the value of attribute request_url.
58 59 60 |
# File 'lib/validation_tracker_client/notice.rb', line 58 def request_url @request_url end |
#session_data ⇒ Object
A hash of session data from the request
38 39 40 |
# File 'lib/validation_tracker_client/notice.rb', line 38 def session_data @session_data end |
#url ⇒ Object
The URL at which the error occurred (if any)
44 45 46 |
# File 'lib/validation_tracker_client/notice.rb', line 44 def url @url end |
Instance Method Details
#[](method) ⇒ Object
Allows properties to be accessed using a hash-like syntax
155 156 157 158 159 160 161 162 |
# File 'lib/validation_tracker_client/notice.rb', line 155 def [](method) case method when :request self else send(method) end end |
#to_xml ⇒ Object
Converts the given notice to XML
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/validation_tracker_client/notice.rb', line 97 def to_xml builder = Builder::XmlMarkup.new builder.instruct! xml = builder.notice(:version => ValidationTrackerClient::API_VERSION) do |notice| notice.tag!("api-key", api_key) notice.notifier do |notifier| notifier.name(notifier_name) notifier.version(notifier_version) notifier.url(notifier_url) end notice.error do |error| error.() error.error_type(error_type) error.request_url(request_url) end if url || controller || action || !parameters.blank? || !cgi_data.blank? || !session_data.blank? notice.request do |request| request.url(url) request.component(controller) request.action(action) unless parameters.nil? || parameters.empty? request.params do |params| xml_vars_for(params, parameters) end end unless session_data.nil? || session_data.empty? request.session do |session| xml_vars_for(session, session_data) end end unless cgi_data.nil? || cgi_data.empty? request.tag!("cgi-data") do |cgi_datum| xml_vars_for(cgi_datum, cgi_data) end end end end notice.tag!("server-environment") do |env| env.tag!("project-root", project_root) env.tag!("environment-name", environment_name) env.tag!("hostname", hostname) end end puts xml.to_s xml.to_s end |