Module: LogParser

Included in:
TexLogParser
Defined in:
lib/log_parser/log_parser.rb,
lib/log_parser/buffer.rb,
lib/log_parser/logger.rb,
lib/log_parser/message.rb,
lib/log_parser/pattern.rb

Overview

Parses a log, extracting messages according to a set of Pattern.

Instances are single-use; create a new one for every log and parsing run.

Defined Under Namespace

Modules: Pattern, RegExpPattern Classes: Buffer, Logger, Message

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messagesArray<Message> (readonly)

Returns the messages this parser found in the given log.

Returns:

  • (Array<Message>)

    the messages this parser found in the given log.


14
15
16
# File 'lib/log_parser/log_parser.rb', line 14

def messages
  @messages
end

#scope_changes_by_lineHash<Integer, Array<String>> (readonly)

The parser keeps a record of the scope changes it detects.

Note: Only available in debug mode; see Logger.

The keys are line indices. The values are arrays of strings, with one string per scope change, in the same order as in the original line.

* Entering a new scope is denoted by

   ```
   push filename
   ```
  and
* leaving a scope by

   ```
   pop  filename
   ```
   Note the extra space after `pop` here; it's there for quaint cosmetic reasons.

Returns:

  • (Hash<Integer, Array<String>>)

    the scope changes this parser detected in the given log.


38
39
40
# File 'lib/log_parser/log_parser.rb', line 38

def 
  @scope_changes_by_line
end

Instance Method Details

#parseArray<Message>

Parses the given log lines and extracts all messages (of known form).

Returns:


42
43
44
45
46
47
48
49
50
51
# File 'lib/log_parser/log_parser.rb', line 42

def parse
  skip_empty_lines
  until empty?
    parse_next_lines
    skip_empty_lines
  end

  # TODO: Remove duplicates?
  @messages
end