Module: Raven::BreadcrumbLogger
- Defined in:
- lib/raven/breadcrumbs/logger.rb
Constant Summary collapse
- LEVELS =
{ ::Logger::DEBUG => 'debug', ::Logger::INFO => 'info', ::Logger::WARN => 'warn', ::Logger::ERROR => 'error', ::Logger::FATAL => 'fatal' }.freeze
- EXC_FORMAT =
/^([a-zA-Z0-9]+)\:\s(.*)$/
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse_exception(message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/raven/breadcrumbs/logger.rb', line 15 def self.parse_exception() lines = .split(/\n\s*/) # TODO: wat return nil unless lines.length > 2 match = lines[0].match(EXC_FORMAT) return nil unless match _, type, value = match.to_a [type, value] end |
Instance Method Details
#add(*args) ⇒ Object
27 28 29 30 |
# File 'lib/raven/breadcrumbs/logger.rb', line 27 def add(*args) (*args) super end |
#add_breadcrumb(severity, message = nil, progname = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/raven/breadcrumbs/logger.rb', line 32 def (severity, = nil, progname = nil) = progname if .nil? # see Ruby's Logger docs for why return if ignored_logger?(progname) return if .nil? || == "" # some loggers will add leading/trailing space as they (incorrectly, mind you) # think of logging as a shortcut to std{out,err} = .strip last_crumb = Raven..peek # try to avoid dupes from logger broadcasts if last_crumb.nil? || last_crumb. != error = Raven::BreadcrumbLogger.parse_exception() # TODO(dcramer): we need to filter out the "currently captured error" if error Raven..record do |crumb| crumb.level = Raven::BreadcrumbLogger::LEVELS.fetch(severity, nil) crumb.category = progname || 'error' crumb.type = 'error' crumb.data = { :type => error[0], :value => error[1] } end else Raven..record do |crumb| crumb.level = Raven::BreadcrumbLogger::LEVELS.fetch(severity, nil) crumb.category = progname || 'logger' crumb. = end end end end |