More log tweaks
This commit is contained in:
parent
e4bad8007f
commit
a4d34358fe
1 changed files with 7 additions and 6 deletions
|
|
@ -390,17 +390,18 @@ class EvenniaLogFile(logfile.LogFile):
|
||||||
**kwargs: same kwargs as file.readlines
|
**kwargs: same kwargs as file.readlines
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Generator: lines from our _file attribute.
|
lines (list): lines from our _file attribute.
|
||||||
"""
|
"""
|
||||||
|
lines = []
|
||||||
for line in self._file.readlines(*args, **kwargs):
|
for line in self._file.readlines(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
lin = line.decode("utf-8")
|
lines.append(line.decode("utf-8"))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
try:
|
try:
|
||||||
lin = str(lin)
|
lines.append(str(line))
|
||||||
except Exception:
|
except Exception:
|
||||||
lin = ""
|
lines.append("")
|
||||||
yield lin
|
return lines
|
||||||
|
|
||||||
|
|
||||||
_LOG_FILE_HANDLES = {} # holds open log handles
|
_LOG_FILE_HANDLES = {} # holds open log handles
|
||||||
|
|
@ -519,7 +520,7 @@ def tail_log_file(filename, offset, nlines, callback=None):
|
||||||
lines_found = filehandle.readlines()
|
lines_found = filehandle.readlines()
|
||||||
block_count -= 1
|
block_count -= 1
|
||||||
# return the right number of lines
|
# return the right number of lines
|
||||||
lines_found = lines_found[-nlines - offset : -offset if offset else None]
|
lines_found = lines_found[-nlines - offset: -offset if offset else None]
|
||||||
if callback:
|
if callback:
|
||||||
callback(lines_found)
|
callback(lines_found)
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue