Class: Coalmine::Notification
- Inherits:
-
Object
- Object
- Coalmine::Notification
- Defined in:
- lib/coalmine/notification.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#error_class ⇒ Object
Returns the value of attribute error_class.
-
#file ⇒ Object
Returns the value of attribute file.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#message ⇒ Object
Returns the value of attribute message.
-
#method ⇒ Object
Returns the value of attribute method.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#process_id ⇒ Object
Returns the value of attribute process_id.
-
#referrer ⇒ Object
Returns the value of attribute referrer.
-
#server ⇒ Object
Returns the value of attribute server.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
-
#thread_id ⇒ Object
Returns the value of attribute thread_id.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Notification
constructor
A new instance of Notification.
- #post_data ⇒ Object
-
#resource_path ⇒ String
Remote resource path.
- #serialize(options) ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Notification
Returns a new instance of Notification.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/coalmine/notification.rb', line 17 def initialize(args = {}) exception = args[:exception] if exception self.stack_trace = exception.backtrace * "\n" if exception.backtrace self. = exception. self.error_class = exception.class.name self.line_number = extract_line_number(exception.backtrace) self.file = extract_file_name(exception.backtrace) end if args[:rack_env] set_from_rack_env(args[:rack_env]) end args.keys.each do |key| setter = :"#{key}=" send(setter, args[key]) if respond_to?(setter) end self.severity = "ERROR" unless self.severity self.hostname = Socket.gethostname begin self.process_id = Process::pid rescue # Ignore end begin self.thread_id = Thread.current.object_id rescue # Ignore end end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def action @action end |
#controller ⇒ Object
Returns the value of attribute controller.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def controller @controller end |
#cookies ⇒ Object
Returns the value of attribute cookies.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def @cookies end |
#environment ⇒ Object
Returns the value of attribute environment.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def environment @environment end |
#error_class ⇒ Object
Returns the value of attribute error_class.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def error_class @error_class end |
#file ⇒ Object
Returns the value of attribute file.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def file @file end |
#hostname ⇒ Object
Returns the value of attribute hostname.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def hostname @hostname end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def ip_address @ip_address end |
#line_number ⇒ Object
Returns the value of attribute line_number.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def line_number @line_number end |
#message ⇒ Object
Returns the value of attribute message.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def @message end |
#method ⇒ Object
Returns the value of attribute method.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def method @method end |
#parameters ⇒ Object
Returns the value of attribute parameters.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def parameters @parameters end |
#process_id ⇒ Object
Returns the value of attribute process_id.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def process_id @process_id end |
#referrer ⇒ Object
Returns the value of attribute referrer.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def referrer @referrer end |
#server ⇒ Object
Returns the value of attribute server.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def server @server end |
#severity ⇒ Object
Returns the value of attribute severity.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def severity @severity end |
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def stack_trace @stack_trace end |
#thread_id ⇒ Object
Returns the value of attribute thread_id.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def thread_id @thread_id end |
#url ⇒ Object
Returns the value of attribute url.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def url @url end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
12 13 14 |
# File 'lib/coalmine/notification.rb', line 12 def user_agent @user_agent end |
Instance Method Details
#post_data ⇒ Object
54 55 56 |
# File 'lib/coalmine/notification.rb', line 54 def post_data {:signature => Coalmine.config.signature, :json => to_json} end |
#resource_path ⇒ String
Remote resource path
96 97 98 |
# File 'lib/coalmine/notification.rb', line 96 def resource_path "/notify/" end |
#serialize(options) ⇒ Object
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 |
# File 'lib/coalmine/notification.rb', line 62 def serialize() config = Coalmine.config results = { :version => config.version, :app_environment => config.environment, :url => url, :file => file, :line_number => line_number, :message => , :stack_trace => stack_trace, :class => error_class, :framework => config.framework, :parameters => parameters, :ip_address => ip_address, :user_agent => user_agent, :cookies => , :method => method, :environment => environment, :server => server, :severity => severity, :hostname => hostname, :process_id => process_id, :thread_id => thread_id.to_s, # Because it is a long :referrer => referrer, :application => Coalmine.custom_variables } Coalmine.filter(results) end |
#to_json(options = {}) ⇒ Object
58 59 60 |
# File 'lib/coalmine/notification.rb', line 58 def to_json( = {}) ActiveSupport::JSON.encode(serialize()) end |