You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ii...@apache.org on 2022/05/09 15:38:04 UTC
[couchdb] branch 3.x updated: Implement print_table/2
This is an automated email from the ASF dual-hosted git repository.
iilyak pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/3.x by this push:
new ff2480f72 Implement print_table/2
new 92fc0bfb9 Merge pull request #3983 from noahshaw11/implement-print_table/2
ff2480f72 is described below
commit ff2480f72f691084c28fa5225c83938727fcbb68
Author: ncshaw <nc...@ibm.com>
AuthorDate: Mon Apr 4 15:01:41 2022 -0500
Implement print_table/2
---
src/couch/src/couch_debug.erl | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/couch/src/couch_debug.erl b/src/couch/src/couch_debug.erl
index cfa994723..d3f00e60f 100644
--- a/src/couch/src/couch_debug.erl
+++ b/src/couch/src/couch_debug.erl
@@ -40,6 +40,10 @@
restart_busy/4
]).
+-export([
+ print_table/2
+]).
+
-type throw(_Reason) :: no_return().
-type process_name() :: atom().
@@ -66,6 +70,7 @@ help() ->
fold,
linked_processes_info,
print_linked_processes,
+ print_table,
restart,
restart_busy
].
@@ -273,6 +278,30 @@ couch_index_server[<0.288.0>] | 478240 | 0 |
couch_index:init/1[<0.3520.22>] | 4899 | 0 | 109456
```
+ ---
+ ", []);
+help(print_table) ->
+ io:format("
+ print_table(Rows, TableSpec)
+ --------------------------------
+
+ Print table of specifications.
+ - Rows: List of {Id, Props} to be printed from the TableSpec
+ - TableSpec: List of either {Value} or {Width, Align, Value}
+ where Align is either left/center/right.
+
+ ---
+ ", []);
+help(print_tree) ->
+ io:format("
+ print_tree(Tree, TableSpec)
+ --------------------------------
+
+ Print tree of specifications.
+ - Tree: Tree to be printed from the TableSpec
+ - TableSpec: List of either {Value} or {Width, Align, Value}
+ where Align is either left/center/right.
+
---
", []);
help(Unknown) ->
@@ -606,7 +635,7 @@ restart_busy(ProcessList, Threshold, DelayInMsec, Property) when
%% Pretty print functions
-%% Limmitations:
+%% Limitations:
%% - The first column has to be specified as {Width, left, Something}
%% The TableSpec is a list of either:
%% - {Value}
@@ -615,6 +644,16 @@ restart_busy(ProcessList, Threshold, DelayInMsec, Property) when
%% - left
%% - centre
%% - right
+print_table(Rows, TableSpec) ->
+ io:format("~s~n", [format(TableSpec)]),
+ lists:foreach(
+ fun({Id, Props}) ->
+ io:format("~s~n", [table_row(Id, 2, Props, TableSpec)])
+ end,
+ Rows
+ ),
+ ok.
+
print_tree(Tree, TableSpec) ->
io:format("~s~n", [format(TableSpec)]),
map_tree(Tree, fun(_, {Id, Props}, Pos) ->