replace char*/string with stringview
This commit is contained in:
@ -15,7 +15,7 @@ constexpr const char* ansi_cyan = "\033[1;36m";
|
||||
constexpr const char* ansi_white = "\033[1;37m";
|
||||
constexpr const char* ansi_default = "\033[0;39m ";
|
||||
|
||||
void Logger::log(const char* message, CGA::color col) const {
|
||||
void Logger::log(const bse::string_view message, CGA::color col) const {
|
||||
if (Logger::kout_enabled) {
|
||||
CGA::color old_col = kout.color_fg;
|
||||
kout << fgc(col)
|
||||
@ -71,41 +71,29 @@ void Logger::flush() {
|
||||
Logger::unlock();
|
||||
}
|
||||
|
||||
void Logger::trace(const char* message) const {
|
||||
void Logger::trace(const bse::string_view message) const {
|
||||
if (Logger::level <= Logger::TRACE) {
|
||||
log(message, CGA::WHITE);
|
||||
}
|
||||
}
|
||||
void Logger::trace(const bse::string& message) const {
|
||||
trace(static_cast<const char*>(message));
|
||||
}
|
||||
|
||||
void Logger::debug(const char* message) const {
|
||||
void Logger::debug(const bse::string_view message) const {
|
||||
if (Logger::level <= Logger::DEBUG) {
|
||||
log(message, CGA::LIGHT_MAGENTA);
|
||||
}
|
||||
}
|
||||
void Logger::debug(const bse::string& message) const {
|
||||
debug(static_cast<const char*>(message));
|
||||
}
|
||||
|
||||
void Logger::error(const char* message) const {
|
||||
void Logger::error(const bse::string_view message) const {
|
||||
if (Logger::level <= Logger::ERROR) {
|
||||
log(message, CGA::LIGHT_RED);
|
||||
}
|
||||
}
|
||||
void Logger::error(const bse::string& message) const {
|
||||
error(static_cast<const char*>(message));
|
||||
}
|
||||
|
||||
void Logger::info(const char* message) const {
|
||||
void Logger::info(const bse::string_view message) const {
|
||||
if (Logger::level <= Logger::INFO) {
|
||||
log(message, CGA::LIGHT_BLUE);
|
||||
}
|
||||
}
|
||||
void Logger::info(const bse::string& message) const {
|
||||
info(static_cast<const char*>(message));
|
||||
}
|
||||
|
||||
// Manipulatoren
|
||||
Logger& TRACE(Logger& log) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "lib/OutStream.h"
|
||||
#include "lib/SpinLock.h"
|
||||
#include "user/lib/String.h"
|
||||
#include "user/lib/StringView.h"
|
||||
|
||||
class Logger : public OutStream {
|
||||
public:
|
||||
@ -19,7 +20,7 @@ private:
|
||||
static bool kout_enabled;
|
||||
static bool serial_enabled;
|
||||
|
||||
void log(const char* message, CGA::color col) const;
|
||||
void log(const bse::string_view message, CGA::color col) const;
|
||||
|
||||
friend class NamedLogger; // Allow NamedLogger to lock/unlock
|
||||
|
||||
@ -46,21 +47,17 @@ public:
|
||||
|
||||
void flush() override;
|
||||
|
||||
void trace(const char* message) const;
|
||||
void trace(const bse::string& message) const;
|
||||
void debug(const char* message) const;
|
||||
void debug(const bse::string& message) const;
|
||||
void error(const char* message) const;
|
||||
void error(const bse::string& message) const;
|
||||
void info(const char* message) const;
|
||||
void info(const bse::string& message) const;
|
||||
void trace(const bse::string_view message) const;
|
||||
void debug(const bse::string_view message) const;
|
||||
void error(const bse::string_view message) const;
|
||||
void info(const bse::string_view message) const;
|
||||
|
||||
// TODO: Make lvl change accessible over menu
|
||||
static void set_level(LogLevel lvl) {
|
||||
Logger::level = lvl;
|
||||
}
|
||||
|
||||
static char* level_to_string(LogLevel lvl) {
|
||||
static bse::string_view level_to_string(LogLevel lvl) {
|
||||
switch (lvl) {
|
||||
case Logger::TRACE:
|
||||
return "TRACE";
|
||||
|
Reference in New Issue
Block a user