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:
parent
1d0b464618
commit
0846986cac
1 changed files with 16 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue