mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add support for Kernel Log Stream
This commit is contained in:
parent
dc01a71fac
commit
9440c45d6e
Notes:
sideshowbarker
2024-07-19 08:56:02 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/9440c45d6e1 Pull-request: https://github.com/SerenityOS/serenity/pull/1322
2 changed files with 45 additions and 0 deletions
|
@ -126,6 +126,31 @@ DebugLogStream dbg()
|
|||
return stream;
|
||||
}
|
||||
|
||||
#if defined(KERNEL)
|
||||
KernelLogStream klog()
|
||||
{
|
||||
KernelLogStream stream;
|
||||
if (Kernel::Thread::current)
|
||||
stream << "\033[34;1m[" << *Kernel::Thread::current << "]\033[0m: ";
|
||||
else
|
||||
stream << "\033[36;1m[Kernel]\033[0m: ";
|
||||
return stream;
|
||||
}
|
||||
#elif !defined(BOOTSTRAPPER)
|
||||
DebugLogStream klog()
|
||||
{
|
||||
return dbg();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(KERNEL)
|
||||
KernelLogStream::~KernelLogStream()
|
||||
{
|
||||
char newline = '\n';
|
||||
write(&newline, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugLogStream::~DebugLogStream()
|
||||
{
|
||||
char newline = '\n';
|
||||
|
|
|
@ -70,6 +70,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#if !defined(BOOTSTRAPPER) && defined(KERNEL)
|
||||
class KernelLogStream final : public LogStream {
|
||||
public:
|
||||
KernelLogStream() {}
|
||||
virtual ~KernelLogStream() override;
|
||||
|
||||
virtual void write(const char* characters, int length) const override
|
||||
{
|
||||
kernelputstr(characters, length);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, const char* value)
|
||||
{
|
||||
int length = 0;
|
||||
|
@ -103,7 +116,14 @@ inline const LogStream& operator<<(const LogStream& stream, bool value)
|
|||
|
||||
DebugLogStream dbg();
|
||||
|
||||
#if defined(KERNEL)
|
||||
KernelLogStream klog();
|
||||
#elif !defined(BOOTSTRAPPER)
|
||||
DebugLogStream klog();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
using AK::dbg;
|
||||
using AK::klog;
|
||||
using AK::LogStream;
|
||||
|
|
Loading…
Reference in a new issue