Skip to content

Commit

Permalink
[feature](selectdb-cloud) Reduce meta-service log (apache#1067)
Browse files Browse the repository at this point in the history
* Quote string in the tagged log
* Add template to enable customized log for RPC requests
  • Loading branch information
platoneko committed Nov 20, 2022
1 parent 15c9d98 commit 0a1b5fa
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 83 deletions.
9 changes: 8 additions & 1 deletion cloud/src/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <fmt/format.h>
#include <glog/logging.h>

#include <type_traits>

namespace selectdb {

bool init_glog(const char* basename);
Expand All @@ -28,7 +30,12 @@ class TaggableLogger {

template <typename V>
TaggableLogger& tag(std::string_view key, const V& value) {
stream_ << '|' << key << '=' << value;
stream_ << ' ' << key << '=';
if constexpr (std::is_convertible_v<V, std::string_view>) {
stream_ << '"' << value << '"';
} else {
stream_ << value;
}
return *this;
}

Expand Down
Loading

0 comments on commit 0a1b5fa

Please sign in to comment.