Class: PostgreSQLParser
- Inherits:
-
Object
show all
- Defined in:
- lib/pqa.rb
Constant Summary
collapse
- LOG_OR_DEBUG_LINE =
Regexp.new("^(LOG|DEBUG):[\s]*")
- QUERY_STARTER =
Regexp.new("^(query|statement):[\s]*")
- STATUS =
Regexp.new("^(connection|received|unexpected EOF)")
- DURATION =
Regexp.new('^duration:([\s\d\.]*)(sec|ms)')
- CONTINUATION_LINE =
/^(\^I|\s|\t)/
- CONTEXT_LINE =
/^CONTEXT:[\s]*/
- ERROR_LINE =
/^(WARNING|ERROR|FATAL|PANIC):[\s]*/
- HINT_LINE =
/^HINT:[\s]*/
- DETAIL_LINE =
/^DETAIL:[\s]*/
- STATEMENT_LINE =
/^STATEMENT:[\s]*/
Instance Method Summary
collapse
Instance Method Details
#parse(text) ⇒ Object
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
# File 'lib/pqa.rb', line 436
def parse(text)
logdebug_match = LOG_OR_DEBUG_LINE.match(text)
if logdebug_match
query_match = QUERY_STARTER.match(logdebug_match.post_match)
if query_match
return PGQueryStarter.new(query_match.post_match)
end
duration_match = DURATION.match(logdebug_match.post_match)
if duration_match
additionnal_info = duration_match.post_match.strip.chomp
if additionnal_info == ""
return PGDurationLine.new(duration_match[1].strip, duration_match[2])
else
return PGQueryStarterWithDuration.new(additionnal_info, duration_match[1].strip, duration_match[2])
end
end
status_match = STATUS.match(logdebug_match.post_match)
if status_match
return PGStatusLine.new(logdebug_match.post_match)
end
return nil
end
error_match = ERROR_LINE.match(text)
if error_match
return PGErrorLine.new(error_match.post_match)
end
context_match = CONTEXT_LINE.match(text)
if context_match
return PGContextLine.new(context_match.post_match)
end
continuation_match = CONTINUATION_LINE.match(text)
if continuation_match
return PGContinuationLine.new(continuation_match.post_match)
end
statement_match = STATEMENT_LINE.match(text)
if statement_match
return PGStatementLine.new(statement_match.post_match)
end
hint_match = HINT_LINE.match(text)
if hint_match
return PGHintLine.new(hint_match.post_match)
end
detail_match = DETAIL_LINE.match(text)
if detail_match
return PGDetailLine.new(detail_match.post_match)
end
if text.strip.chomp == ""
return PGContinuationLine.new("")
end
return nil
end
|