class BulletLogParser::Parser
bullert log persing class
Constants
- REGEX_CALL_STACK
- REGEX_DETAIL
- REGEX_LINE1
Attributes
ast[R]
Public Class Methods
new()
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 10 def initialize @parse_method = :parse_line1 @ast = { details: [], stack: [] } @state = nil end
Public Instance Methods
completed?()
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 29 def completed? @state == :completed end
failed?()
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 21 def failed? @state == :failed end
puts(str)
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 33 def puts(str) perse_proc = method(@parse_method).curry perse_proc.call(str) end
terminated?()
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 25 def terminated? @state != nil end
Private Instance Methods
change_state_completed()
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 44 def change_state_completed @state = :completed end
change_state_failed()
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 40 def change_state_failed @state = :failed end
parse_line1(str)
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 48 def parse_line1(str) matched = REGEX_LINE1.match(str) return change_state_failed unless matched @parse_method = :parse_line2 @ast.update({ detectedAt: matched[1], level: matched[2], user: matched[3] }) end
parse_line2(str)
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 60 def parse_line2(str) @parse_method = :parse_line_detector return if str.empty? @ast.update({ request: str }) end
parse_line_call_stack_detail(str)
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 92 def parse_line_call_stack_detail(str) return change_state_completed if str.empty? matched = REGEX_CALL_STACK.match(str) return change_state_failed unless matched @ast[:stack] << { filename: matched[1], lineno: matched[2].to_i, message: matched[3] } end
parse_line_detector(str)
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 67 def parse_line_detector(str) @parse_method = :parse_line_detector_detail return change_state_failed if str.empty? @ast.update({ detection: str, details: [], stack: [] }) end
parse_line_detector_detail(str)
click to toggle source
# File lib/bullet_log_parser/parser.rb, line 78 def parse_line_detector_detail(str) if str == 'Call stack' @parse_method = :parse_line_call_stack_detail return end return change_state_completed if str.empty? matched = REGEX_DETAIL.match(str) return change_state_failed unless matched @ast[:details] << matched[1] end