OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import cStringIO |
| 6 |
| 7 |
| 8 _LOG_STREAM = None |
| 9 |
| 10 |
| 11 def InitiateLogStream(): |
| 12 global _LOG_STREAM |
| 13 assert _LOG_STREAM is None, 'Already initialized' |
| 14 _LOG_STREAM = cStringIO.StringIO() |
| 15 return _LOG_STREAM |
| 16 |
| 17 |
| 18 def TruncateLogStream(): |
| 19 if not _LOG_STREAM: |
| 20 return |
| 21 _LOG_STREAM.truncate(0) |
| 22 |
| 23 |
| 24 def FlushLogStream(outstream): |
| 25 if not _LOG_STREAM: |
| 26 return |
| 27 print >> outstream, _LOG_STREAM.getvalue() |
| 28 TruncateLogStream() |
OLD | NEW |