3 Commits

Author SHA1 Message Date
zxq9 b487f98d9e Merge branch 'master' into eureka 2025-03-05 19:59:10 +09:00
zxq9 1dc686215e Whoops! 2025-01-24 00:05:44 +09:00
zxq9 c8670ae1b9 Static log fun 2025-01-23 23:53:43 +09:00
2 changed files with 16 additions and 5 deletions
+7 -2
View File
@@ -6,8 +6,6 @@
-export([connect/4, slowly_connect/4]).
-include("$zx_include/zx_logger.hrl").
connect(Node = {Host, Port}, Request, From, Timeout) ->
Timer = erlang:send_after(Timeout, self(), timeout),
@@ -236,3 +234,10 @@ url({Node, Port}, Path) when is_list(Node) ->
["https://", Node, ":", integer_to_list(Port), Path];
url({Node, Port}, Path) when is_tuple(Node) ->
["https://", inet:ntoa(Node), ":", integer_to_list(Port), Path].
log(Level, Format, Args) ->
Raw = io_lib:format("~w ~w: " ++ Format, [?MODULE, self() | Args]),
Entry = unicode:characters_to_list(Raw),
logger:log(Level, Entry).
+9 -3
View File
@@ -29,8 +29,6 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
code_change/3, terminate/2]).
%% TODO: Make logging more flexible
-include("$zx_include/zx_logger.hrl").
%%% Type and Record Definitions
@@ -197,7 +195,7 @@ handle_info({'DOWN', Mon, process, PID, Info}, State) ->
NewState = handle_down(PID, Mon, Info, State),
{noreply, NewState};
handle_info(Unexpected, State) ->
ok = log("Unexpected info: ~tp~n", [Unexpected]),
ok = log(warning, "Unexpected info: ~tp~n", [Unexpected]),
{noreply, State}.
@@ -287,3 +285,11 @@ do_request(Request,
do_request(Request, From, State = #s{chain_nodes = {[], Used}}) ->
Fresh = lists:reverse(Used),
do_request(Request, From, State#s{chain_nodes = {Fresh, []}}).
log(Level, Format, Args) ->
Raw = io_lib:format("~w ~w: " ++ Format, [?MODULE, self() | Args]),
Entry = unicode:characters_to_list(Raw),
logger:log(Level, Entry).