Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions coloredlogcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# written by jeff sharkey, http://jsharkey.org/
# piping detection and popen() added by other android team members

import os, sys, re, StringIO
import os, sys, re, io
import fcntl, termios, struct

# List of tags to highlight (inverted)
Expand All @@ -46,7 +46,7 @@
data = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, '1234')
HEIGHT, WIDTH = struct.unpack('hh',data)

BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = list(range(8))

def format(fg=None, bg=None, bright=False, bold=False, dim=False, reset=False):
# manually derived from http://en.wikipedia.org/wiki/ANSI_escape_code#Codes
Expand All @@ -65,7 +65,7 @@ def format(fg=None, bg=None, bright=False, bold=False, dim=False, reset=False):

def indent_wrap(message, indent=0, width=80):
wrap_area = width - indent
messagebuf = StringIO.StringIO()
messagebuf = io.StringIO()
current = 0
while current < len(message):
next = min(current + wrap_area, len(message))
Expand Down Expand Up @@ -155,11 +155,11 @@ def millis_color(match):

match = retag.match(line)
if not match:
print line
print(line)
continue

priority, tag, process, message = match.groups()
linebuf = StringIO.StringIO()
linebuf = io.StringIO()

tag = tag.strip()
if tag in IGNORED: continue
Expand Down Expand Up @@ -195,7 +195,7 @@ def millis_color(match):

# write out tagtype colored edge
if not priority in PRIORITIES:
print line
print(line)
continue

linebuf.write(PRIORITIES[priority])
Expand All @@ -207,4 +207,4 @@ def millis_color(match):
message = indent_wrap(message, HEADER_SIZE, WIDTH)

linebuf.write(message)
print linebuf.getvalue()
print(linebuf.getvalue())