aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigConsoleClient.h
blob: 684e928fd4feb42687994e701a85ff198e597f80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

#include "JavaScriptCore/ConsoleClient.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"

namespace Inspector {
class InspectorConsoleAgent;
class InspectorDebuggerAgent;
class InspectorScriptProfilerAgent;
} // namespace Inspector
namespace Zig {
using InspectorConsoleAgent = Inspector::InspectorConsoleAgent;
using InspectorDebuggerAgent = Inspector::InspectorDebuggerAgent;
using InspectorScriptProfilerAgent = Inspector::InspectorScriptProfilerAgent;
using namespace JSC;

class ConsoleClient final : public JSC::ConsoleClient {
    WTF_MAKE_FAST_ALLOCATED;

public:
    ~ConsoleClient() final {}
    ConsoleClient(void* client)
        : JSC::ConsoleClient()
    {
        m_client = client;
    }

    static bool logToSystemConsole();
    static void setLogToSystemConsole(bool);

    void setDebuggerAgent(InspectorDebuggerAgent* agent) { m_debuggerAgent = agent; }
    void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent* agent)
    {
        m_scriptProfilerAgent = agent;
    }

    void* m_client;

private:
    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::JSGlobalObject*,
        Ref<Inspector::ScriptArguments>&&);
    void count(JSC::JSGlobalObject*, const String& label);
    void countReset(JSC::JSGlobalObject*, const String& label);
    void profile(JSC::JSGlobalObject*, const String& title);
    void profileEnd(JSC::JSGlobalObject*, const String& title);
    void takeHeapSnapshot(JSC::JSGlobalObject*, const String& title);
    void time(JSC::JSGlobalObject*, const String& label);
    void timeLog(JSC::JSGlobalObject*, const String& label, Ref<Inspector::ScriptArguments>&&);
    void timeEnd(JSC::JSGlobalObject*, const String& label);
    void timeStamp(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
    void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
    void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
    void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);

    void warnUnimplemented(const String& method);
    void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject*,
        Ref<Inspector::ScriptArguments>&&);

    void startConsoleProfile();
    void stopConsoleProfile();

    Inspector::InspectorConsoleAgent* m_consoleAgent;
    Inspector::InspectorDebuggerAgent* m_debuggerAgent { nullptr };
    Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent { nullptr };
    Vector<String> m_profiles;
    bool m_profileRestoreBreakpointActiveValue { false };
};

} // namespace Zig
n class='deletions'>-9/+492 2023-09-20implement `Module.prototype._compile` (#5840)Gravatar dave caruso 4-2/+78 2023-09-20feat(runtime): implement `console._stdout` (#5842)Gravatar dave caruso 2-1/+59 2023-09-20Improve types for `test.each`, `describe.each` (#5838)Gravatar Colin McDonnell 2-10/+59 2023-09-20Fix rendering of bun.lockb in vscode extensionGravatar Ashcon Partovi 5-114/+4 2023-09-20Run bun fmtGravatar Ashcon Partovi 2-12/+9 2023-09-20Update quickstartGravatar Colin McDonnell 1-0/+19 2023-09-20Update prisma guideGravatar Colin McDonnell 1-0/+6 2023-09-20Update env docGravatar Colin McDonnell 1-1/+1 2023-09-20Clarify hot modeGravatar Colin McDonnell 1-10/+9 2023-09-20[bun install] Add `-E` as alias of `--exact` (#5104)Gravatar Jonah Snider 2-2/+57 2023-09-20feat: switch disableTelemetry to bunfig (#5690)Gravatar Lucas Coratger 3-1/+14 2023-09-20Treat `undefined` value as empty in expect.toThrow (#5788)Gravatar LongYinan 1-3/+3 2023-09-20Fix various bugs in vscode extension (#5772)Gravatar JeremyFunk 3-9/+85 2023-09-20add `emitDecoratorMetadata` (#5777)Gravatar Dylan Conway 19-110/+1884 2023-09-20fix(doc): correct `server.reload` (#5799)Gravatar Ai Hoshino 1-1/+1 2023-09-20Call `Error.prepareStackTrace` on `new Error().stack` (#5802)Gravatar Jarred Sumner 6-155/+277 2023-09-20Fixes #5800Gravatar Jarred Sumner 1-1/+1 2023-09-20Fix path used in bunx (#5785)Gravatar Jarred Sumner 2-26/+51 2023-09-20Fix RedirectURLTooLong errors (#5786)Gravatar ggobbe 1-1/+1 2023-09-19Show when a newer version is available in the install screen (#5780)Gravatar Jarred Sumner 3-14/+95 2023-09-19Fix broken linksGravatar Colin McDonnell 4-4/+4