mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:57:46 +00:00
LogStream: Preserve errno for the lifetime of a LogStream object.
This commit is contained in:
parent
1d0b464618
commit
0846986cac
1 changed files with 16 additions and 1 deletions
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
#include <AK/kstdio.h>
|
#include <AK/kstdio.h>
|
||||||
|
|
||||||
|
#ifdef USERLAND
|
||||||
|
#include <AK/ValueRestorer.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
class String;
|
class String;
|
||||||
|
@ -56,7 +61,12 @@ private:
|
||||||
|
|
||||||
class LogStream {
|
class LogStream {
|
||||||
public:
|
public:
|
||||||
LogStream() {}
|
LogStream()
|
||||||
|
#ifdef USERLAND
|
||||||
|
: m_errno_restorer(errno)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~LogStream() {}
|
virtual ~LogStream() {}
|
||||||
|
|
||||||
virtual void write(const char*, int) const = 0;
|
virtual void write(const char*, int) const = 0;
|
||||||
|
@ -64,6 +74,11 @@ public:
|
||||||
protected:
|
protected:
|
||||||
friend const LogStream& operator<<(const LogStream&, const TStyle&);
|
friend const LogStream& operator<<(const LogStream&, const TStyle&);
|
||||||
mutable bool m_needs_style_reset { false };
|
mutable bool m_needs_style_reset { false };
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifdef USERLAND
|
||||||
|
ValueRestorer<int> m_errno_restorer;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebugLogStream final : public LogStream {
|
class DebugLogStream final : public LogStream {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue