mirror of https://gitee.com/bigwinds/arangodb
allow logging more types
This commit is contained in:
parent
fc5d7311b5
commit
4aa57b1cd1
|
@ -75,20 +75,51 @@ class LoggerStream {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
LoggerStream& operator<<(T obj) {
|
||||
LoggerStream& operator<<(T const& obj) {
|
||||
_out << obj;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
LoggerStream& operator<<(std::vector<T> const& v) {
|
||||
for (auto const& i : v) _out << i << " ";
|
||||
LoggerStream& operator<<(std::vector<T> const& obj) {
|
||||
_out << '[';
|
||||
size_t i = 0;
|
||||
size_t const n = obj.size();
|
||||
for (auto const& it : obj) {
|
||||
if (++i < n) {
|
||||
_out << it << ", ";
|
||||
}
|
||||
}
|
||||
_out << ']';
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
LoggerStream& operator<<(std::unordered_set<T> const& us) {
|
||||
for (auto const& i : us) _out << i;
|
||||
LoggerStream& operator<<(std::unordered_set<T> const& obj) {
|
||||
_out << '{';
|
||||
size_t i = 0;
|
||||
size_t const n = obj.size();
|
||||
for (auto const& it : obj) {
|
||||
if (++i < n) {
|
||||
_out << it << ", ";
|
||||
}
|
||||
}
|
||||
_out << '}';
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
LoggerStream& operator<<(std::unordered_map<K, V> const& obj) {
|
||||
_out << '{';
|
||||
size_t i = 0;
|
||||
size_t n = obj.size();
|
||||
for (auto const& it : obj) {
|
||||
if (++i < n) {
|
||||
_out << it << ", ";
|
||||
}
|
||||
_out << it.first << " => " << it.second;
|
||||
}
|
||||
_out << '}';
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue