diff options
author | Erlang/OTP <[email protected]> | 2009-12-04 09:32:50 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2009-12-04 09:32:50 +0000 |
commit | b1821b0f692deb93b9cae69ca9a1a591f5530474 (patch) | |
tree | e48846f9d9734b5bda7088acc23d44623b99030a /lib/stdlib/src | |
parent | 5bf73e1dc401a205e02432d3e8ebedde0ad7f117 (diff) | |
parent | 88b530ea24977081020feb2123124063e58dfc12 (diff) | |
download | otp-b1821b0f692deb93b9cae69ca9a1a591f5530474.tar.gz otp-b1821b0f692deb93b9cae69ca9a1a591f5530474.tar.bz2 otp-b1821b0f692deb93b9cae69ca9a1a591f5530474.zip |
Merge branch 'sv/sys_get_status' into ccase/r13b04_dev
* sv/sys_get_status:
Teach sys:get_status/1,2 to call Mod:format_status/2
gen_fsm: Fix format_status/2 to handle Pids
OTP-8324 The ability for the gen_server and gen_fsm callback modules to
format their own state for display under the sys:get_status/1,2
calls has been restored and documented. (Thanks to Steve
Vinoski.)
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/gen_fsm.erl | 7 | ||||
-rw-r--r-- | lib/stdlib/src/sys.erl | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/stdlib/src/gen_fsm.erl b/lib/stdlib/src/gen_fsm.erl index f3775f967a..ba0275ae2b 100644 --- a/lib/stdlib/src/gen_fsm.erl +++ b/lib/stdlib/src/gen_fsm.erl @@ -603,7 +603,12 @@ get_msg(Msg) -> Msg. format_status(Opt, StatusData) -> [PDict, SysState, Parent, Debug, [Name, StateName, StateData, Mod, _Time]] = StatusData, - Header = lists:concat(["Status for state machine ", Name]), + NameTag = if is_pid(Name) -> + pid_to_list(Name); + is_atom(Name) -> + Name + end, + Header = lists:concat(["Status for state machine ", NameTag]), Log = sys:get_debug(log, Debug, []), Specfic = case erlang:function_exported(Mod, format_status, 2) of 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. |