Method: LogParser::Message#to_json

Defined in:
lib/log_parser/message.rb

#to_json(_options = {}) ⇒ String

Convert this message to JSON.

Returns:

  • (String)

    The JSON string representing this message.


66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/log_parser/message.rb', line 66

def to_json(_options = {})
  hash = {
    level: @level,
    source_file: @source_file,
    source_lines: @source_lines,
    message: @message,
    log_lines: @log_lines,
    preformatted: @preformatted
  }
  hash[:pattern] = @pattern if Logger.debug?
  JSON.pretty_generate hash
end