| OLD | NEW | 
|---|
| 1 # Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 
| 2 # | 2 # | 
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without | 
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are | 
| 5 # met: | 5 # met: | 
| 6 # | 6 # | 
| 7 #     * Redistributions of source code must retain the above copyright | 7 #     * Redistributions of source code must retain the above copyright | 
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. | 
| 9 #     * Redistributions in binary form must reproduce the above | 9 #     * Redistributions in binary form must reproduce the above | 
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 98         if self._last_partial_line: | 98         if self._last_partial_line: | 
| 99             self._erase_last_partial_line() | 99             self._erase_last_partial_line() | 
| 100         if self._verbose: | 100         if self._verbose: | 
| 101             now_tuple = time.localtime(now) | 101             now_tuple = time.localtime(now) | 
| 102             msg = '%02d:%02d:%02d.%03d %d %s' % (now_tuple.tm_hour, now_tuple.tm
     _min, now_tuple.tm_sec, int((now * 1000) % 1000), pid, self._ensure_newline(txt)
     ) | 102             msg = '%02d:%02d:%02d.%03d %d %s' % (now_tuple.tm_hour, now_tuple.tm
     _min, now_tuple.tm_sec, int((now * 1000) % 1000), pid, self._ensure_newline(txt)
     ) | 
| 103         elif self._isatty: | 103         elif self._isatty: | 
| 104             msg = txt | 104             msg = txt | 
| 105         else: | 105         else: | 
| 106             msg = self._ensure_newline(txt) | 106             msg = self._ensure_newline(txt) | 
| 107 | 107 | 
| 108         self._stream.write(msg) | 108         self._stream.write(msg.decode('ascii', errors='replace')) | 
| 109 | 109 | 
| 110     def writeln(self, txt, now=None, pid=None): | 110     def writeln(self, txt, now=None, pid=None): | 
| 111         self.write(self._ensure_newline(txt), now, pid) | 111         self.write(self._ensure_newline(txt), now, pid) | 
| 112 | 112 | 
| 113     def _erase_last_partial_line(self): | 113     def _erase_last_partial_line(self): | 
| 114         num_chars = len(self._last_partial_line) | 114         num_chars = len(self._last_partial_line) | 
| 115         self._stream.write(self._erasure(self._last_partial_line)) | 115         self._stream.write(self._erasure(self._last_partial_line)) | 
| 116         self._last_partial_line = '' | 116         self._last_partial_line = '' | 
| 117 | 117 | 
| 118     def flush(self): | 118     def flush(self): | 
| 119         if self._last_partial_line: | 119         if self._last_partial_line: | 
| 120             self._stream.write('\n') | 120             self._stream.write('\n') | 
| 121             self._last_partial_line = '' | 121             self._last_partial_line = '' | 
| 122             self._stream.flush() | 122             self._stream.flush() | 
| 123 | 123 | 
| 124     def number_of_columns(self): | 124     def number_of_columns(self): | 
| 125         return self._number_of_columns | 125         return self._number_of_columns | 
| 126 | 126 | 
| 127 | 127 | 
| 128 class _LogHandler(logging.Handler): | 128 class _LogHandler(logging.Handler): | 
| 129     def __init__(self, meter): | 129     def __init__(self, meter): | 
| 130         logging.Handler.__init__(self) | 130         logging.Handler.__init__(self) | 
| 131         self._meter = meter | 131         self._meter = meter | 
| 132         self.name = LOG_HANDLER_NAME | 132         self.name = LOG_HANDLER_NAME | 
| 133 | 133 | 
| 134     def emit(self, record): | 134     def emit(self, record): | 
| 135         self._meter.writeln(record.getMessage(), record.created, record.process) | 135         self._meter.writeln(record.getMessage(), record.created, record.process) | 
| OLD | NEW | 
|---|