46 enum MessageType : uint8_t {
57 enum Output : uint8_t {
63 enum Color : uint8_t {
84 Message(uint8_t,
const std::string &,
const std::string &,
const std::string &);
85 Message(uint64_t time, uint8_t type,
const std::string &name,
const std::string &
string,
const std::string ¬e) : time(time), type(type), name(name), string(
string), note(note) {}
91 bool operator==(
const Message &m)
const {
return type == m.type &&
string == m.string && name == m.name && note == m.note; }
99 TimeFormat(
const std::string &,
bool =
false);
100 bool empty()
const {
return empty_; }
108 static void message(
const Message &m, uint8_t f = LOG_STREAM_CONSOLE_COLOR | LOG_STREAM_CONSOLE_EXTEND) { data.completed(m, f); }
109 static void console_output(
const Message &, uint8_t = LOG_STREAM_CONSOLE_COLOR | LOG_STREAM_CONSOLE_EXTEND);
110 static std::string levelName(uint8_t);
111 static std::string colorString(Color);
112 static std::string sender(
const char *);
113 static std::string timeString(
const uint64_t,
const TimeFormat & = {});
114 static std::string currentTimeString(
const TimeFormat & = {});
116 static void setTimeFormat(
const std::string &,
bool =
false);
117 static void setTimeOffset(
int);
118 static void setCompleted(
void (*_completed)(
const Message &, uint8_t)) { data.completed = _completed; }
119 static void setFunctionPrefixIgnoreList(
const std::vector<std::string> &list) { data.functionPrefixIgnoreList_ = list; }
120 static void setSenderPrefix(
const std::string &prefix) { data.senderPrefix_ = prefix; }
122 LogStream(uint8_t,
const char *,
const char *,
int, uint8_t = 0);
123 LogStream() =
default;
124 ~LogStream()
noexcept(
false);
125 template <
typename T>
126 inline LogStream &operator<<(T val) {
127 typedef const typename std::remove_reference<T>::type type;
129 if constexpr (std::is_same<type, const std::string>::value || std::is_same<type, const std::string_view>::value) {
139 stream << std::forward<T>(val);
143 LogStream &operator<<(
decltype(std::endl<
char, std::char_traits<char>>) &);
144 LogStream &operator<<(
const Color);
145 LogStream &operator<<(
const int8_t);
146 LogStream &operator<<(
const uint8_t);
147 LogStream &operator<<(
const char *);
148 LogStream &operator<<(
char *);
149 template <
typename... Args>
150 LogStream &output(std::format_string<Args...> msg, Args &&...args) {
152 stream << std::vformat(msg.get(), std::make_format_args(args...));
156 LogStream &output() {
return *
this; }
157 LogStream &output(
const std::string &);
159 LogStream &nospace();
167 static void set(
int);
172 int timeOffset = std::numeric_limits<int>::max();
173 TimeFormat timeFormat {LOG_STREAM_DEFAULT_TIME_FORMAT,
false};
174 void (*completed)(
const Message &, uint8_t) = &console_output;
175 std::vector<std::string> functionPrefixIgnoreList_;
176 std::string senderPrefix_;
182 std::stringstream stream;