701d79d08a
console.context(name:string) method returns console instance, this console instance fully implements console interface (including fact that any method can be called without console as receiver). Protocol.Runtime.consoleAPICalled notification contains additional context:string field: - "anonymous#unique-id" for any method call on unnamed console context, - "name#unique-id" for any method call on named console context. console.count and console.timeEnd have context as a scope. console.clear clear all messages regardless on what context instance it was called. console calls is ~10% slower with this CL since we need to store and then fetch console_context_id and console_context_name from function object. We recently (in April) made console calls twice faster so 10% doesn't sound critical and existing of console.log call in hot code is problem by itself. R=pfeldman@chromium.org Bug: chromium:728767 Change-Id: I5fc73216fb8b28bfe1e8c2c1b393ebfbe43cd02e Reviewed-on: https://chromium-review.googlesource.com/522128 Reviewed-by: Igor Sheludko <ishell@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Cr-Commit-Position: refs/heads/master@{#45864}
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef V8_D8_CONSOLE_H_
|
|
#define V8_D8_CONSOLE_H_
|
|
|
|
#include "src/base/platform/time.h"
|
|
#include "src/debug/debug-interface.h"
|
|
#include "src/debug/interface-types.h"
|
|
|
|
namespace v8 {
|
|
|
|
class D8Console : public debug::ConsoleDelegate {
|
|
public:
|
|
explicit D8Console(Isolate* isolate);
|
|
|
|
private:
|
|
void Log(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
void Error(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
void Warn(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
void Info(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
void Debug(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
void Time(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
void TimeEnd(const debug::ConsoleCallArguments& args,
|
|
const v8::debug::ConsoleContext&) override;
|
|
|
|
Isolate* isolate_;
|
|
std::map<std::string, base::TimeTicks> timers_;
|
|
base::TimeTicks default_timer_;
|
|
};
|
|
|
|
} // namespace v8
|
|
|
|
#endif // V8_D8_CONSOLE_H_
|