@@ -113,7 +113,7 @@ def allocate_color(tag):
113113 "F" : "%s%s%s " % (format (fg = BLACK , bg = RED ), "F" .center (PRIORITY_WIDTH ), format (reset = True )),
114114}
115115
116- redetail = re .compile ("^([0-9]+-[0-9]+ [0-9\:\.]+)\s+([0-9]+)\s+([0-9]+) ([A-Z ]) ([^\:]+) \: (.*)$" )
116+ redetail = re .compile ("^([0-9]+-[0-9]+ [0-9\:\.]+)\s+([0-9]+)\s+([0-9]+) ([\sVDIWEF\s ]) ([\S]*)\s* \: (.*)$" )
117117retag = re .compile ("^([A-Z])/([^\(]+)\(([^\)]+)\): (.*)$" )
118118retime = re .compile ("(?:(\d+)s)?([\d.]+)\dms" )
119119reproc = re .compile (r"^I/ActivityManager.*?: Start proc .*?: pid=(\d+) uid=(\d+)" )
@@ -143,6 +143,9 @@ def millis_color(match):
143143 input = sys .stdin
144144
145145while True :
146+ line_header_size = HEADER_SIZE
147+ line_tag_width = TAG_WIDTH
148+
146149 try :
147150 line = input .readline ()
148151 except KeyboardInterrupt :
@@ -162,6 +165,9 @@ def millis_color(match):
162165 continue
163166
164167 time , ppid , process , priority , tag , message = match .groups ()
168+ if (len (tag ) > line_tag_width ):
169+ line_tag_width = len (tag )
170+ line_header_size = TIME_WIDTH + PPID_WIDTH + USER_WIDTH + PROCESS_WIDTH + line_tag_width + PRIORITY_WIDTH + 6
165171 linebuf = StringIO .StringIO ()
166172
167173 tag = tag .strip ()
@@ -195,14 +201,14 @@ def millis_color(match):
195201 # right-align tag title and allocate color if needed
196202 tag = tag .strip ()
197203 if "avc: denied" in message :
198- tag = tag [- TAG_WIDTH :].rjust (TAG_WIDTH )
204+ tag = tag [- line_tag_width :].rjust (line_tag_width )
199205 linebuf .write ("%s%s%s " % (format (fg = WHITE , bg = RED , dim = False ), tag , format (reset = True )))
200206 elif tag in HIGHLIGHT :
201- tag = tag [- TAG_WIDTH :].rjust (TAG_WIDTH )
207+ tag = tag [- line_tag_width :].rjust (line_tag_width )
202208 linebuf .write ("%s%s%s " % (format (fg = BLACK , bg = WHITE , dim = False ), tag , format (reset = True )))
203209 else :
204210 color = allocate_color (tag )
205- tag = tag [- TAG_WIDTH :].rjust (TAG_WIDTH )
211+ tag = tag [- line_tag_width :].rjust (line_tag_width )
206212 linebuf .write ("%s%s%s " % (format (fg = color , dim = False ), tag , format (reset = True )))
207213
208214 # write out tagtype colored edge
@@ -216,7 +222,7 @@ def millis_color(match):
216222 message = retime .sub (millis_color , message )
217223
218224 # insert line wrapping as needed
219- message = indent_wrap (message , HEADER_SIZE , WIDTH )
225+ message = indent_wrap (message , line_header_size , WIDTH )
220226
221227 linebuf .write (message )
222228 print linebuf .getvalue ()
0 commit comments