limit ListBase to_string print count

This commit is contained in:
zhjc1124
2023-08-29 12:44:25 +00:00
committed by ob-robot
parent 78d58cb036
commit d96192d69c
2 changed files with 6 additions and 26 deletions

View File

@ -226,31 +226,6 @@ private:
int64_t pos_; int64_t pos_;
}; };
template <typename T>
const char *to_cstring(const T &obj, const bool verbose)
{
char *buffer = NULL;
int64_t str_len = 0;
CStringBufMgr &mgr = CStringBufMgr::get_thread_local_instance();
mgr.inc_level();
buffer = mgr.acquire();
if (OB_ISNULL(buffer)) {
LIB_LOG_RET(ERROR, OB_ALLOCATE_MEMORY_FAILED, "buffer is NULL");
} else {
const int64_t buf_len = mgr.get_buffer_len();
str_len = obj.to_string(buffer, buf_len -1, verbose);
if (str_len >= 0 && str_len < buf_len) {
buffer[str_len] = '\0';
} else {
buffer[0] = '\0';
}
mgr.update_position(str_len + 1);
}
mgr.try_clear_list();
mgr.dec_level();
return buffer;
}
template <typename T> template <typename T>
const char *to_cstring(const T &obj, FalseType) const char *to_cstring(const T &obj, FalseType)
{ {

View File

@ -89,7 +89,11 @@ struct ListBase// erase List Type
common::databuff_printf(buf, buf_len, pos, ", list_tail:0x%llx, list:", (unsigned long long)list_tail_); common::databuff_printf(buf, buf_len, pos, ", list_tail:0x%llx, list:", (unsigned long long)list_tail_);
int64_t list_len = 0; int64_t list_len = 0;
while (OB_NOT_NULL(iter)) { while (OB_NOT_NULL(iter)) {
if (list_len < MAX_PRINT_COUNT) {
common::databuff_printf(buf, buf_len, pos, "[%s]<->", to_cstring(*iter)); common::databuff_printf(buf, buf_len, pos, "[%s]<->", to_cstring(*iter));
} else if(list_len == MAX_PRINT_COUNT) {
common::databuff_printf(buf, buf_len, pos, "...");
}
++list_len; ++list_len;
iter = iter->next_; iter = iter->next_;
} }
@ -157,6 +161,7 @@ struct ListBase// erase List Type
public: public:
ListNodeBase *list_head_; ListNodeBase *list_head_;
ListNodeBase *list_tail_; ListNodeBase *list_tail_;
static const int64_t MAX_PRINT_COUNT = 16;
}; };
template <typename T> template <typename T>