Permalink
Browse files

crappy xml based output

  • Loading branch information...
1 parent b59f79a commit eacb84ed851ccc90a222433020d164fff5d2ba2d @simulacre committed Mar 1, 2012
Showing with 33 additions and 4 deletions.
  1. +32 −2 src/rabbit_events_handler.erl
  2. +1 −2 src/rabbitmq_events.app.src
@@ -24,11 +24,40 @@ handle_call(_Request, State) ->
rabbit_log:info("[events] got state that isn't understood ~p.~n", [State]),
{ok, not_understood, State}.
-handle_event(Event, State) ->
- rabbit_log:info("[events] caught an event ~p in state ~p.~n", [Event, State]),
+%%------------------------------------------------------------------------------------------------------------
+fields_to_xml_simple(Fields) ->
+ [ {field, [{name, K}], [V]} || {K, V} <- Fields ].
+
+handle_event({event, connection_created, Event, _}, State) ->
+ %log_event(connection_created, Event),
+ %MEvent = [[address,unknown], [port,unknown]],
+ MEvent = [{address,unknown}, {port,unknown},
+ {host,"<rabbit@kiff.2.207.0>"}],
+ % {peer_address,unknown}, {peer_port,unknown},
+ % {user,"guest"}, {vhost,"/"},
+ % {client_properties,[]}, {type,direct}],
+ %rabbit_log:info(mochijson2:encode(MEvent)),
+ MFields = fields_to_xml_simple(MEvent),
+ rabbit_log:info(xmerl:export_simple(MFields, xmerl_xml)),
+ {ok, State};
+
+
+handle_event({event, Type, Event, _}, State) ->
+ rabbit_log:info("[events:~p] caught an event ~p in state ~p.~n", [Type, Event, State]),
+ log_event(Type, Event),
+ %io:write(mochijson2:encode(tuple_to_list(Event))),
+ %rabbit_log:info("[events] caught an event ~p in state ~p.~n", [mochijson2:encode(Event), mochijson2:encode(State)]),
+ %rabbit_log:info("[events] caught an event ~p in state ~p.~n", [Event, State]),
{ok, State}.
+
+log_event(Type, Event) ->
+ rabbit_log:info("[events:~p] ~p.~n", [Type, Event]).
+
+%%------------------------------------------------------------------------------------------------------------
+
handle_info(_Info, State) ->
+ %rabbit_log:info("[events] caught an info ~p for state ~p.~n", [mochijson2:encode(_Info), mochijson2:encode(State)]),
rabbit_log:info("[events] caught an info ~p for state ~p.~n", [_Info, State]),
{ok, State}.
@@ -39,3 +68,4 @@ terminate(_Arg, _State) ->
code_change(_OldVsn, State, _Extra) ->
rabbit_log:info("[events] code change called.~n", []),
{ok, State}.
+
@@ -5,5 +5,4 @@
{registered, []},
{mod, {rabbit_events_app, []}},
{env, []},
- {applications, [kernel, stdlib, rabbit]}]}.
-
+ {applications, [kernel, stdlib]}]}.

0 comments on commit eacb84e

Please sign in to comment.