Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index e68727a3c41829a1889e847403d243797df540be..de3f48d391d19764e521a7bacc6b9e1edca8588a 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -87,7 +87,7 @@ StreamInfo Service::debug_stream("Debug"); |
StreamInfo Service::gc_stream("GC"); |
StreamInfo Service::echo_stream("_Echo"); |
StreamInfo Service::graph_stream("_Graph"); |
- |
+StreamInfo Service::logging_stream("_Logging"); |
static StreamInfo* streams_[] = { |
&Service::isolate_stream, |
@@ -95,6 +95,7 @@ static StreamInfo* streams_[] = { |
&Service::gc_stream, |
&Service::echo_stream, |
&Service::graph_stream, |
+ &Service::logging_stream, |
}; |
@@ -683,6 +684,16 @@ void Service::HandleEvent(ServiceEvent* event) { |
jsobj.AddProperty("event", event); |
jsobj.AddProperty("streamId", stream_id); |
} |
+ PostEvent(stream_id, event->KindAsCString(), &js); |
+} |
+ |
+ |
+void Service::PostEvent(const char* stream_id, |
+ const char* kind, |
+ JSONStream* event) { |
+ ASSERT(stream_id != NULL); |
+ ASSERT(kind != NULL); |
+ ASSERT(event != NULL); |
// Message is of the format [<stream id>, <json string>]. |
// |
@@ -702,13 +713,12 @@ void Service::HandleEvent(ServiceEvent* event) { |
Dart_CObject json_cobj; |
json_cobj.type = Dart_CObject_kString; |
- json_cobj.value.as_string = const_cast<char*>(js.ToCString()); |
+ json_cobj.value.as_string = const_cast<char*>(event->ToCString()); |
list_values[1] = &json_cobj; |
if (FLAG_trace_service) { |
OS::Print( |
- "vm-service: Pushing event of type %s to stream %s\n", |
- event->KindAsCString(), stream_id); |
+ "vm-service: Pushing event of type %s to stream %s\n", kind, stream_id); |
} |
Dart_PostCObject(ServiceIsolate::Port(), &list_cobj); |
@@ -2512,6 +2522,30 @@ void Service::SendEmbedderEvent(Isolate* isolate, |
} |
+void Service::SendLogEvent(Isolate* isolate, |
+ int64_t sequence_number, |
+ int64_t timestamp, |
+ intptr_t level, |
+ const String& name, |
+ const String& message, |
+ const Instance& zone, |
+ const Object& error, |
+ const Instance& stack_trace) { |
+ ServiceEvent::LogRecord log_record; |
+ log_record.sequence_number = sequence_number; |
+ log_record.timestamp = timestamp; |
+ log_record.level = level; |
+ log_record.name = &name; |
+ log_record.message = &message; |
+ log_record.zone = &zone; |
+ log_record.error = &error; |
+ log_record.stack_trace = &stack_trace; |
+ ServiceEvent event(isolate, ServiceEvent::kLogging); |
+ event.set_log_record(log_record); |
+ Service::HandleEvent(&event); |
+} |
+ |
+ |
class ContainsAddressVisitor : public FindObjectVisitor { |
public: |
ContainsAddressVisitor(Isolate* isolate, uword addr) |