Skip to content
This repository
Browse code

Merge pull request #119 from basho/adt-fix-coverage

Fix 'must be purged before loading' warnings
  • Loading branch information...
commit d0ca807137fe622edf8d1c877c5985ebf2d910ce 2 parents 57cc2d5 + e87cf8e
Andrew Thompson authored March 13, 2013

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  src/lager_app.erl
15  src/lager_app.erl
@@ -95,12 +95,15 @@ expand_handlers([{lager_file_backend, Configs}|T]) ->
95 95
     [ {lager_file_backend:config_to_id(Config), Config} || Config <- Configs] ++
96 96
       expand_handlers(T);
97 97
 expand_handlers([{Mod, Config}|T]) when is_atom(Mod) ->
98  
-    %% allow the backend to generate a gen_event handler id, if it wants to
99  
-    _ = code:load_file(Mod),
100  
-    Res = case erlang:function_exported(Mod, config_to_id, 1) of
101  
-        true ->
102  
-            {Mod:config_to_id(Config), Config};
103  
-        false ->
  98
+    %% Allow the backend to generate a gen_event handler id, if it wants to.
  99
+    %% We don't use erlang:function_exported here because that requires the module 
  100
+    %% already be loaded, which is unlikely at this phase of startup. Using code:load
  101
+    %% caused undesireable side-effects with generating code-coverage reports.
  102
+    Res = try Mod:config_to_id(Config) of
  103
+        Id ->
  104
+            {Id, Config}
  105
+    catch
  106
+        _:_ ->
104 107
             {Mod, Config}
105 108
     end,
106 109
     [Res | expand_handlers(T)];

0 notes on commit d0ca807

Please sign in to comment.
Something went wrong with that request. Please try again.