1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:57:35 +00:00

LogStream: Preserve errno for the lifetime of a LogStream object.

This commit is contained in:
Andreas Kling 2019-07-25 07:00:33 +02:00
parent 1d0b464618
commit 0846986cac

View file

@ -2,6 +2,11 @@
#include <AK/kstdio.h>
#ifdef USERLAND
#include <AK/ValueRestorer.h>
#include <errno.h>
#endif
namespace AK {
class String;
@ -56,7 +61,12 @@ private:
class LogStream {
public:
LogStream() {}
LogStream()
#ifdef USERLAND
: m_errno_restorer(errno)
#endif
{
}
virtual ~LogStream() {}
virtual void write(const char*, int) const = 0;
@ -64,6 +74,11 @@ public:
protected:
friend const LogStream& operator<<(const LogStream&, const TStyle&);
mutable bool m_needs_style_reset { false };
private:
#ifdef USERLAND
ValueRestorer<int> m_errno_restorer;
#endif
};
class DebugLogStream final : public LogStream {