aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorSteve Vinoski <[email protected]>2009-11-27 12:37:13 -0500
committerSteve Vinoski <[email protected]>2009-12-01 21:31:30 -0500
commit88b530ea24977081020feb2123124063e58dfc12 (patch)
tree3e1fa8301f22328d0b1cf70edc585bfca5fd8729 /lib/stdlib/src
parent2a9b7a1c7816812dd637933a8fbf61bed6742785 (diff)
downloadotp-88b530ea24977081020feb2123124063e58dfc12.tar.gz
otp-88b530ea24977081020feb2123124063e58dfc12.tar.bz2
otp-88b530ea24977081020feb2123124063e58dfc12.zip
Teach sys:get_status/1,2 to call Mod:format_status/2
Restore the ability for gen_server and gen_fsm callback modules to format their own state for display under the sys:get_status/1,2 calls. This ability is extremely useful for new behavior modules based on gen_server or gen_fsm, so that they can display their status in a more meaningful way than just dumping the state record. It is also generally useful for applications wanting to display their gen_server or gen_fsm callback module state in something other than the default manner. Also document the previously undocumented the gen_server:format_status/2 and gen_fsm:format_status/2 optional callback functions that, if exported by the callback module, are invoked when sys:get_status/1,2 are called. Add unit tests to ensure that format_status/2 functions exported from a gen_fsm callback module and a gen_server callback module are called when sys:get_status/1,2 are called.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/sys.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/stdlib/src/sys.erl b/lib/stdlib/src/sys.erl
index e0f2dbcd3c..12209c16d7 100644
--- a/lib/stdlib/src/sys.erl
+++ b/lib/stdlib/src/sys.erl
@@ -245,8 +245,17 @@ do_cmd(SysState, Other, _Parent, _Mod, Debug, Misc) ->
{SysState, {error, {unknown_system_msg, Other}}, Debug, Misc}.
get_status(SysState, Parent, Mod, Debug, Misc) ->
+ PDict = get(),
+ FmtMisc =
+ case erlang:function_exported(Mod, format_status, 2) of
+ true ->
+ FmtArgs = [PDict, SysState, Parent, Debug, Misc],
+ Mod:format_status(normal, FmtArgs);
+ _ ->
+ Misc
+ end,
{status, self(), {module, Mod},
- [get(), SysState, Parent, Debug, Misc]}.
+ [PDict, SysState, Parent, Debug, FmtMisc]}.
%%-----------------------------------------------------------------
%% These are the system debug commands.