mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
AK: Provide off-switch for dbg() output
This commit is contained in:
parent
b29f4add6b
commit
1ef26e0c09
Notes:
sideshowbarker
2024-07-19 03:02:11 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/1ef26e0c092 Pull-request: https://github.com/SerenityOS/serenity/pull/3314
2 changed files with 20 additions and 1 deletions
|
@ -163,13 +163,25 @@ KernelLogStream::~KernelLogStream()
|
||||||
|
|
||||||
DebugLogStream::~DebugLogStream()
|
DebugLogStream::~DebugLogStream()
|
||||||
{
|
{
|
||||||
if (!empty()) {
|
if (!empty() && s_enabled) {
|
||||||
char newline = '\n';
|
char newline = '\n';
|
||||||
write(&newline, 1);
|
write(&newline, 1);
|
||||||
dbgputstr(reinterpret_cast<char*>(data()), size());
|
dbgputstr(reinterpret_cast<char*>(data()), size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugLogStream::set_enabled(bool enabled)
|
||||||
|
{
|
||||||
|
s_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DebugLogStream::is_enabled()
|
||||||
|
{
|
||||||
|
return s_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DebugLogStream::s_enabled = true;
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
StdLogStream::~StdLogStream()
|
StdLogStream::~StdLogStream()
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,6 +115,13 @@ class DebugLogStream final : public BufferedLogStream {
|
||||||
public:
|
public:
|
||||||
DebugLogStream() { }
|
DebugLogStream() { }
|
||||||
virtual ~DebugLogStream() override;
|
virtual ~DebugLogStream() override;
|
||||||
|
|
||||||
|
// DebugLogStream only checks `enabled` and possibly generates output while the destructor runs.
|
||||||
|
static void set_enabled(bool);
|
||||||
|
static bool is_enabled();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool s_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(KERNEL)
|
#if !defined(KERNEL)
|
||||||
|
|
Loading…
Reference in a new issue