def memory(self): """Return an estimate of how much memory is used for the log. 32 bytes of header + 8 bytes for the pointer + the length of the tag and the text.
This ignores the overhead of the list of log lines itself.""" return32 + 8 + len(self.tag) + 1 + len(self.text) + 1
def ParseLogcat(f, processes, duration=None):
previous = None for logLine in ParseLogcatInner(f, processes, duration): if logLine.tag == "chatty"and logLine.level == "I":
m = CHATTY_IDENTICAL.match(logLine.text) if m: for i in range(int(m.group(1))):
clone = previous.clone()
clone.timestamp = logLine.timestamp yield clone continue
previous = logLine yield logLine
def ParseLogcatInner(f, processes, duration=None): """Parses a file object containing log text and returns a list of LogLine objects."""
result = []
state = STATE_BEGIN
logLine = None
previous = None
if duration:
endTime = datetime.datetime.now() + datetime.timedelta(seconds=duration)
# TODO: use a nonblocking / timeout read so we stop if there are # no logs coming out (haha joke, right!) for line in f: if duration and endTime <= datetime.datetime.now(): break
if len(line) > 0and line[-1] == '\n':
line = line[0:-1]
m = BUFFER_BEGIN.match(line) if m: if logLine: yield logLine
logLine = None
buf = m.group(1)
state = STATE_BUFFER continue
m = BUFFER_SWITCH.match(line) if m: if logLine: yield logLine
logLine = None
buf = m.group(1)
state = STATE_BUFFER continue
m = HEADER.match(line) if m: if logLine: yield logLine
logLine = LogLine(
buf=buf,
timestamp=m.group(1),
uid=m.group(2),
pid=m.group(3),
tid=m.group(4),
level=m.group(5),
tag=m.group(6)
)
previous = logLine
logLine.process = processes.FindPid(logLine.pid, logLine.uid)
state = STATE_HEADER continue
m = HEADER_TYPE2.match(line) if m: if logLine: yield logLine
logLine = LogLine(
buf=buf,
timestamp=m.group(1),
uid="0",
pid=m.group(2),
tid=m.group(3),
level=m.group(4),
tag=m.group(5),
text=m.group(6)
)
previous = logLine
logLine.process = processes.FindPid(logLine.pid, logLine.uid)
state = STATE_BEGIN continue
ifnot len(line): if state == STATE_BLANK: if logLine:
logLine.text += "\n"
state = STATE_BLANK continue
if logLine: if state == STATE_HEADER:
logLine.text += line elif state == STATE_TEXT:
logLine.text += "\n"
logLine.text += line elif state == STATE_BLANK: if len(logLine.text):
logLine.text += "\n"
logLine.text += "\n"
logLine.text += line
state = STATE_TEXT
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.