Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1812)

Unified Diff: telemetry/telemetry/internal/util/log_stream.py

Issue 2997373002: WIP to improve Telemetry logging
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « telemetry/telemetry/internal/story_runner.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « telemetry/telemetry/internal/story_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698