OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'package:logging/logging.dart'; | 7 import 'package:logging/logging.dart'; |
8 import 'package:observatory/models.dart' as M; | 8 import 'package:observatory/models.dart' as M; |
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 M.EventRepository _events; | 21 M.EventRepository _events; |
22 StreamSubscription _subscription; | 22 StreamSubscription _subscription; |
23 Level _level = Level.ALL; | 23 Level _level = Level.ALL; |
24 final _logs = <Map>[]; | 24 final _logs = <Map>[]; |
25 | 25 |
26 M.IsolateRef get isolate => _isolate; | 26 M.IsolateRef get isolate => _isolate; |
27 Level get level => _level; | 27 Level get level => _level; |
28 | 28 |
29 set level(Level value) => _level = _r.checkAndReact(_level, value); | 29 set level(Level value) => _level = _r.checkAndReact(_level, value); |
30 | 30 |
31 factory LoggingListElement(M.IsolateRef isolate, | 31 factory LoggingListElement(M.IsolateRef isolate, M.EventRepository events, |
32 M.EventRepository events, | 32 {RenderingQueue queue}) { |
33 {RenderingQueue queue}) { | |
34 assert(isolate != null); | 33 assert(isolate != null); |
35 assert(events != null); | 34 assert(events != null); |
36 LoggingListElement e = document.createElement(tag.name); | 35 LoggingListElement e = document.createElement(tag.name); |
37 e._r = new RenderingScheduler(e, queue: queue); | 36 e._r = new RenderingScheduler(e, queue: queue); |
38 e._isolate = isolate; | 37 e._isolate = isolate; |
39 e._events = events; | 38 e._events = events; |
40 return e; | 39 return e; |
41 } | 40 } |
42 | 41 |
43 LoggingListElement.created() : super.created(); | 42 LoggingListElement.created() : super.created(); |
(...skipping 14 matching lines...) Expand all Loading... |
58 | 57 |
59 @override | 58 @override |
60 detached() { | 59 detached() { |
61 super.detached(); | 60 super.detached(); |
62 _r.disable(notify: true); | 61 _r.disable(notify: true); |
63 children = []; | 62 children = []; |
64 _subscription.cancel(); | 63 _subscription.cancel(); |
65 } | 64 } |
66 | 65 |
67 void render() { | 66 void render() { |
68 children = _logs.where(_shouldBeVisible).map((logRecord) => | 67 children = _logs |
69 new DivElement()..classes = ['logItem', logRecord['level'].name] | 68 .where(_shouldBeVisible) |
70 ..children = [ | 69 .map((logRecord) => new DivElement() |
71 new SpanElement()..classes = ['level'] | 70 ..classes = ['logItem', logRecord['level'].name] |
72 ..text = logRecord['level'].name, | 71 ..children = [ |
73 new SpanElement()..classes = ['time'] | 72 new SpanElement() |
74 ..text = Utils.formatDateTime(logRecord['time']), | 73 ..classes = ['level'] |
75 new SpanElement()..classes = ['message'] | 74 ..text = logRecord['level'].name, |
76 ..text = logRecord["message"].valueAsString | 75 new SpanElement() |
77 ] | 76 ..classes = ['time'] |
78 ).toList(); | 77 ..text = Utils.formatDateTime(logRecord['time']), |
| 78 new SpanElement() |
| 79 ..classes = ['message'] |
| 80 ..text = logRecord["message"].valueAsString |
| 81 ]) |
| 82 .toList(); |
79 } | 83 } |
80 | 84 |
81 bool _shouldBeVisible(Map record) => _level.compareTo(record['level']) <= 0; | 85 bool _shouldBeVisible(Map record) => _level.compareTo(record['level']) <= 0; |
82 } | 86 } |
OLD | NEW |