patch for sys:get_status to call format_status/2

Steve Vinoski vinoski@REDACTED
Wed Sep 16 16:52:33 CEST 2009


I've never gotten any replies offering an opinion on whether or not the
patch below is acceptable. Has anyone had a chance to evaluate it yet? Just
curious.
thanks,
--steve

On Wed, Aug 26, 2009 at 9:12 AM, Steve Vinoski <vinoski@REDACTED> wrote:

> [I've been trying to send this patch to erlang-bugs and erlang-questions
> for the past few days, but it hasn't shown up. Trying erlang-patches this
> time.]
> Back in March of this year the following thread appeared in
> erlang-questions regarding the undocumented format_status/2 function that
> apparently used to be called by sys:get_status if provided by a behavior
> module:
>
> <http://erlang.org/pipermail/erlang-questions/2009-March/042242.html>
>
> I searched back all the way to version R6B but found no code that made
> that call except within SASL's si_sasl_supp module, yet I see that
> various modules such as gen_server, gen_event, gen_fsm, and os_mon's disksup
> and memsup each provide a format_status/2 function, plus the generic
> behaviors also check to see if modules implementing them also provide
> a format_status/2 function, calling it if they do and thus allowing you
> to format how sys:get_status prints out your gen_server, gen_fsm, etc.
> state. Seems like a shame to let that code go to waste! :-) I agree with
> the originator of that thread that being allowed to provide a
> special format_status/2 when implementing a behavior can be very handy, so
> below find a simple patch for R13B01 that implements it.
>
> --steve
>
> --- lib/stdlib/src/sys.erl~ 2009-03-12 08:18:15.000000000 -0400
> +++ lib/stdlib/src/sys.erl 2009-08-26 01:25:13.000000000 -0400
> @@ -245,8 +245,17 @@
>      {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.
>
>


More information about the erlang-patches mailing list