couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject [27/50] lager commit: updated refs/heads/import-master to da4419e
Date Thu, 13 Feb 2014 16:43:29 GMT
Fix dialyzer warnings and make all the records typed


Project: http://git-wip-us.apache.org/repos/asf/couchdb-lager/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-lager/commit/faf3096d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-lager/tree/faf3096d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-lager/diff/faf3096d

Branch: refs/heads/import-master
Commit: faf3096d9979cf77bccdf5da124ce6be5a3d6bd7
Parents: d18019b
Author: Andrew Thompson <andrew@hijacked.us>
Authored: Tue Jan 14 17:04:25 2014 -0500
Committer: Andrew Thompson <andrew@hijacked.us>
Committed: Thu Jan 23 23:44:30 2014 -0500

----------------------------------------------------------------------
 rebar.config                   |  2 +-
 src/lager.erl                  |  6 +++---
 src/lager_app.erl              |  2 +-
 src/lager_backend_throttle.erl |  6 +++---
 src/lager_console_backend.erl  |  5 ++++-
 src/lager_crash_log.erl        | 20 ++++++++++----------
 src/lager_file_backend.erl     | 20 ++++++++++----------
 src/lager_format.erl           |  2 +-
 src/lager_handler_watcher.erl  |  6 +++---
 src/lager_util.erl             |  9 ++++-----
 tools.mk                       |  8 +++++++-
 11 files changed, 47 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/rebar.config
----------------------------------------------------------------------
diff --git a/rebar.config b/rebar.config
index 4278d3e..3e0b1c8 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,4 +1,4 @@
-{erl_opts, [debug_info]}.
+{erl_opts, [debug_info, warn_untyped_record]}.
 {erl_first_files, ["src/lager_util.erl"]}.
 {deps, [
         {goldrush, ".*",

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager.erl
----------------------------------------------------------------------
diff --git a/src/lager.erl b/src/lager.erl
index 298a9a8..1931d69 100644
--- a/src/lager.erl
+++ b/src/lager.erl
@@ -191,7 +191,7 @@ trace(Backend, Filter, Level) ->
 stop_trace({_Filter, _Level, Target} = Trace) ->
     {Level, Traces} = lager_config:get(loglevel),
     NewTraces =  lists:delete(Trace, Traces),
-    lager_util:trace_filter([ element(1, T) || T <- NewTraces ]),
+    _ = lager_util:trace_filter([ element(1, T) || T <- NewTraces ]),
     %MinLevel = minimum_loglevel(get_loglevels() ++ get_trace_levels(NewTraces)),
     lager_config:set(loglevel, {Level, NewTraces}),
     case get_loglevel(Target) of
@@ -210,7 +210,7 @@ stop_trace({_Filter, _Level, Target} = Trace) ->
 
 clear_all_traces() ->
     {Level, _Traces} = lager_config:get(loglevel),
-    lager_util:trace_filter(none),
+    _ = lager_util:trace_filter(none),
     lager_config:set(loglevel, {Level, []}),
     lists:foreach(fun(Handler) ->
           case get_loglevel(Handler) of
@@ -319,7 +319,7 @@ add_trace_to_loglevel_config(Trace) ->
     case lists:member(Trace, Traces) of
         false ->
             NewTraces = [Trace|Traces],
-            lager_util:trace_filter([ element(1, T) || T <- NewTraces]),
+            _ = lager_util:trace_filter([ element(1, T) || T <- NewTraces]),
             lager_config:set(loglevel, {MinLevel, [Trace|Traces]});
         _ ->
             ok

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_app.erl
----------------------------------------------------------------------
diff --git a/src/lager_app.erl b/src/lager_app.erl
index d169f80..6052c3a 100644
--- a/src/lager_app.erl
+++ b/src/lager_app.erl
@@ -113,7 +113,7 @@ start(_StartType, _StartArgs) ->
                 end
         end,
 
-    lager_util:trace_filter(none), 
+    _ = lager_util:trace_filter(none), 
 
     {ok, Pid, SavedHandlers}.
 

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_backend_throttle.erl
----------------------------------------------------------------------
diff --git a/src/lager_backend_throttle.erl b/src/lager_backend_throttle.erl
index 14573b0..8b6f3ec 100644
--- a/src/lager_backend_throttle.erl
+++ b/src/lager_backend_throttle.erl
@@ -30,9 +30,9 @@
         code_change/3]).
 
 -record(state, {
-        hwm,
-        window_min,
-        async = true
+        hwm :: non_neg_integer(),
+        window_min :: non_neg_integer(),
+        async = true :: boolean()
     }).
 
 init([Hwm, Window]) ->

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_console_backend.erl
----------------------------------------------------------------------
diff --git a/src/lager_console_backend.erl b/src/lager_console_backend.erl
index cf73d63..ca203ad 100644
--- a/src/lager_console_backend.erl
+++ b/src/lager_console_backend.erl
@@ -24,7 +24,10 @@
 -export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2,
         code_change/3]).
 
--record(state, {level, formatter,format_config,colors=[]}).
+-record(state, {level :: {'mask', integer()},
+                formatter :: atom(),
+                format_config :: any(),
+                colors=[] :: list()}).
 
 -ifdef(TEST).
 -include_lib("eunit/include/eunit.hrl").

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_crash_log.erl
----------------------------------------------------------------------
diff --git a/src/lager_crash_log.erl b/src/lager_crash_log.erl
index eab2275..089e32a 100644
--- a/src/lager_crash_log.erl
+++ b/src/lager_crash_log.erl
@@ -45,14 +45,14 @@
 -export([start_link/5, start/5]).
 
 -record(state, {
-        name,
-        fd,
-        inode,
-        fmtmaxbytes,
-        size,
-        date,
-        count,
-        flap=false
+        name :: string(),
+        fd :: pid(),
+        inode :: integer(),
+        fmtmaxbytes :: integer(),
+        size :: integer(),
+        date :: undefined | string(),
+        count :: integer(),
+        flap=false :: boolean()
 }).
 
 %% @private
@@ -95,7 +95,7 @@ handle_cast(_Request, State) ->
 
 %% @private
 handle_info(rotate, #state{name=Name, count=Count, date=Date} = State) ->
-    lager_util:rotate_logfile(Name, Count),
+    _ = lager_util:rotate_logfile(Name, Count),
     schedule_rotation(Date),
     {noreply, State};
 handle_info(_Info, State) ->
@@ -199,7 +199,7 @@ do_log({log, Event}, #state{name=Name, fd=FD, inode=Inode, flap=Flap,
         true ->
             case lager_util:ensure_logfile(Name, FD, Inode, false) of
                 {ok, {_, _, Size}} when RotSize /= 0, Size > RotSize ->
-                    lager_util:rotate_logfile(Name, Count),
+                    _ = lager_util:rotate_logfile(Name, Count),
                     handle_cast({log, Event}, State);
                 {ok, {NewFD, NewInode, _Size}} ->
                     {Date, TS} = lager_util:format_time(

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_file_backend.erl
----------------------------------------------------------------------
diff --git a/src/lager_file_backend.erl b/src/lager_file_backend.erl
index 779f8ad..96f41bc 100644
--- a/src/lager_file_backend.erl
+++ b/src/lager_file_backend.erl
@@ -62,15 +62,15 @@
         inode :: integer(),
         flap=false :: boolean(),
         size = 0 :: integer(),
-        date,
-        count = 10,
-        formatter,
-        formatter_config,
-        sync_on,
-        check_interval = ?DEFAULT_CHECK_INTERVAL,
-        sync_interval = ?DEFAULT_SYNC_INTERVAL,
-        sync_size = ?DEFAULT_SYNC_SIZE,
-        last_check = os:timestamp()
+        date :: undefined | string(),
+        count = 10 :: integer(),
+        formatter :: atom(),
+        formatter_config :: any(),
+        sync_on :: {'mask', integer()},
+        check_interval = ?DEFAULT_CHECK_INTERVAL :: non_neg_integer(),
+        sync_interval = ?DEFAULT_SYNC_INTERVAL :: non_neg_integer(),
+        sync_size = ?DEFAULT_SYNC_SIZE :: non_neg_integer(),
+        last_check = os:timestamp() :: erlang:timestamp()
     }).
 
 -type option() :: {file, string()} | {level, lager:log_level()} |
@@ -147,7 +147,7 @@ handle_event(_Event, State) ->
 
 %% @private
 handle_info({rotate, File}, #state{name=File,count=Count,date=Date} = State) ->
-    lager_util:rotate_logfile(File, Count),
+    _ = lager_util:rotate_logfile(File, Count),
     schedule_rotation(File, Date),
     {ok, State};
 handle_info(_Info, State) ->

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_format.erl
----------------------------------------------------------------------
diff --git a/src/lager_format.erl b/src/lager_format.erl
index b834f27..d12ce3b 100644
--- a/src/lager_format.erl
+++ b/src/lager_format.erl
@@ -23,7 +23,7 @@
 -export([format/3, format/4]).
 
 -record(options, {
-        chomp = false
+        chomp = false :: boolean()
     }).
 
 format(FmtStr, Args, MaxLen) ->

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_handler_watcher.erl
----------------------------------------------------------------------
diff --git a/src/lager_handler_watcher.erl b/src/lager_handler_watcher.erl
index f4cc245..1285a24 100644
--- a/src/lager_handler_watcher.erl
+++ b/src/lager_handler_watcher.erl
@@ -36,9 +36,9 @@
 -export([start_link/3, start/3]).
 
 -record(state, {
-        module,
-        config,
-        event
+        module :: atom(),
+        config :: any(),
+        event :: pid() | atom()
     }).
 
 start_link(Event, Module, Config) ->

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/src/lager_util.erl
----------------------------------------------------------------------
diff --git a/src/lager_util.erl b/src/lager_util.erl
index 9980fb2..9131439 100644
--- a/src/lager_util.erl
+++ b/src/lager_util.erl
@@ -353,17 +353,16 @@ calculate_next_rotation([{date, Date}|T], {{Year, Month, Day}, _} =
Now) ->
     NewNow = calendar:gregorian_seconds_to_datetime(Seconds),
     calculate_next_rotation(T, NewNow).
 
-
+-spec trace_filter(Query :: 'none' | [tuple()]) -> {ok, any()}.
 trace_filter(Query) ->
     trace_filter(?DEFAULT_TRACER, Query).
 
 %% TODO: Support multiple trace modules 
+%-spec trace_filter(Module :: atom(), Query :: 'none' | [tuple()]) -> {ok, any()}.
 trace_filter(Module, Query) when Query == none; Query == [] ->
-    trace_filter(Module, glc:null(false));
+    {ok, _} = glc:compile(Module, glc:null(false));
 trace_filter(Module, Query) when is_list(Query) ->
-    trace_filter(Module, glc_lib:reduce(trace_any(Query)));
-trace_filter(Module, Query) ->
-    {ok, _} = glc:compile(Module, Query).
+    {ok, _} = glc:compile(Module, glc_lib:reduce(trace_any(Query))).
 
 validate_trace({Filter, Level, {Destination, ID}}) when is_tuple(Filter); is_list(Filter),
is_atom(Level), is_atom(Destination) ->
     case validate_trace({Filter, Level, Destination}) of

http://git-wip-us.apache.org/repos/asf/couchdb-lager/blob/faf3096d/tools.mk
----------------------------------------------------------------------
diff --git a/tools.mk b/tools.mk
index 7e73423..82a0669 100644
--- a/tools.mk
+++ b/tools.mk
@@ -17,16 +17,22 @@ else
 endif
 
 ${LOCAL_PLT}: compile
+ifneq (,$(wildcard deps/*))
 ifneq (,$(wildcard $(LOCAL_PLT)))
 	dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin  && \
 		dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$?
-ne 1
 else
 	dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
 endif
+endif
 
 dialyzer: ${PLT} ${LOCAL_PLT}
 	@echo "==> $(shell basename $(shell pwd)) (dialyzer)"
-	dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin
+	@if [ -f $(LOCAL_PLT) ]; then \
+		dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin; \
+	else \
+		dialyzer $(DIALYZER_FLAGS) --plts $(PLT) -c ebin; \
+	fi
 
 cleanplt:
 	@echo 


Mime
View raw message