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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 1241683005: Support piping log data over the service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of service; 5 part of service;
6 6
7 /// Helper function for canceling a Future<StreamSubscription>. 7 /// Helper function for canceling a Future<StreamSubscription>.
8 Future cancelFutureSubscription( 8 Future cancelFutureSubscription(
9 Future<StreamSubscription> subscriptionFuture) async { 9 Future<StreamSubscription> subscriptionFuture) async {
10 if (subscriptionFuture != null) { 10 if (subscriptionFuture != null) {
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // A map from stream id to event stream state. 693 // A map from stream id to event stream state.
694 Map<String,_EventStreamState> _eventStreams = {}; 694 Map<String,_EventStreamState> _eventStreams = {};
695 695
696 // Well-known stream ids. 696 // Well-known stream ids.
697 static const kIsolateStream = 'Isolate'; 697 static const kIsolateStream = 'Isolate';
698 static const kDebugStream = 'Debug'; 698 static const kDebugStream = 'Debug';
699 static const kGCStream = 'GC'; 699 static const kGCStream = 'GC';
700 static const kStdoutStream = 'Stdout'; 700 static const kStdoutStream = 'Stdout';
701 static const kStderrStream = 'Stderr'; 701 static const kStderrStream = 'Stderr';
702 static const _kGraphStream = '_Graph'; 702 static const _kGraphStream = '_Graph';
703 static const kLoggingStream = '_Logging';
703 704
704 /// Returns a single-subscription Stream object for a VM event stream. 705 /// Returns a single-subscription Stream object for a VM event stream.
705 Future<Stream> getEventStream(String streamId) async { 706 Future<Stream> getEventStream(String streamId) async {
706 var eventStream = _eventStreams.putIfAbsent( 707 var eventStream = _eventStreams.putIfAbsent(
707 streamId, () => new _EventStreamState( 708 streamId, () => new _EventStreamState(
708 this, streamId, () => _eventStreams.remove(streamId))); 709 this, streamId, () => _eventStreams.remove(streamId)));
709 return eventStream.addStream(); 710 return eventStream.addStream();
710 } 711 }
711 712
712 /// Helper function for listening to an event stream. 713 /// Helper function for listening to an event stream.
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 message = map['message']; 1585 message = map['message'];
1585 exception = new ServiceObject._fromMap(owner, map['exception']); 1586 exception = new ServiceObject._fromMap(owner, map['exception']);
1586 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); 1587 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']);
1587 name = 'DartError($message)'; 1588 name = 'DartError($message)';
1588 vmName = name; 1589 vmName = name;
1589 } 1590 }
1590 1591
1591 String toString() => 'DartError($message)'; 1592 String toString() => 'DartError($message)';
1592 } 1593 }
1593 1594
1595 Level _findLogLevel(int value) {
1596 for (var level in Level.LEVELS) {
1597 if (level.value == value) {
1598 return level;
1599 }
1600 }
1601 return new Level('$value', value);
1602 }
1603
1594 /// A [ServiceEvent] is an asynchronous event notification from the vm. 1604 /// A [ServiceEvent] is an asynchronous event notification from the vm.
1595 class ServiceEvent extends ServiceObject { 1605 class ServiceEvent extends ServiceObject {
1596 /// The possible 'kind' values. 1606 /// The possible 'kind' values.
1597 static const kIsolateStart = 'IsolateStart'; 1607 static const kIsolateStart = 'IsolateStart';
1598 static const kIsolateExit = 'IsolateExit'; 1608 static const kIsolateExit = 'IsolateExit';
1599 static const kIsolateUpdate = 'IsolateUpdate'; 1609 static const kIsolateUpdate = 'IsolateUpdate';
1600 static const kPauseStart = 'PauseStart'; 1610 static const kPauseStart = 'PauseStart';
1601 static const kPauseExit = 'PauseExit'; 1611 static const kPauseExit = 'PauseExit';
1602 static const kPauseBreakpoint = 'PauseBreakpoint'; 1612 static const kPauseBreakpoint = 'PauseBreakpoint';
1603 static const kPauseInterrupted = 'PauseInterrupted'; 1613 static const kPauseInterrupted = 'PauseInterrupted';
1604 static const kPauseException = 'PauseException'; 1614 static const kPauseException = 'PauseException';
1605 static const kResume = 'Resume'; 1615 static const kResume = 'Resume';
1606 static const kBreakpointAdded = 'BreakpointAdded'; 1616 static const kBreakpointAdded = 'BreakpointAdded';
1607 static const kBreakpointResolved = 'BreakpointResolved'; 1617 static const kBreakpointResolved = 'BreakpointResolved';
1608 static const kBreakpointRemoved = 'BreakpointRemoved'; 1618 static const kBreakpointRemoved = 'BreakpointRemoved';
1609 static const kGraph = '_Graph'; 1619 static const kGraph = '_Graph';
1610 static const kGC = 'GC'; 1620 static const kGC = 'GC';
1611 static const kInspect = 'Inspect'; 1621 static const kInspect = 'Inspect';
1612 static const kDebuggerSettingsUpdate = '_DebuggerSettingsUpdate'; 1622 static const kDebuggerSettingsUpdate = '_DebuggerSettingsUpdate';
1613 static const kConnectionClosed = 'ConnectionClosed'; 1623 static const kConnectionClosed = 'ConnectionClosed';
1624 static const kLogging = '_Logging';
1614 1625
1615 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); 1626 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner);
1616 1627
1617 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { 1628 ServiceEvent.connectionClosed(this.reason) : super._empty(null) {
1618 kind = kConnectionClosed; 1629 kind = kConnectionClosed;
1619 } 1630 }
1620 1631
1621 @observable String kind; 1632 @observable String kind;
1622 @observable Breakpoint breakpoint; 1633 @observable Breakpoint breakpoint;
1623 @observable Frame topFrame; 1634 @observable Frame topFrame;
1624 @observable Instance exception; 1635 @observable Instance exception;
1625 @observable Instance asyncContinuation; 1636 @observable Instance asyncContinuation;
1626 @observable ServiceObject inspectee; 1637 @observable ServiceObject inspectee;
1627 @observable ByteData data; 1638 @observable ByteData data;
1628 @observable int count; 1639 @observable int count;
1629 @observable String reason; 1640 @observable String reason;
1630 @observable String exceptions; 1641 @observable String exceptions;
1631 @observable String bytesAsString; 1642 @observable String bytesAsString;
1643 @observable Map logRecord;
1632 int chunkIndex, chunkCount, nodeCount; 1644 int chunkIndex, chunkCount, nodeCount;
1633 1645
1634 @observable bool get isPauseEvent { 1646 @observable bool get isPauseEvent {
1635 return (kind == kPauseStart || 1647 return (kind == kPauseStart ||
1636 kind == kPauseExit || 1648 kind == kPauseExit ||
1637 kind == kPauseBreakpoint || 1649 kind == kPauseBreakpoint ||
1638 kind == kPauseInterrupted || 1650 kind == kPauseInterrupted ||
1639 kind == kPauseException); 1651 kind == kPauseException);
1640 } 1652 }
1641 1653
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 count = map['count']; 1696 count = map['count'];
1685 } 1697 }
1686 if (map['_debuggerSettings'] != null && 1698 if (map['_debuggerSettings'] != null &&
1687 map['_debuggerSettings']['_exceptions'] != null) { 1699 map['_debuggerSettings']['_exceptions'] != null) {
1688 exceptions = map['_debuggerSettings']['_exceptions']; 1700 exceptions = map['_debuggerSettings']['_exceptions'];
1689 } 1701 }
1690 if (map['bytes'] != null) { 1702 if (map['bytes'] != null) {
1691 var bytes = decodeBase64(map['bytes']); 1703 var bytes = decodeBase64(map['bytes']);
1692 bytesAsString = UTF8.decode(bytes); 1704 bytesAsString = UTF8.decode(bytes);
1693 } 1705 }
1706 if (map['logRecord'] != null) {
1707 logRecord = map['logRecord'];
1708 logRecord['time'] =
1709 new DateTime.fromMillisecondsSinceEpoch(logRecord['time']);
1710 logRecord['level'] = _findLogLevel(logRecord['level']);
1711 }
1694 } 1712 }
1695 1713
1696 String toString() { 1714 String toString() {
1697 if (data == null) { 1715 if (data == null) {
1698 return "ServiceEvent(owner='${owner.id}', kind='${kind}')"; 1716 return "ServiceEvent(owner='${owner.id}', kind='${kind}')";
1699 } else { 1717 } else {
1700 return "ServiceEvent(owner='${owner.id}', kind='${kind}', " 1718 return "ServiceEvent(owner='${owner.id}', kind='${kind}', "
1701 "data.lengthInBytes=${data.lengthInBytes})"; 1719 "data.lengthInBytes=${data.lengthInBytes})";
1702 } 1720 }
1703 } 1721 }
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
3583 var v = list[i]; 3601 var v = list[i];
3584 if ((v is ObservableMap) && _isServiceMap(v)) { 3602 if ((v is ObservableMap) && _isServiceMap(v)) {
3585 list[i] = owner.getFromMap(v); 3603 list[i] = owner.getFromMap(v);
3586 } else if (v is ObservableList) { 3604 } else if (v is ObservableList) {
3587 _upgradeObservableList(v, owner); 3605 _upgradeObservableList(v, owner);
3588 } else if (v is ObservableMap) { 3606 } else if (v is ObservableMap) {
3589 _upgradeObservableMap(v, owner); 3607 _upgradeObservableMap(v, owner);
3590 } 3608 }
3591 } 3609 }
3592 } 3610 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698