Skip to content

Commit

Permalink
opti easylog (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweet2honey authored Nov 15, 2023
1 parent 4d5da04 commit 4c6f2d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
18 changes: 5 additions & 13 deletions include/ylt/easylog/appender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,28 +176,20 @@ class appender {
memcpy(buf + 24, severity_str(record.get_severity()).data(), 8);
buf[32] = ' ';

if constexpr (enable_console) {
add_color(record.get_severity());
}

std::string_view str(buf, 33);

write_file(str);

if constexpr (enable_console) {
std::cout << str;
clean_color(record.get_severity());
}

auto time_str = std::string_view(buf, 33);
auto tid_str = get_tid_buf(record.get_tid());
auto file_str = record.get_file_str();
auto msg = record.get_message();

write_file(time_str);
write_file(tid_str);
write_file(file_str);
write_file(msg);

if constexpr (enable_console) {
add_color(record.get_severity());
std::cout << time_str;
clean_color(record.get_severity());
std::cout << tid_str;
std::cout << file_str;
std::cout << msg;
Expand Down
3 changes: 1 addition & 2 deletions include/ylt/easylog/record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace easylog {
namespace detail {
template <class T>
constexpr inline bool c_array_v = std::is_array_v<std::remove_cvref_t<T>> &&
std::extent_v<std::remove_cvref_t<T>> > 0;
(std::extent_v<std::remove_cvref_t<T>> > 0);

template <typename Type, typename = void>
struct has_data : std::false_type {};
Expand Down Expand Up @@ -151,7 +151,6 @@ class record_t {
data ? ss_.append("true") : ss_.append("false");
}
else if constexpr (std::is_same_v<char, U>) {
data ? ss_.append("true") : ss_.append("false");
ss_.push_back(data);
}
else if constexpr (std::is_enum_v<U>) {
Expand Down

0 comments on commit 4c6f2d6

Please sign in to comment.