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

Unified Diff: pkg/analysis_server/test/stress/utilities/logger.dart

Issue 2611593002: Rework the replay test to be more correct (Closed)
Patch Set: Created 3 years, 12 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
Index: pkg/analysis_server/test/stress/utilities/logger.dart
diff --git a/pkg/analysis_server/test/stress/utilities/logger.dart b/pkg/analysis_server/test/stress/utilities/logger.dart
new file mode 100644
index 0000000000000000000000000000000000000000..acf7a742baefc188eec1b678176ff78775e44a2e
--- /dev/null
+++ b/pkg/analysis_server/test/stress/utilities/logger.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * A utility class used to write logging information during a test.
+ */
+class Logger {
+ /**
+ * The width of the field in which labels are printed.
+ */
+ static const int _labelWidth = 8;
+
+ /**
+ * The separator used to separate the label from the content.
+ */
+ static const String _separator = ' : ';
+
+ /**
+ * The sink to which the logged information should be written.
+ */
+ final StringSink sink;
+
+ /**
+ * Initialize a newly created logger to write to the given [sink].
+ */
+ Logger(this.sink);
+
+ /**
+ * Log the given information.
+ *
+ * The [label] is used to indicate the kind of information being logged, while
+ * the [content] contains the actual information. If a list of [arguments] is
+ * provided, then they will be written after the content.
+ */
+ void log(String label, String content, {List<String> arguments = null}) {
+ for (int i = _labelWidth - label.length; i > 0; i--) {
+ sink.write(' ');
+ }
+ sink.write(label);
+ sink.write(_separator);
+ sink.write(content);
+ arguments?.forEach((String argument) {
+ sink.write(' ');
+ sink.write(argument);
+ });
+ sink.writeln();
+ }
+}
« no previous file with comments | « pkg/analysis_server/test/stress/utilities/git.dart ('k') | pkg/analysis_server/test/stress/utilities/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698