This commit is contained in:
2017-12-18 13:29:06 +09:00
parent c47a88c319
commit 83a7a68844
3 changed files with 95 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
-export([log/2, log/3]).
-spec log(Level, Format) -> ok
when Level :: info
| warning
| error,
Format :: string().
%% @private
%% @equiv log(Level, Format, [])
log(Level, Format) ->
log(Level, Format, []).
-spec log(Level, Format, Args) -> ok
when Level :: info
| warning
| error,
Format :: string(),
Args :: [term()].
%% @private
%% A logging abstraction to hide whatever logging back end is actually in use.
%% Format must adhere to Erlang format string rules, and the arity of Args must match
%% the provided format.
log(Level, Format, Args) ->
Tag =
case Level of
info -> "[INFO]";
warning -> "[WARNING]";
error -> "[ERROR]"
end,
io:format("~s ~p: " ++ Format ++ "~n", [Tag, self() | Args]).