mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
AK: Get rid of TStyle (output styling helper for LogStream)
This didn't end up getting used, so let's get rid of it.
This commit is contained in:
parent
1c8f017730
commit
2ad0ec325a
3 changed files with 2 additions and 74 deletions
|
@ -31,24 +31,6 @@ const LogStream& operator<<(const LogStream& stream, const void* value)
|
||||||
return stream << String::format("%p", value);
|
return stream << String::format("%p", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const LogStream& operator<<(const LogStream& stream, const TStyle& style)
|
|
||||||
{
|
|
||||||
stream << "\033[";
|
|
||||||
|
|
||||||
if (style.color() != TStyle::Color::NoColor)
|
|
||||||
stream << ((int)style.color() + 30) << (style.attributes() ? ";" : "");
|
|
||||||
else
|
|
||||||
stream << '0';
|
|
||||||
|
|
||||||
if (style.attributes() & TStyle::Attribute::Bold)
|
|
||||||
stream << '1';
|
|
||||||
|
|
||||||
stream << 'm';
|
|
||||||
|
|
||||||
stream.m_needs_style_reset = true;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USERLAND
|
#ifdef USERLAND
|
||||||
static TriState got_process_name = TriState::Unknown;
|
static TriState got_process_name = TriState::Unknown;
|
||||||
static char process_name_buffer[256];
|
static char process_name_buffer[256];
|
||||||
|
@ -65,7 +47,7 @@ DebugLogStream dbg()
|
||||||
got_process_name = TriState::False;
|
got_process_name = TriState::False;
|
||||||
}
|
}
|
||||||
if (got_process_name == TriState::True)
|
if (got_process_name == TriState::True)
|
||||||
stream << TStyle(TStyle::Color::Brown, TStyle::Attribute::Bold) << process_name_buffer << '(' << getpid() << ")" << TStyle(TStyle::None) << ": ";
|
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
|
||||||
#endif
|
#endif
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,52 +14,6 @@ namespace AK {
|
||||||
class String;
|
class String;
|
||||||
class StringView;
|
class StringView;
|
||||||
|
|
||||||
class TStyle {
|
|
||||||
public:
|
|
||||||
enum NoneTag { None };
|
|
||||||
|
|
||||||
enum Color {
|
|
||||||
Black = 0,
|
|
||||||
Red,
|
|
||||||
Green,
|
|
||||||
Brown,
|
|
||||||
Blue,
|
|
||||||
Magenta,
|
|
||||||
Cyan,
|
|
||||||
LightGray,
|
|
||||||
DarkGray,
|
|
||||||
BrightRed,
|
|
||||||
BrightGreen,
|
|
||||||
Yellow,
|
|
||||||
BrightBlue,
|
|
||||||
BrightMagenta,
|
|
||||||
BrightCyan,
|
|
||||||
White,
|
|
||||||
NoColor = 255,
|
|
||||||
};
|
|
||||||
enum Attribute {
|
|
||||||
NoAttribute = 0,
|
|
||||||
Bold = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
TStyle() {}
|
|
||||||
TStyle(NoneTag) {}
|
|
||||||
TStyle(Color color, unsigned attributes = NoAttribute)
|
|
||||||
: m_color(color)
|
|
||||||
, m_attributes(attributes)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~TStyle() {}
|
|
||||||
|
|
||||||
Color color() const { return m_color; }
|
|
||||||
unsigned attributes() const { return m_attributes; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Color m_color { NoColor };
|
|
||||||
unsigned m_attributes { NoAttribute };
|
|
||||||
};
|
|
||||||
|
|
||||||
class LogStream {
|
class LogStream {
|
||||||
public:
|
public:
|
||||||
LogStream()
|
LogStream()
|
||||||
|
@ -72,10 +26,6 @@ public:
|
||||||
|
|
||||||
virtual void write(const char*, int) const = 0;
|
virtual void write(const char*, int) const = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
friend const LogStream& operator<<(const LogStream&, const TStyle&);
|
|
||||||
mutable bool m_needs_style_reset { false };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef USERLAND
|
#ifdef USERLAND
|
||||||
ScopedValueRollback<int> m_errno_restorer;
|
ScopedValueRollback<int> m_errno_restorer;
|
||||||
|
@ -87,8 +37,6 @@ public:
|
||||||
DebugLogStream() {}
|
DebugLogStream() {}
|
||||||
virtual ~DebugLogStream() override
|
virtual ~DebugLogStream() override
|
||||||
{
|
{
|
||||||
if (m_needs_style_reset)
|
|
||||||
write("\033[0m", 4);
|
|
||||||
char newline = '\n';
|
char newline = '\n';
|
||||||
write(&newline, 1);
|
write(&newline, 1);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +62,6 @@ const LogStream& operator<<(const LogStream&, const StringView&);
|
||||||
const LogStream& operator<<(const LogStream&, int);
|
const LogStream& operator<<(const LogStream&, int);
|
||||||
const LogStream& operator<<(const LogStream&, unsigned);
|
const LogStream& operator<<(const LogStream&, unsigned);
|
||||||
const LogStream& operator<<(const LogStream&, const void*);
|
const LogStream& operator<<(const LogStream&, const void*);
|
||||||
const LogStream& operator<<(const LogStream& stream, const TStyle&);
|
|
||||||
|
|
||||||
inline const LogStream& operator<<(const LogStream& stream, char value)
|
inline const LogStream& operator<<(const LogStream& stream, char value)
|
||||||
{
|
{
|
||||||
|
@ -133,4 +80,3 @@ DebugLogStream dbg();
|
||||||
|
|
||||||
using AK::dbg;
|
using AK::dbg;
|
||||||
using AK::LogStream;
|
using AK::LogStream;
|
||||||
using AK::TStyle;
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ using AK::TestSuite;
|
||||||
auto ___aev1 = one; \
|
auto ___aev1 = one; \
|
||||||
auto ___aev2 = two; \
|
auto ___aev2 = two; \
|
||||||
if (___aev1 != ___aev2) { \
|
if (___aev1 != ___aev2) { \
|
||||||
dbg() << TStyle(TStyle::Red, TStyle::Bold) << "FAIL" << TStyle() << ": " __FILE__ ":" << __LINE__ << ": assertEqual(" ___str(one) ", " ___str(two) ") failed"; \
|
dbg() << "\033[31;1mFAIL\033[0m: " __FILE__ ":" << __LINE__ << ": assertEqual(" ___str(one) ", " ___str(two) ") failed"; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue