Files
sdk/runtime/lib/developer.cc
T
John McCutchan a2757141b0 Make dart:developer log more user friendly
- Make required arguments required.
- Validate required arguments in Dart before calling native.
- timestamp is now a DateTime.
- level has a default (ALL).
- sequence number is last + 1 if not provided.

R=lrn@google.com

Review URL: https://codereview.chromium.org//1266053003 .
2015-08-04 07:12:39 -07:00

63 lines
2.0 KiB
C++

// 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.
#include "vm/bootstrap_natives.h"
#include "include/dart_api.h"
#include "vm/debugger.h"
#include "vm/exceptions.h"
#include "vm/native_entry.h"
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/service.h"
namespace dart {
// Native implementations for the dart:developer library.
DEFINE_NATIVE_ENTRY(Developer_debugger, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(Bool, when, arguments->NativeArgAt(0));
GET_NATIVE_ARGUMENT(String, msg, arguments->NativeArgAt(1));
Debugger* debugger = isolate->debugger();
if (!debugger) {
return when.raw();
}
if (when.value()) {
debugger->BreakHere(msg);
}
return when.raw();
}
DEFINE_NATIVE_ENTRY(Developer_inspect, 1) {
GET_NATIVE_ARGUMENT(Instance, inspectee, arguments->NativeArgAt(0));
Service::SendInspectEvent(isolate, inspectee);
return inspectee.raw();
}
DEFINE_NATIVE_ENTRY(Developer_log, 8) {
GET_NON_NULL_NATIVE_ARGUMENT(String, message, arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Integer, timestamp, arguments->NativeArgAt(1));
GET_NON_NULL_NATIVE_ARGUMENT(Integer, sequence, arguments->NativeArgAt(2));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, level, arguments->NativeArgAt(3));
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(4));
GET_NATIVE_ARGUMENT(Instance, dart_zone, arguments->NativeArgAt(5));
GET_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(6));
GET_NATIVE_ARGUMENT(Instance, stack_trace, arguments->NativeArgAt(7));
Service::SendLogEvent(isolate,
sequence.AsInt64Value(),
timestamp.AsInt64Value(),
level.Value(),
name,
message,
dart_zone,
error,
stack_trace);
return Object::null();
}
} // namespace dart