v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1
// Copyright 2019 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef V8_TORQUE_LS_GLOBALS_H_
6
#define V8_TORQUE_LS_GLOBALS_H_
7
8
#include <fstream>
9
10
#include "
src/base/contextual.h
"
11
12
namespace
v8
{
13
namespace
internal
{
14
namespace
torque {
15
16
// When the language server is run by VS code, stdout can not be seen, as it is
17
// used as the communication channel. For debugging purposes a simple
18
// Log class is added, that allows writing diagnostics to a file configurable
19
// via command line flag.
20
class
Logger
:
public
base::ContextualClass
<Logger> {
21
public
:
22
Logger
() :
enabled_
(false) {}
23
~Logger
() {
24
if
(
enabled_
)
logfile_
.close();
25
}
26
27
static
void
Enable
(std::string path) {
28
Get
().enabled_ =
true
;
29
Get
().logfile_.open(path);
30
}
31
32
template
<
class
... Args>
33
static
void
Log
(Args&&...
args
) {
34
if
(
Enabled
()) {
35
USE
((
Stream
() << std::forward<Args>(
args
))...);
36
Flush
();
37
}
38
}
39
40
private
:
41
static
bool
Enabled
() {
return
Get
().enabled_; }
42
static
std::ofstream&
Stream
() {
43
CHECK
(
Get
().
enabled_
);
44
return
Get
().logfile_;
45
}
46
static
void
Flush
() {
Get
().logfile_.flush(); }
47
48
private
:
49
bool
enabled_
;
50
std::ofstream
logfile_
;
51
};
52
53
DECLARE_CONTEXTUAL_VARIABLE
(TorqueFileList, std::vector<std::string>);
54
55
}
// namespace torque
56
}
// namespace internal
57
}
// namespace v8
58
59
#endif
// V8_TORQUE_LS_GLOBALS_H_
v8::base::ContextualVariable
Definition
contextual.h:27
v8::base::ContextualVariable::Get
static VarType & Get()
Definition
contextual.h:64
v8::internal::torque::Logger
Definition
globals.h:20
v8::internal::torque::Logger::Flush
static void Flush()
Definition
globals.h:46
v8::internal::torque::Logger::Log
static void Log(Args &&... args)
Definition
globals.h:33
v8::internal::torque::Logger::Logger
Logger()
Definition
globals.h:22
v8::internal::torque::Logger::Enable
static void Enable(std::string path)
Definition
globals.h:27
v8::internal::torque::Logger::Enabled
static bool Enabled()
Definition
globals.h:41
v8::internal::torque::Logger::~Logger
~Logger()
Definition
globals.h:23
v8::internal::torque::Logger::enabled_
bool enabled_
Definition
globals.h:49
v8::internal::torque::Logger::Stream
static std::ofstream & Stream()
Definition
globals.h:42
v8::internal::torque::Logger::logfile_
std::ofstream logfile_
Definition
globals.h:50
contextual.h
DECLARE_CONTEXTUAL_VARIABLE
#define DECLARE_CONTEXTUAL_VARIABLE(VarName,...)
Definition
contextual.h:88
args
base::Vector< const DirectHandle< Object > > args
Definition
execution.cc:74
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
CHECK
#define CHECK(condition)
Definition
logging.h:124
USE
#define USE(...)
Definition
macros.h:293
src
torque
ls
globals.h
Generated on Sun Apr 6 2025 21:08:51 for v8 by
1.12.0