mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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
Notes:
sideshowbarker
2024-07-19 11:21:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2ad0ec325a0
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);
|
||||
}
|
||||
|
||||
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
|
||||
static TriState got_process_name = TriState::Unknown;
|
||||
static char process_name_buffer[256];
|
||||
|
@ -65,7 +47,7 @@ DebugLogStream dbg()
|
|||
got_process_name = TriState::False;
|
||||
}
|
||||
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
|
||||
return stream;
|
||||
}
|
||||
|
|
|
@ -14,52 +14,6 @@ namespace AK {
|
|||
class String;
|
||||
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 {
|
||||
public:
|
||||
LogStream()
|
||||
|
@ -72,10 +26,6 @@ public:
|
|||
|
||||
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:
|
||||
#ifdef USERLAND
|
||||
ScopedValueRollback<int> m_errno_restorer;
|
||||
|
@ -87,8 +37,6 @@ public:
|
|||
DebugLogStream() {}
|
||||
virtual ~DebugLogStream() override
|
||||
{
|
||||
if (m_needs_style_reset)
|
||||
write("\033[0m", 4);
|
||||
char newline = '\n';
|
||||
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&, unsigned);
|
||||
const LogStream& operator<<(const LogStream&, const void*);
|
||||
const LogStream& operator<<(const LogStream& stream, const TStyle&);
|
||||
|
||||
inline const LogStream& operator<<(const LogStream& stream, char value)
|
||||
{
|
||||
|
@ -133,4 +80,3 @@ DebugLogStream dbg();
|
|||
|
||||
using AK::dbg;
|
||||
using AK::LogStream;
|
||||
using AK::TStyle;
|
||||
|
|
|
@ -252,7 +252,7 @@ using AK::TestSuite;
|
|||
auto ___aev1 = one; \
|
||||
auto ___aev2 = two; \
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue