mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:37:34 +00:00
AK: Add out() and warn() streams that forward to stdout and stderr
Our C++ code generator tools have been relying on host-side dbg() being forwarded to stdout until now. Now they use out() instead. Hopefully this will make it easier and more enticing to use streams in userspace programs as well. :^)
This commit is contained in:
parent
63b11e094d
commit
0d48fb9a87
6 changed files with 219 additions and 176 deletions
|
@ -68,6 +68,24 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||
class StdLogStream final : public LogStream {
|
||||
public:
|
||||
StdLogStream(int fd)
|
||||
: m_fd(fd)
|
||||
{
|
||||
}
|
||||
virtual ~StdLogStream() override;
|
||||
virtual void write(const char* characters, int length) const override;
|
||||
|
||||
private:
|
||||
int m_fd { -1 };
|
||||
};
|
||||
|
||||
inline StdLogStream out() { return StdLogStream(STDOUT_FILENO); }
|
||||
inline StdLogStream warn() { return StdLogStream(STDERR_FILENO); }
|
||||
#endif
|
||||
|
||||
#if !defined(BOOTSTRAPPER) && defined(KERNEL)
|
||||
class KernelLogStream final : public LogStream {
|
||||
public:
|
||||
|
@ -128,3 +146,8 @@ DebugLogStream klog();
|
|||
using AK::dbg;
|
||||
using AK::klog;
|
||||
using AK::LogStream;
|
||||
|
||||
#if !defined(KERNEL) && !defined(BOOTSTRAPPER)
|
||||
using AK::out;
|
||||
using AK::warn;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue