limit ListBase to_string print count
This commit is contained in:
25
deps/oblib/src/lib/utility/ob_print_utils.h
vendored
25
deps/oblib/src/lib/utility/ob_print_utils.h
vendored
@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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)) {
|
||||||
common::databuff_printf(buf, buf_len, pos, "[%s]<->", to_cstring(*iter));
|
if (list_len < MAX_PRINT_COUNT) {
|
||||||
|
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>
|
||||||
|
|||||||
Reference in New Issue
Block a user