Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make the dialyzer happy.

  • Loading branch information...
commit ec61e88d8a8a4b4c90b5ebecfa7a7d53be00d46c 1 parent 077f218
Andrew Thompson Vagabond authored
2  include/lager.hrl
View
@@ -52,7 +52,7 @@
end).
-define(SHOULD_LOG(Level),
- ?LEVEL2NUM(Level) =< lager_mochiglobal:get(loglevel, ?LOG_NONE)).
+ lager_util:level_to_num(Level) =< lager_mochiglobal:get(loglevel, ?LOG_NONE)).
%% internal non-blocking logging call
-define(INT_LOG(Level, Format, Args),
1  src/error_logger_lager_h.erl
View
@@ -49,6 +49,7 @@
-define(CRASH_LOG(Event),
gen_server:cast(lager_crash_log, {log, Event})).
+-spec init(any()) -> {ok, {}}.
init(_) ->
{ok, {}}.
13 src/lager.erl
View
@@ -26,6 +26,11 @@
get_loglevel/1, set_loglevel/2, set_loglevel/3, get_loglevels/0,
minimum_loglevel/1]).
+-type log_level() :: debug | info | notice | warning | error | critical | alert | emergency.
+-type log_level_number() :: 0..7.
+
+-export_type([log_level/0, log_level_number/0]).
+
%% API
%% @doc Start the application. Mainly useful for using `-s lager' as a command
@@ -44,6 +49,8 @@ start_ok(App, {error, Reason}) ->
erlang:error({app_start_failed, App, Reason}).
%% @private
+-spec log(log_level(), atom(), atom(), pos_integer(), pid(), tuple(), list()) ->
+ ok | {error, lager_not_running}.
log(Level, Module, Function, Line, Pid, Time, Message) ->
Timestamp = lager_util:format_time(Time),
Msg = [io_lib:format("[~p] ~p@~p:~p:~p ", [Level, Pid, Module,
@@ -51,6 +58,8 @@ log(Level, Module, Function, Line, Pid, Time, Message) ->
safe_notify(lager_util:level_to_num(Level), Timestamp, Msg).
%% @private
+-spec log(log_level(), atom(), atom(), pos_integer(), pid(), tuple(), string(), list()) ->
+ ok | {error, lager_not_running}.
log(Level, Module, Function, Line, Pid, Time, Format, Args) ->
Timestamp = lager_util:format_time(Time),
Msg = [io_lib:format("[~p] ~p@~p:~p:~p ", [Level, Pid, Module,
@@ -58,12 +67,14 @@ log(Level, Module, Function, Line, Pid, Time, Format, Args) ->
safe_notify(lager_util:level_to_num(Level), Timestamp, Msg).
%% @doc Manually log a message into lager without using the parse transform.
+-spec log(log_level(), pid(), list()) -> ok | {error, lager_not_running}.
log(Level, Pid, Message) ->
Timestamp = lager_util:format_time(),
Msg = [io_lib:format("[~p] ~p ", [Level, Pid]), string:strip(lists:flatten(Message), right, $\n)],
safe_notify(lager_util:level_to_num(Level), Timestamp, Msg).
%% @doc Manually log a message into lager without using the parse transform.
+-spec log(log_level(), pid(), string(), list()) -> ok | {error, lager_not_running}.
log(Level, Pid, Format, Args) ->
Timestamp = lager_util:format_time(),
Msg = [io_lib:format("[~p] ~p ", [Level, Pid]), string:strip(lists:flatten(io_lib:format(Format, Args)), right, $\n)],
@@ -91,7 +102,7 @@ set_loglevel(Handler, Ident, Level) when is_atom(Level) ->
get_loglevel(Handler) ->
case gen_event:call(lager_event, Handler, get_loglevel, infinity) of
X when is_integer(X) ->
- ?NUM2LEVEL(X);
+ lager_util:num_to_level(X);
Y -> Y
end.
16 src/lager_crash_log.erl
View
@@ -147,14 +147,14 @@ perhaps_a_sasl_report(error_report, {Pid, Type, Report}, FmtMaxBytes) ->
false ->
{ignore, ignore, ignore, false}
end;
-perhaps_a_sasl_report(info_report, {Pid, Type, Report}, FmtMaxBytes) ->
- case lager_stdlib:is_my_info_report(Type) of
- true ->
- {sasl_type_to_report_head(Type), Pid,
- sasl_limited_str(Type, Report, FmtMaxBytes), false};
- false ->
- {ignore, ignore, ignore, false}
- end;
+%perhaps_a_sasl_report(info_report, {Pid, Type, Report}, FmtMaxBytes) ->
+ %case lager_stdlib:is_my_info_report(Type) of
+ %true ->
+ %{sasl_type_to_report_head(Type), Pid,
+ %sasl_limited_str(Type, Report, FmtMaxBytes), false};
+ %false ->
+ %{ignore, ignore, ignore, false}
+ %end;
perhaps_a_sasl_report(_, _, _) ->
{ignore, ignore, ignore, false}.
3  src/lager_file_backend.erl
View
@@ -40,12 +40,13 @@
-record(file, {
name :: string(),
level :: integer(),
- fd :: port(),
+ fd :: file:io_device(),
inode :: integer(),
flap=false :: boolean()
}).
%% @private
+-spec init([{string(), lager:log_level()},...]) -> {ok, #state{}}.
init(LogFiles) ->
Files = [begin
case lager_util:open_logfile(Name, true) of
2  src/lager_transform.erl
View
@@ -68,7 +68,7 @@ transform_statement({call, Line, {remote, Line1, {atom, Line2, lager},
{call,Line,
{remote,Line,{atom,Line,lager_mochiglobal},{atom,Line,get}},
[{atom,Line,loglevel},{integer,Line,?LOG_NONE}]},
- {integer, Line, ?LEVEL2NUM(Severity)}},
+ {integer, Line, lager_util:level_to_num(Severity)}},
[{clause,Line,
[{atom,Line,true}], %% yes, we log!
[],
Please sign in to comment.
Something went wrong with that request. Please try again.