Packages
geas
2.7.13
2.11.1
2.11.0
retired
2.10.1
2.10.0
retired
2.9.9
2.9.8
2.9.7
2.9.6
2.9.5
2.9.4
2.9.2
2.9.1
2.9.0
2.8.1
2.8.0
2.7.14
2.7.13
2.7.12
2.7.11
2.7.10
2.7.9
2.7.8
2.7.7
2.7.6
2.7.5
2.7.4
2.7.3
2.7.2
2.7.1
2.7.0
2.6.2
2.6.1
2.6.0
retired
2.5.1
2.5.0
retired
2.4.6
2.4.5
retired
2.4.4
retired
2.4.3
retired
2.4.2
retired
2.4.1
retired
2.4.0
2.3.0
2.2.0
Guess Erlang Application Scattering
Current section
Files
Jump to
Current section
Files
src/geas_logs.hrl
-define(LOG(X, Y),
case erlang:get(X) of
undefined when is_list(Y) -> erlang:put(X, Y) ;
_ when is_list(Y) -> erlang:put(X, erlang:get(X) ++ Y);
undefined when is_tuple(Y) -> erlang:put(X, [Y]) ;
_ when is_tuple(Y) -> erlang:put(X, erlang:get(X) ++ [Y])
end
).
%%-------------------------------------------------------------------------
%% @doc Log levels set
%% @since 2.0.6
%% @end
%%-------------------------------------------------------------------------
loglevels() ->
Conf = get_config(),
Check = Conf#config.log ,
case Check of
false -> [] ;
"" -> ["debug", "notice", "warning", "error", "tip"];
LL -> string:tokens(LL, " ")
end.
%%-------------------------------------------------------------------------
%% @doc Log infos on analyze, and reinit log buffer
%% @since 2.0.6
%% @end
%%-------------------------------------------------------------------------
log() ->
L = get(geas_logs),
LL = loglevels(),
case is_list(L) of
true -> log(L, LL);
false -> ok
end,
c:flush(),
put(geas_logs, []).
log(L) when is_list(L) -> log(L, loglevels());
log(L) -> log([L], loglevels()).
log(L, LogLevels) ->
Fun =
fun(X) -> {Level, Info, File} = X,
case lists:member(atom_to_list(Level), LogLevels) of
true ->
Tag = case Level of
notice -> "(i)";
warning -> "/!\\" ;
error -> "[!]";
tip -> "(?)";
_ -> " @ "
end,
InfoS = lists:flatten(io_lib:format("~p",[Info])) ,
FileInfos = lists:flatten(io_lib:format("~p",[File])) ,
io:format(standard_error, "~s ~s ~s~n",[Tag, string:left(InfoS,30), FileInfos]);
false -> ok
end
end,
lists:foreach(Fun, L).