diff options
author | ncshaw <ncshaw@ibm.com> | 2022-04-04 15:01:41 -0500 |
---|---|---|
committer | Noah Shaw <ncshaw@ibm.com> | 2022-05-09 10:04:06 -0500 |
commit | ff2480f72f691084c28fa5225c83938727fcbb68 (patch) | |
tree | bd4707ac5f19c4940e7b2a351756b536435ef2fb | |
parent | 3cd41c5dfab76ffa2dece825d819918aa9aab35e (diff) | |
download | couchdb-ff2480f72f691084c28fa5225c83938727fcbb68.tar.gz |
Implement print_table/2
-rw-r--r-- | src/couch/src/couch_debug.erl | 41 |
1 files changed, 40 insertions, 1 deletions
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 ]. @@ -275,6 +280,30 @@ couch_index_server[<0.288.0>] | 478240 | 0 | --- ", []); +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) -> io:format("Unknown function: `~p`. Please try one of the following:~n", [Unknown]), [io:format(" - ~s~n", [Function]) || Function <- help()], @@ -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) -> |