
This implements: - console.group() - console.groupCollapsed() - console.groupEnd() In the Browser, we use `<details>` for the groups, which is not actually implemented yet, so groups are always open. In the REPL, groups are non-interactive, but still indent any output. This looks weird since the console prompt and return values remain on the far left, but this matches what Node does so it's probably fine. :^) I expect `console.group()` is not used much outside of browsers.
37 lines
944 B
C++
37 lines
944 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
namespace JS {
|
|
|
|
class ConsoleObject final : public Object {
|
|
JS_OBJECT(ConsoleObject, Object);
|
|
|
|
public:
|
|
explicit ConsoleObject(GlobalObject&);
|
|
virtual void initialize(GlobalObject&) override;
|
|
virtual ~ConsoleObject() override;
|
|
|
|
private:
|
|
JS_DECLARE_NATIVE_FUNCTION(log);
|
|
JS_DECLARE_NATIVE_FUNCTION(debug);
|
|
JS_DECLARE_NATIVE_FUNCTION(info);
|
|
JS_DECLARE_NATIVE_FUNCTION(warn);
|
|
JS_DECLARE_NATIVE_FUNCTION(error);
|
|
JS_DECLARE_NATIVE_FUNCTION(trace);
|
|
JS_DECLARE_NATIVE_FUNCTION(count);
|
|
JS_DECLARE_NATIVE_FUNCTION(count_reset);
|
|
JS_DECLARE_NATIVE_FUNCTION(clear);
|
|
JS_DECLARE_NATIVE_FUNCTION(assert_);
|
|
JS_DECLARE_NATIVE_FUNCTION(group);
|
|
JS_DECLARE_NATIVE_FUNCTION(group_collapsed);
|
|
JS_DECLARE_NATIVE_FUNCTION(group_end);
|
|
};
|
|
|
|
}
|