my debug handler won't stick

Martin Bjorklund mbj@REDACTED
Tue Jan 2 11:03:02 CET 2001


"Vance Shipley" <vances@REDACTED> wrote:
> 
> The sys module has a function to install a custom debug
> function which will be called whenever a system event is
> generated.  It is defined as:
> 
> 	sys:install(Name, Func, FuncState) -> done | NewFuncState
> 
> So I create a debug function like this:
> 
> 	dbg_fun(FuncState, Event, ProcState) ->
> 		io:fwrite("~w ~w ~w~n", [FuncState, Event, ProcState]),
> 		FuncState.
> 
> and install it with:
> 
> 	sys:install(testing, {test, dbg_fun}, foo)


You probaly mean:

 	sys:install(testing, {{test, dbg_fun}, foo})


> Now the next time I send a message ('bar') to testing I get:
> 
> 	foo {in, {'$gen_event', bar}} {testing, state1}
> 
> Which is great however subsequent messages don't result in
> dbg_fun getting called.

You can check the status of you process by calling sys:get_status/1.
There you'll see if your handler is installed:

2> sys:install(error_logger, {{test, dbg_fun}, foo}).
ok
3> sys:get_status(error_logger).
{status,<0.4.0>,
        {module,gen_event},
        [[{'$ancestors',[<0.1.0>]},
          {'$initial_call',{gen,init_it,
                                [gen_event,
                                 <0.1.0>,
                                 <0.1.0>,
                                 {local,error_logger},
                                 [],
                                 [],
                                 []]}}],
         running,
         <0.1.0>,
         [{{test,dbg_fun},foo}],        <-----------------
         [error_logger,
          [{handler,error_logger,false,[],false},
           {handler,error_logger_tty_h,false,{<0.18.0>,error_logger},false}]]]}


This works fine for me.


/martin




More information about the erlang-questions mailing list