Class: CustosNotifier::Notice
- Inherits:
-
Object
- Object
- CustosNotifier::Notice
- Defined in:
- lib/custos_notifier.rb
Overview
Mainly goal of this class is evaulate HTTP request attributes and build a hash object containing all parameters needed to post error to Custos Service.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(args) ⇒ Notice
constructor
A new instance of Notice.
-
#to_param ⇒ Object
Method builds (based on parameters passed to constructor) a parameter hash which i posted to Custos service.
Constructor Details
#initialize(args) ⇒ Notice
Returns a new instance of Notice.
96 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 |
# File 'lib/custos_notifier.rb', line 96 def initialize(args) @args = args @exception = args[:exception] @exception_class = @exception.class.to_s @message = @exception. @backtrace = @exception.backtrace.join("\n") @server = `hostname`.chomp @source = "" @process_id = $$ @parameters = rack_env(:params) || {} @request_uri = rack_env(:url) || "" @document_root = rack_env(:env) { |env| env["DOCUMENT_ROOT"] } || "" @content_length = rack_env(:env) { |env| env["DOCUMENT_ROOT"] } || "" @http_accept = rack_env(:env) { |env| env["HTTP_ACCEPT"] } || "" @http_method = rack_env(:request_method) @http_cookie = rack_env(:env) { |env| env["HTTP_COOKIE"] } || "" @http_host = rack_env(:host) || "" @http_referer = rack_env(:referer) || "" @user_agent = rack_env(:user_agent) || "" @path_info = rack_env(:path_info) || "" @query_string = rack_env(:query_string) || "" @connection = rack_env(:env) { |env| env["HTTP_CONNECTION"] } || "" @server_name = rack_env(:env) { |env| env["SERVER_NAME"] } || "" @session = rack_env(:env) { |env| env["rack.session"] } end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
93 94 95 |
# File 'lib/custos_notifier.rb', line 93 def args @args end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
94 95 96 |
# File 'lib/custos_notifier.rb', line 94 def parameters @parameters end |
Instance Method Details
#to_param ⇒ Object
Method builds (based on parameters passed to constructor) a parameter hash which i posted to Custos service.
- returns
-
Hash
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/custos_notifier.rb', line 128 def to_param { :project => CustosNotifier.configuration.project, :api_key => CustosNotifier.configuration.api_key, :error => { :exception_class => @exception_class, :message => @message, :stage => CustosNotifier.configuration.stage, :backtrace => @backtrace, :server => @server, :source => @source, :process_id => @process_id, :request => { :uri => @request_uri, :parameters => filter(@parameters).to_json, :document_root => @document_root, :content_length => @content_length, :http_accept => @http_accept, :http_cookie => @http_cookie, :http_host => @http_host, :http_referer => @http_referer, :user_agent => @user_agent, :path_info => @path_info, :query_string => @query_string, :connection => @connection, :server_name => @server_name, :http_method => @http_method, :session => @session.to_json } } } end |