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

Unified Diff: runtime/observatory/lib/src/elements/logging_list.dart

Issue 2299893003: Converted Observatory logging-page element (Closed)
Patch Set: Updated observatory_sources.gypi Created 4 years, 3 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: runtime/observatory/lib/src/elements/logging_list.dart
diff --git a/runtime/observatory/lib/src/elements/logging_list.dart b/runtime/observatory/lib/src/elements/logging_list.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b1dcb55473cd674dd814d59e71839f6c8ed74022
--- /dev/null
+++ b/runtime/observatory/lib/src/elements/logging_list.dart
@@ -0,0 +1,84 @@
+// Copyright (c) 2015, 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.
+
+library logging_page;
+
+import 'dart:async';
+import 'dart:html';
+import 'package:logging/logging.dart';
+import 'package:observatory/models.dart' as M;
+import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
+import 'package:observatory/src/elements/helpers/tag.dart';
+import 'package:observatory/utils.dart';
+
+class LoggingListElement extends HtmlElement implements Renderable {
+ static const tag = const Tag<LoggingListElement>('logging-list');
+
+ RenderingScheduler<LoggingListElement> _r;
+
+ Stream<RenderedEvent<LoggingListElement>> get onRendered => _r.onRendered;
+
+ M.IsolateRef _isolate;
+ M.EventRepository _events;
+ StreamSubscription _subscription;
+ Level _level = Level.ALL;
+ final _logs = <Map>[];
+
+ M.IsolateRef get isolate => _isolate;
+ Level get level => _level;
+
+ set level(Level value) => _level = _r.checkAndReact(_level, value);
+
+ factory LoggingListElement(M.IsolateRef isolate,
+ M.EventRepository events,
+ {RenderingQueue queue}) {
+ assert(isolate != null);
+ assert(events != null);
+ LoggingListElement e = document.createElement(tag.name);
+ e._r = new RenderingScheduler(e, queue: queue);
+ e._isolate = isolate;
+ e._events = events;
+ return e;
+ }
+
+ LoggingListElement.created() : super.created();
+
+ @override
+ attached() {
+ super.attached();
+ _r.enable();
+ _subscription = _events.onLoggingEvent.listen((e) {
+ if (e.isolate.id == _isolate.id) {
+ _logs.add(e.logRecord);
+ if (_shouldBeVisible(_logs.last)) {
+ _r.dirty();
+ }
+ }
+ });
+ }
+
+ @override
+ detached() {
+ super.detached();
+ _r.disable(notify: true);
+ children = [];
+ _subscription.cancel();
+ }
+
+ void render() {
+ children = _logs.where(_shouldBeVisible).map((logRecord) =>
+ new DivElement()..classes = ['logItem', logRecord['level'].name]
+ ..children = [
+ new SpanElement()..classes = ['level']
+ ..text = logRecord['level'].name,
+ new SpanElement()..classes = ['time']
+ ..text = Utils.formatDateTime(logRecord['time']),
+ new SpanElement()..classes = ['message']
+ ..text = logRecord["message"].valueAsString
+ ]
+ ).toList();
+ }
+
+ bool _shouldBeVisible(Map record) => _level.compareTo(record['level']) <= 0;
+}
« no previous file with comments | « runtime/observatory/lib/src/elements/logging.html ('k') | runtime/observatory/lib/src/models/objects/event.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698