Skip to content

Commit

Permalink
Fix dialyzer warnings
Browse files Browse the repository at this point in the history
Add `| undefined` to records that get initialized with not all their
fields set to the proper type (hence get the value undefined). These
fixes allow lager to exist as a dependency in a project and be filtered
through that project's dialyzer run without warnings.
  • Loading branch information
priestjim committed Sep 28, 2016
1 parent bce5504 commit 7598d8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/lager_crash_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

-record(state, {
name :: string(),
fd :: pid(),
inode :: integer(),
fd :: pid() | undefined,
inode :: integer() | undefined,
fmtmaxbytes :: integer(),
size :: integer(),
date :: undefined | string(),
Expand Down Expand Up @@ -119,7 +119,7 @@ schedule_rotation(Date) ->
%% ===== Begin code lifted from riak_err =====

-spec limited_fmt(string(), list(), integer()) -> iolist().
%% @doc Format Fmt and Args similar to what io_lib:format/2 does but with
%% @doc Format Fmt and Args similar to what io_lib:format/2 does but with
%% limits on how large the formatted string may be.
%%
%% If the Args list's size is larger than TermMaxSize, then the
Expand Down
12 changes: 6 additions & 6 deletions src/lager_file_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
-record(state, {
name :: string(),
level :: {'mask', integer()},
fd :: file:io_device(),
inode :: integer(),
fd :: file:io_device() | undefined,
inode :: integer() | undefined,
flap=false :: boolean(),
size = 0 :: integer(),
date :: undefined | string(),
Expand All @@ -81,7 +81,7 @@
{check_interval, non_neg_integer()} | {formatter, atom()} |
{formatter_config, term()}.

-spec init([option(),...]) -> {ok, #state{}} | {error, bad_config}.
-spec init([option(),...]) -> {ok, #state{}} | {error, {fatal,bad_config}}.
init({FileName, LogLevel}) when is_list(FileName), is_atom(LogLevel) ->
%% backwards compatibility hack
init([{file, FileName}, {level, LogLevel}]);
Expand Down Expand Up @@ -158,7 +158,7 @@ handle_event({log, Message},
NewState = case Drop > 0 of
true ->
Report = io_lib:format(
"lager_file_backend dropped ~p messages in the last second that exceeded the limit of ~p messages/sec",
"lager_file_backend dropped ~p messages in the last second that exceeded the limit of ~p messages/sec",
[Drop, Hwm]),
ReportMsg = lager_msg:new(Report, warning, [], []),
write(State, lager_msg:timestamp(ReportMsg),
Expand Down Expand Up @@ -652,7 +652,7 @@ filesystem_test_() ->
lager:log(error, self(), "Test message1"),
gen_event:call(lager_event, {lager_file_backend, "test.log"}, rotate, infinity),
lager:log(error, self(), "Test message1"),
?assert(filelib:is_regular("test.log.0"))
?assert(filelib:is_regular("test.log.0"))
end
},
{"sync_on option should work",
Expand Down Expand Up @@ -832,7 +832,7 @@ trace_files_test_() ->
catch ets:delete(lager_config),
application:unset_env(lager, traces),
application:stop(lager),

file:delete("events.log"),
file:delete("test.log"),
file:delete("debug.log"),
Expand Down

0 comments on commit 7598d8c

Please sign in to comment.