Commit f585c7f9 authored by benoît chesneau's avatar benoît chesneau

remove lager dependency

parent 5aaaf0b5
Pipeline #8888728 (#) passed with stage
in 1 minute and 9 seconds
{erl_opts, [
debug_info,
{parse_transform, lager_transform}
debug_info
]}.
{deps, [
{lager, "3.2.1"},
{ranch, "1.2.1"}
]}.
{"1.1.0",
[{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.8">>},1},
{<<"lager">>,{pkg,<<"lager">>,<<"3.2.1">>},0},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.2.1">>},0}]}.
[
{pkg_hash,[
{<<"goldrush">>, <<"2024BA375CEEA47E27EA70E14D2C483B2D8610101B4E852EF7F89163CDB6E649">>},
{<<"lager">>, <<"EEF4E18B39E4195D37606D9088EA05BF1B745986CF8EC84F01D332456FE88D17">>},
{<<"ranch">>, <<"A6FB992C10F2187B46FFD17CE398DDF8A54F691B81768F9EF5F461EA7E28C762">>}]}
].
......@@ -14,7 +14,6 @@
{applications,
[kernel,
stdlib,
lager,
crypto,
asn1,
public_key,
......
......@@ -166,14 +166,14 @@ do_call(Name, CallType, Mod, Fun, Args) ->
ok ->
{ok, Headers};
Error ->
lager:error(
error_logger:error_msg(
"teleport: error sending request ~p on ~s: ~w",
[[CallType, Mod, Fun, Args], Name, Error]
),
Error
end;
Error ->
lager:error("teleport: error while retrieving a connection for ~p", [Name]),
error_logger:error_msg("teleport: error while retrieving a connection for ~p", [Name]),
Error
end.
......@@ -297,22 +297,22 @@ wait_handshake(info, {OK, Sock, Payload}, Data = #{ sock := Sock, ok := OK}) ->
#{name := Name, host := Host} = Data,
try erlang:binary_to_term(Payload) of
{connected, PeerNode} ->
lager:info("teleport: client connected to peer-node ~p[~p]~n", [Name, PeerNode]),
error_logger:info_msg("teleport: client connected to peer-node ~p[~p]~n", [Name, PeerNode]),
ets:insert(teleport_incoming_conns, {self(), Host, PeerNode}),
teleport_monitor:linkup(Name),
{next_state, wait_for_data, activate_socket(Data#{peer_node => PeerNode})};
{connection_rejected, Reason} ->
lager:warning("teleport: connection rejected", [Reason]),
error_logger:warning_msg("teleport: connection rejected", [Reason]),
handle_conn_closed(Data, wait_handshake, {connection_rejected, Reason}),
{stop, normal, Data};
heartbeat ->
{keep_statee, activate_socket(Data#{missed_heartbeats => 0})};
_OtherMsg ->
lager:warning("teleport: got unknown message ~p~n", [_OtherMsg]),
error_logger:warning_msg("teleport: got unknown message ~p~n", [_OtherMsg]),
{keep_state, activate_socket(Data)}
catch
error:badarg ->
lager:warning(
error_logger:warning_msg(
"teleport: client for ~p error during handshake to bad data : ~w",
[Name, Payload]
),
......@@ -386,7 +386,7 @@ wait_for_data(info, {OK, Sock, PayLoad}, Data = #{ sock := Sock, ok := OK}) ->
catch
error:badarg ->
#{ db := Db, host := Host, port:= Port} = Data,
lager:info(
error_logger:info_msg(
"teleport: ~p, tcp error with ~p:~p : ~w",
[Db, Host, Port, Data]
),
......@@ -418,7 +418,7 @@ handle_event(info, _State, heartbeat, Data) ->
M2 = M + 1,
if
M2 > 3 ->
lager:warning("Missed ~p heartbeats from ~p. Closing connection~n", [M2, PeerNode]),
error_logger:warning_msg("Missed ~p heartbeats from ~p. Closing connection~n", [M2, PeerNode]),
_ = cleanup(Data),
{stop, normal, Data};
true ->
......@@ -434,7 +434,7 @@ handle_event(EventType, State, Event, Data = #{ transport := Transport, sock :=
{Error, Sock, Reason} ->
handle_conn_closed({Error, Reason}, State, Data);
_ ->
lager:error(
error_logger:error_msg(
"teleport: client [~p] received an unknown event: ~p ~p",
[State, Event, EventType]
),
......@@ -442,7 +442,7 @@ handle_event(EventType, State, Event, Data = #{ transport := Transport, sock :=
end.
handle_conn_closed(Error, State, Data = #{name := Name, peer_node := PeerNode}) ->
lager:debug(
error_logger:info_msg(
"teleport:lost client connection in ~p from ~p[~p]. Reason: ~p~n",
[State, Name, PeerNode, Error]
),
......
......@@ -72,24 +72,24 @@ wait_for_handshake(info, {OK, Sock, PayLoad}, Data = #{ sock := Sock, ok := OK})
Cookie = erlang:get_cookie(),
try erlang:binary_to_term(PayLoad) of
{connect, ClientCookie, PeerNode} when ClientCookie =:= Cookie ->
lager:info("teleport: server connected to peer node: ~p~n", [PeerNode]),
error_logger:info_msg("teleport: server connected to peer node: ~p~n", [PeerNode]),
ets:insert(teleport_incoming_conns, {self(), PeerHost, PeerNode}),
ok = send_handshake(Data),
{next_state, wait_for_data, activate_socket(Data)};
{connect, _InvalidCookie} ->
lager:warning("teleport: invalid cookie from ~p", [PeerHost]),
error_logger:warning_msg("teleport: invalid cookie from ~p", [PeerHost]),
{stop, normal, Data};
heartbeat ->
{keep_state, activate_socket(Data#{missed_heartbeats => 0})};
OtherMsg ->
lager:error(
error_logger:error_msg(
"teleport: invalid message from ~p: ~w",
[PeerHost, OtherMsg]
),
{stop, normal, Data}
catch
error:badarg ->
lager:warning("teleport: bad handshake from ~p: ~w", [PeerHost, Data]),
error_logger:warning_msg("teleport: bad handshake from ~p: ~w", [PeerHost, Data]),
{stop, normal, Data}
end;
wait_for_handshake(EventType, Event, Data) ->
......@@ -125,11 +125,11 @@ wait_for_data(info, {OK, Sock, PayLoad}, Data = #{ sock := Sock, ok := OK, chann
heartbeat ->
{keep_state, activate_socket(Data#{missed_heartbeats => 0})};
OtherMsg ->
lager:error("teleport: invalid message: ~p~n", [OtherMsg]),
error_logger:error_msg("teleport: invalid message: ~p~n", [OtherMsg]),
{stop, error, normal}
catch
error:badarg ->
lager:warning("teleport: bad data: ~w", [Data]),
error_logger:warning_msg("teleport: bad data: ~w", [Data]),
cleanup(Data),
{stop, normal, Data}
end;
......@@ -147,7 +147,7 @@ handle_event(info, _State, heartbeat, Data) ->
M2 = M + 1,
if
M2 > 3 ->
lager:warning("Missed ~p heartbeats from ~p. Closing connection~n", [M2, PeerHost]),
error_logger:warning_msg("Missed ~p heartbeats from ~p. Closing connection~n", [M2, PeerHost]),
_ = cleanup(Data),
{stop, normal, Data};
true ->
......@@ -170,7 +170,7 @@ handle_event(EventType, State, Event, Data) ->
{Error, Sock, Reason} ->
handle_conn_closed({Error, Reason}, State, Data);
_ ->
lager:error(
error_logger:error_msg(
"teleport: server [~p] received an unknown event: ~p ~p",
[State, Event, EventType]
),
......@@ -178,7 +178,10 @@ handle_event(EventType, State, Event, Data) ->
end.
handle_conn_closed(Error, State, Data = #{ peer_host := Host}) ->
lager:debug("teleport: connection from ~p closed (~p). Reason: ~p~n", [Host, State, Error]),
error_logger:info_msg(
"client connection on ~p closed during ~p: ~p",
Host, State, Error
),
{stop, normal, cleanup(Data)}.
worker(Mod, Fun, Args) -> apply(Mod, Fun, Args).
......
......@@ -33,10 +33,10 @@ start_link() ->
start_server(Name, Config) when is_map(Config) ->
case supervisor:start_child(?MODULE, server_spec(Name, Config)) of
{ok, Pid} ->
lager:info("teleport: start server: ~s [~s]", [get_uri(Name), Name]),
error_logger:info_msg("teleport: start server: ~s [~s]", [get_uri(Name), Name]),
{ok, Pid};
{error, {already_started, Pid}} ->
lager:info("teleport: server already started: ~s [~s]", [get_uri(Name), Name]),
error_logger:info_msg("teleport: server already started: ~s [~s]", [get_uri(Name), Name]),
{ok, Pid}
end;
start_server(Name, Config) when is_list(Config) ->
......@@ -49,10 +49,10 @@ stop_server(Name) ->
ok ->
_ = supervisor:delete_child(?MODULE, listener_name(Name)),
ranch_server:cleanup_listener_opts(Name),
lager:info("teleport: stopped server ~s~n", [Uri]),
error_logger:info_msg("teleport: stopped server ~s~n", [Uri]),
ok;
Error ->
lager:error("teleport: error stopping server ~p~n", [Uri]),
error_logger:error_msg("teleport: error stopping server ~p~n", [Uri]),
Error
end.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment