Rename parse_message_line to parse_log_line
This commit is contained in:
parent
377b58f1e8
commit
9f1c0c3d54
3 changed files with 8 additions and 8 deletions
|
@ -51,7 +51,7 @@ class LogMessage(LogItem):
|
||||||
nb_lines, message)
|
nb_lines, message)
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
|
|
||||||
def parse_message_line(msg):
|
def parse_log_line(msg):
|
||||||
match = re.match(MESSAGE_LOG_RE, msg)
|
match = re.match(MESSAGE_LOG_RE, msg)
|
||||||
if match:
|
if match:
|
||||||
return LogMessage(*match.groups())
|
return LogMessage(*match.groups())
|
||||||
|
@ -188,7 +188,7 @@ class Logger(object):
|
||||||
idx += 1
|
idx += 1
|
||||||
log.debug('fail?')
|
log.debug('fail?')
|
||||||
continue
|
continue
|
||||||
log_item = parse_message_line(lines[idx])
|
log_item = parse_log_line(lines[idx])
|
||||||
idx += 1
|
idx += 1
|
||||||
if not isinstance(log_item, LogItem):
|
if not isinstance(log_item, LogItem):
|
||||||
log.debug('wrong log format? %s', log_item)
|
log.debug('wrong log format? %s', log_item)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
A simple script to parse and output logs from a poezio logfile
|
A simple script to parse and output logs from a poezio logfile
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from poezio.logger import LogInfo, LogMessage, parse_message_line
|
from poezio.logger import LogInfo, LogMessage, parse_log_line
|
||||||
from functools import singledispatch
|
from functools import singledispatch
|
||||||
from poezio import poopt
|
from poezio import poopt
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -71,7 +71,7 @@ def parse_messages(fd):
|
||||||
elif in_text:
|
elif in_text:
|
||||||
more_lines.append(line[1:])
|
more_lines.append(line[1:])
|
||||||
continue
|
continue
|
||||||
current_log = parse_message_line(line)
|
current_log = parse_log_line(line)
|
||||||
in_text = True
|
in_text = True
|
||||||
print_log(current_log, more_lines)
|
print_log(current_log, more_lines)
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,14 @@ Test the functions in the `logger` module
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from poezio.logger import LogInfo, LogMessage, parse_message_line
|
from poezio.logger import LogInfo, LogMessage, parse_log_line
|
||||||
|
|
||||||
def test_parse_message():
|
def test_parse_message():
|
||||||
line = 'MR 20170909T09:09:09Z 000 <nick> body'
|
line = 'MR 20170909T09:09:09Z 000 <nick> body'
|
||||||
assert vars(parse_message_line(line)) == vars(LogMessage('2017', '09', '09', '09', '09', '09', '0', 'nick', 'body'))
|
assert vars(parse_log_line(line)) == vars(LogMessage('2017', '09', '09', '09', '09', '09', '0', 'nick', 'body'))
|
||||||
|
|
||||||
line = '<>'
|
line = '<>'
|
||||||
assert parse_message_line(line) == None
|
assert parse_log_line(line) == None
|
||||||
|
|
||||||
line = 'MR 20170908T07:05:04Z 003 <nick> '
|
line = 'MR 20170908T07:05:04Z 003 <nick> '
|
||||||
assert vars(parse_message_line(line)) == vars(LogMessage('2017', '09', '08', '07', '05', '04', '003', 'nick', ''))
|
assert vars(parse_log_line(line)) == vars(LogMessage('2017', '09', '08', '07', '05', '04', '003', 'nick', ''))
|
||||||
|
|
Loading…
Reference in a new issue