Commit 74b0f150 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[d8] Don't print prefix for console.log in d8

This should make d8 behave closer to node.

Change-Id: Ic871aed194b277262d70f53cfd02a50a3447f2a4
Reviewed-on: https://chromium-review.googlesource.com/718757Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48549}
parent c39111fd
......@@ -9,9 +9,9 @@
namespace v8 {
namespace {
void WriteToFile(const char* action, FILE* file, Isolate* isolate,
void WriteToFile(const char* prefix, FILE* file, Isolate* isolate,
const debug::ConsoleCallArguments& args) {
fprintf(file, "console.%s: ", action);
if (prefix) fprintf(file, "%s: ", prefix);
for (int i = 0; i < args.Length(); i++) {
HandleScope handle_scope(isolate);
if (i > 0) fprintf(file, " ");
......@@ -49,7 +49,7 @@ void D8Console::Assert(const debug::ConsoleCallArguments& args,
arg = v8::False(isolate_);
}
if (arg->IsTrue()) return;
WriteToFile("assert", stdout, isolate_, args);
WriteToFile("console.assert", stdout, isolate_, args);
isolate_->ThrowException(v8::Exception::Error(
v8::String::NewFromUtf8(isolate_, "console.assert failed",
v8::NewStringType::kNormal)
......@@ -58,27 +58,27 @@ void D8Console::Assert(const debug::ConsoleCallArguments& args,
void D8Console::Log(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
WriteToFile("log", stdout, isolate_, args);
WriteToFile(nullptr, stdout, isolate_, args);
}
void D8Console::Error(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
WriteToFile("error", stderr, isolate_, args);
WriteToFile("console.error", stderr, isolate_, args);
}
void D8Console::Warn(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
WriteToFile("warn", stdout, isolate_, args);
WriteToFile("console.warn", stdout, isolate_, args);
}
void D8Console::Info(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
WriteToFile("info", stdout, isolate_, args);
WriteToFile("console.info", stdout, isolate_, args);
}
void D8Console::Debug(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
WriteToFile("debug", stdout, isolate_, args);
WriteToFile("console.debug", stdout, isolate_, args);
}
void D8Console::Time(const debug::ConsoleCallArguments& args,
......
......@@ -2,7 +2,7 @@ console.timeEnd: default, {NUMBER}
console.timeEnd: abcd, {NUMBER}
console.timeEnd: b, {NUMBER}
console.timeEnd: a, {NUMBER}
console.log: log more
log more
console.warn: warn 2
console.debug: debug
console.info: info
......
console.log: state: 0
console.log: state: 0
console.log: increment state
console.log: current state: 1
console.log: increment state
console.log: current state: 2
console.log: increment state
console.log: current state: 3
state: 0
state: 0
increment state
current state: 1
increment state
current state: 2
increment state
current state: 3
*%(basename)s:19: Error
setTimeout(function() { throw new Error(); });
^
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment