Class: LogEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/log_query/log_entry.rb

Constant Summary collapse

LOG_PARSER =
/^(?<timestamp>[^\s]+) (?<source>[^\[]+)\[(?<dyno>[^\]]+)\]: (?<message>.*)$/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timestamp, source, dyno, message) ⇒ LogEntry

Returns a new instance of LogEntry.



13
14
15
16
# File 'lib/log_query/log_entry.rb', line 13

def initialize(timestamp, source, dyno, message)
  @timestamp, @source, @dyno = timestamp, source, dyno
  @message = Messages.resolve_message(source, dyno).new(message)
end

Instance Attribute Details

#dynoObject

Returns the value of attribute dyno.



4
5
6
# File 'lib/log_query/log_entry.rb', line 4

def dyno
  @dyno
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/log_query/log_entry.rb', line 4

def message
  @message
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/log_query/log_entry.rb', line 4

def source
  @source
end

#timestampObject

Returns the value of attribute timestamp.



4
5
6
# File 'lib/log_query/log_entry.rb', line 4

def timestamp
  @timestamp
end

Class Method Details

.from_heroku_log_line(line) ⇒ Object



8
9
10
11
# File 'lib/log_query/log_entry.rb', line 8

def self.from_heroku_log_line(line)
  matches = line.match(LOG_PARSER)
  new(matches[:timestamp], matches[:source], matches[:dyno], matches[:message])
end