Class: Opbeat::ErrorMessage
- Inherits:
-
Object
- Object
- Opbeat::ErrorMessage
- Defined in:
- lib/opbeat/error_message.rb,
lib/opbeat/error_message/http.rb,
lib/opbeat/error_message/user.rb,
lib/opbeat/error_message/exception.rb,
lib/opbeat/error_message/stacktrace.rb
Defined Under Namespace
Classes: Exception, HTTP, Stacktrace, User
Constant Summary collapse
- DEFAULTS =
{ level: :error, logger: 'root'.freeze }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#culprit ⇒ Object
Returns the value of attribute culprit.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#http ⇒ Object
Returns the value of attribute http.
-
#level ⇒ Object
Returns the value of attribute level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#machine ⇒ Object
Returns the value of attribute machine.
-
#message ⇒ Object
Returns the value of attribute message.
-
#param_message ⇒ Object
Returns the value of attribute param_message.
-
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #add_extra(info) ⇒ Object
-
#initialize(config, message, attrs = {}) {|_self| ... } ⇒ ErrorMessage
constructor
A new instance of ErrorMessage.
Constructor Details
#initialize(config, message, attrs = {}) {|_self| ... } ⇒ ErrorMessage
Returns a new instance of ErrorMessage.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/opbeat/error_message.rb', line 16 def initialize config, , attrs = {} @config = config @message = @timestamp = Time.now.utc.to_i DEFAULTS.merge(attrs).each do |k,v| send(:"#{k}=", v) end @filter = Filter.new config yield self if block_given? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
29 30 31 |
# File 'lib/opbeat/error_message.rb', line 29 def config @config end |
#culprit ⇒ Object
Returns the value of attribute culprit.
34 35 36 |
# File 'lib/opbeat/error_message.rb', line 34 def culprit @culprit end |
#exception ⇒ Object
Returns the value of attribute exception.
38 39 40 |
# File 'lib/opbeat/error_message.rb', line 38 def exception @exception end |
#extra ⇒ Object
Returns the value of attribute extra.
36 37 38 |
# File 'lib/opbeat/error_message.rb', line 36 def extra @extra end |
#http ⇒ Object
Returns the value of attribute http.
40 41 42 |
# File 'lib/opbeat/error_message.rb', line 40 def http @http end |
#level ⇒ Object
Returns the value of attribute level.
32 33 34 |
# File 'lib/opbeat/error_message.rb', line 32 def level @level end |
#logger ⇒ Object
Returns the value of attribute logger.
33 34 35 |
# File 'lib/opbeat/error_message.rb', line 33 def logger @logger end |
#machine ⇒ Object
Returns the value of attribute machine.
35 36 37 |
# File 'lib/opbeat/error_message.rb', line 35 def machine @machine end |
#message ⇒ Object
Returns the value of attribute message.
30 31 32 |
# File 'lib/opbeat/error_message.rb', line 30 def @message end |
#param_message ⇒ Object
Returns the value of attribute param_message.
37 38 39 |
# File 'lib/opbeat/error_message.rb', line 37 def @param_message end |
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
39 40 41 |
# File 'lib/opbeat/error_message.rb', line 39 def stacktrace @stacktrace end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
31 32 33 |
# File 'lib/opbeat/error_message.rb', line 31 def @timestamp end |
#user ⇒ Object
Returns the value of attribute user.
41 42 43 |
# File 'lib/opbeat/error_message.rb', line 41 def user @user end |
Class Method Details
.from_exception(config, exception, opts = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/opbeat/error_message.rb', line 43 def self.from_exception config, exception, opts = {} = "#{exception.class}: #{exception.}" if config.excluded_exceptions.include? exception.class.to_s info "Skipping excluded exception #{exception.class}" return nil end = new(config, ) do |msg| msg.level = :error msg.exception = Exception.from(exception) msg.stacktrace = Stacktrace.from(config, exception) end if frames = .stacktrace && .stacktrace.frames if first_frame = frames.last .culprit = "#{first_frame.filename}:#{first_frame.lineno}:in `#{first_frame.function}'" end end if env = opts[:rack_env] .http = HTTP.from_rack_env env, filter: @filter .user = User.from_rack_env config, env end if extra = opts[:extra] .extra = extra end end |
Instance Method Details
#add_extra(info) ⇒ Object
75 76 77 78 |
# File 'lib/opbeat/error_message.rb', line 75 def add_extra info @extra ||= {} @extra.merge! info end |