Permalink
Browse files

Using the standard Erlang logger

  • Loading branch information...
1 parent a6ef7da commit 8813d049c9c426d86c57ac9f7325253255df9666 @agfeo agfeo committed Mar 21, 2011
Showing with 22 additions and 28 deletions.
  1. +4 −8 src/tcp_serv.erl
  2. +2 −2 src/test.erl
  3. +8 −10 src/xmlrpc.erl
  4. +1 −1 src/xmlrpc_decode.erl
  5. +1 −1 src/xmlrpc_encode.erl
  6. +6 −6 src/xmlrpc_http.erl
View
@@ -55,10 +55,6 @@
start_link(Args) -> start_link(Args, 60000).
start_link(Args, Timeout) ->
- application:start(log4erl),
- log4erl:conf("priv/log4erl.conf"),
- log4erl:debug("exml: ============================================="),
- log4erl:debug("exml: TCP server started"),
Pid = proc_lib:spawn_link(?MODULE, init, [self(), Args]),
receive
{Pid, started} -> {ok, Pid};
@@ -133,10 +129,10 @@ cleanup(State) -> gen_tcp:close(State#state.listen_socket).
%% Exported: start_seesion/3
start_session(Parent, {M, F, A}, ListenSocket) ->
- log4erl:debug("exml: TCP start session ~p", [ListenSocket]),
- log4erl:debug("exml: M ~p", [M]),
- log4erl:debug("exml: F ~p", [F]),
- log4erl:debug("exml: A ~p", [A]),
+ error_logger:info_msg("exml: TCP start session ~p", [ListenSocket]),
+ error_logger:info_msg("exml: M ~p", [M]),
+ error_logger:info_msg("exml: F ~p", [F]),
+ error_logger:info_msg("exml: A ~p", [A]),
case gen_tcp:accept(ListenSocket) of
{ok, Socket} ->
Parent ! start_session,
View
@@ -3,7 +3,7 @@
-export([decode/2]).
decode(State, Payload) ->
- log4erl:debug("TEST: Payload received ~p", [Payload]),
+ error_logger:info_msg("TEST: Payload received ~p", [Payload]),
P = {response, [102012]},
- log4erl:debug("TEST: Encoded Response ~p", [P]),
+ error_logger:info_msg("TEST: Encoded Response ~p", [P]),
{true, 60000, State, P}.
View
@@ -62,27 +62,27 @@ call(Socket, URI, Payload, KeepAlive, Timeout) ->
{ok, Header} ->
handle_payload(Socket, KeepAlive, Timeout, Header);
{error, Reason} when KeepAlive == false ->
- log4erl:error("exml: call SOCKET CLOSED (1) ~p", [Reason]),
+ error_logger:error_msg("exml: call SOCKET CLOSED (1) ~p", [Reason]),
gen_tcp:close(Socket),
{error, Reason};
{error, Reason} ->
- log4erl:error("exml: call SOCKET CLOSED (1) ~p", [Reason]),
+ error_logger:error_msg("exml: call SOCKET CLOSED (1) ~p", [Reason]),
{error, Socket, Reason}
end;
{error, Reason} when KeepAlive == false ->
- log4erl:error("exml: call SOCKET CLOSED (1) ~p", [Reason]),
+ error_logger:error_msg("exml: call SOCKET CLOSED (1) ~p", [Reason]),
gen_tcp:close(Socket),
{error, Reason};
{error, Reason} ->
- log4erl:error("exml: call SOCKET CLOSED (1) ~p", [Reason]),
+ error_logger:error_msg("exml: call SOCKET CLOSED (1) ~p", [Reason]),
{error, Socket, Reason}
end;
{error, Reason} when KeepAlive == false ->
- log4erl:error("Socket closed (5) ~p", [Reason]),
+ error_msg:error_logger("Socket closed (5) ~p", [Reason]),
gen_tcp:close(Socket),
{error, Reason};
{error, Reason} ->
- log4erl:error("Socket closed (6) ~p", [Reason]),
+ error_logger:error_msg("Socket closed (6) ~p", [Reason]),
{error, Socket, Reason}
end.
@@ -108,10 +108,10 @@ parse_response(Socket, Timeout) ->
{ok,"HTTP/1.1 200 \r\n"} -> parse_header(Socket, Timeout);
{ok,"HTTP/1.1 200 OK\r\n"} -> parse_header(Socket, Timeout);
{ok, StatusLine} ->
- log4erl:error("exml: Parse error ~p", [StatusLine]),
+ error_logger:error_msg("exml: Parse error ~p", [StatusLine]),
{error, StatusLine};
{error, Reason} ->
- log4erl:error("exml: Parse error ~p", [Reason]),
+ error_logger:error_msg("exml: Parse error ~p", [Reason]),
{error, Reason}
end.
@@ -190,8 +190,6 @@ start_link(Port, MaxSessions, Timeout, Handler, State) ->
start_link(all, Port, MaxSessions, Timeout, Handler, State).
start_link(IP, Port, MaxSessions, Timeout, Handler, State) ->
- application:start(log4erl),
- log4erl:conf("priv/log4erl.conf"),
OptionList = [{active, false}, {reuseaddr, true}|ip(IP)],
SessionHandler = {xmlrpc_http, handler, [Timeout, Handler, State]},
tcp_serv:start_link([Port, MaxSessions, OptionList, SessionHandler]).
View
@@ -75,7 +75,7 @@ decode_element(#xmlElement{name = methodResponse} = MethodResponse)
end
end;
decode_element(E) ->
- log4erl:error("exml: decode_element BAD ELEMENT ~p", [E]),
+ error_logger:error_msg("exml: decode_element BAD ELEMENT ~p", [E]),
{error, {bad_element, E}}.
match_element(NameList, Content) -> match_element(throw, NameList, Content).
View
@@ -63,7 +63,7 @@ payload({response, [Param]} = _Payload) ->
"</methodResponse>"]}
end;
payload(Payload) ->
- log4erl:error("exml: payload BAD PAYLOAD ~p", [Payload]),
+ error_logger:error_msg("exml: payload BAD PAYLOAD ~p", [Payload]),
{error, {bad_payload, Payload}}.
encode_params(Params) -> encode_params(Params, []).
View
@@ -52,7 +52,7 @@ handler(Socket, Timeout, Handler, State) ->
send(Socket, StatusCode),
handler(Socket, Timeout, Handler, State);
{error, Reason} ->
- log4erl:error("exml: handler ERROR ~p", [Reason]),
+ error_logger:error_msg("exml: handler ERROR ~p", [Reason]),
{error, Reason}
end.
@@ -72,7 +72,7 @@ parse_request(Socket, Timeout) ->
_ -> {status, 400}
end;
{error, Reason} ->
- log4erl:error("exml: parse_request ERROR ~p", [Reason]),
+ error_logger:error_msg("exml: parse_request ERROR ~p", [Reason]),
{error, Reason}
end.
@@ -118,7 +118,7 @@ parse_header(Socket, Timeout, Header) ->
parse_header(Socket, Timeout, Header)
end;
{error, Reason} ->
- log4erl:error("exml: parse_header ERROR ~p", [Reason]),
+ error_logger:error_msg("exml: parse_header ERROR ~p", [Reason]),
{error, Reason}
end.
@@ -139,11 +139,11 @@ handle_payload(Socket, Timeout, Handler, State,
eval_payload(Socket, Timeout, Handler, State, Connection,
DecodedPayload);
{error, Reason} when Connection == close ->
- log4erl:error("exml: handle_payload ERROR ~p", [Reason]),
+ errro_logger:error_msg("exml: handle_payload ERROR ~p", [Reason]),
?ERROR_LOG({xmlrpc_decode, payload, Payload, Reason}),
send(Socket, 400);
{error, Reason} ->
- log4erl:error("exml: handle_payload ERROR ~p", [Reason]),
+ error_logger:error_msg("exml: handle_payload ERROR ~p", [Reason]),
?ERROR_LOG({xmlrpc_decode, payload, Payload, Reason}),
send(Socket, 400),
handler(Socket, Timeout, Handler, State)
@@ -189,7 +189,7 @@ encode_send(Socket, StatusCode, ExtraHeader, Payload) ->
?DEBUG_LOG({encoded_response, lists:flatten(EncodedPayload)}),
send(Socket, StatusCode, ExtraHeader, EncodedPayload);
{error, Reason} ->
- log4erl:error("exml: encode_send ERROR ~p", [Reason]),
+ error_logger:error_msg("exml: encode_send ERROR ~p", [Reason]),
?ERROR_LOG({xmlrpc_encode, payload, Payload, Reason}),
send(Socket, 500)
end.

0 comments on commit 8813d04

Please sign in to comment.