Class: Startback::Support::LogFormatter
- Inherits:
-
Object
- Object
- Startback::Support::LogFormatter
- Defined in:
- lib/startback/support/log_formatter.rb
Instance Method Summary collapse
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/startback/support/log_formatter.rb', line 5 def call(severity, time, progname, msg) { severity: severity, time: time }.merge(msg) .merge(error: error_to_json(msg[:error], severity)) .compact .to_json << "\n" end |
#error_to_json(error, severity = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/startback/support/log_formatter.rb', line 15 def error_to_json(error, severity = nil) return error if error.nil? return error if error.is_a?(String) return error.to_s unless error.is_a?(Exception) backtrace = error.backtrace[0..25] if severity == "FATAL" causes = error.causes.map{|c| error_to_json(c) } if error.respond_to?(:causes) causes = nil if causes && causes.empty? { message: error., backtrace: backtrace, causes: causes }.compact end |