anchor.diff:  handle_event({stop_watching, Who}, StateName, #state{observers=Observers}=State) ->
       State1 = State#state{observers=lists:delete(Who, Observers)},
       {next_state, StateName, State1};
  -handle_event(_Event, StateName, State) ->
  +handle_event({logging, Level}, StateName, State) ->
  +    State1 = State#state{logging=Level},
  +    {next_state, StateName, State1};
  +handle_event(_Event, StateName, #state{name=Name}=State) ->
  +    lager:error("FSM for ~p received unexpected event ~p", [Name, _Event]),
       {next_state, StateName, State}.
   
   handle_sync_event(_Event, _From, StateName, State) ->
  
positive.code:         _ -> ok
      end.
  
  
  current_state(Name) ->
      case catch gproc:lookup_pid({n,l,Name}) of
          {'EXIT', _} ->
  
negative.code:          init/1,
           terminate/3]).
  
  -include("pushy_sql.hrl").
  
  -type node_name() :: binary().
  -type node_state() :: binary().
  -type logging_level() :: 'verbose' | 'normal'.
  -type status_atom() :: 'idle' | 'ready' | 'restarting' | 'running'.
  -type status_binary() :: binary(). % <<"idle">> | <<"ready">> | <<"restarting">> | <<"running">>.
  -type gproc_error() :: ok | {error, no_node}.
  
  -record(state, {dead_interval    :: integer(),
                  name             :: binary(),
                  heartbeats = 0   :: integer(),
                  logging = normal :: logging_level(),
                  observers = [],
                  tref}).
  
  
  %%%
  %%% External API
  %%%
  -spec start_link(node_name(),HeartbeatInterval::integer(),DeadIntervalCount::integer()) ->
                          'ignore' | {'error',_} | {'ok',pid()}.
  start_link(Name, HeartbeatInterval, DeadIntervalCount) ->
      gen_fsm:start_link(?MODULE, [Name, HeartbeatInterval, DeadIntervalCount], []).
  
  -spec heartbeat({'heartbeat',node_name(),node_state()}) -> gproc_error().
  heartbeat({heartbeat, NodeName, NodeState}) ->
      case catch gproc:send({n,l,NodeName},
              {heartbeat, NodeName, status_to_atom(NodeState)}) of
  