| Index: telemetry/telemetry/internal/util/log_stream.py
|
| diff --git a/telemetry/telemetry/internal/util/log_stream.py b/telemetry/telemetry/internal/util/log_stream.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b05836e3f19833e1c9915fae8892d055a50b7fe4
|
| --- /dev/null
|
| +++ b/telemetry/telemetry/internal/util/log_stream.py
|
| @@ -0,0 +1,28 @@
|
| +# Copyright 2017 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import cStringIO
|
| +
|
| +
|
| +_LOG_STREAM = None
|
| +
|
| +
|
| +def InitiateLogStream():
|
| + global _LOG_STREAM
|
| + assert _LOG_STREAM is None, 'Already initialized'
|
| + _LOG_STREAM = cStringIO.StringIO()
|
| + return _LOG_STREAM
|
| +
|
| +
|
| +def TruncateLogStream():
|
| + if not _LOG_STREAM:
|
| + return
|
| + _LOG_STREAM.truncate(0)
|
| +
|
| +
|
| +def FlushLogStream(outstream):
|
| + if not _LOG_STREAM:
|
| + return
|
| + print >> outstream, _LOG_STREAM.getvalue()
|
| + TruncateLogStream()
|
|
|