iilyak closed pull request #1637: Add ability to configure logger for eunit 
test step
URL: https://github.com/apache/couchdb/pull/1637
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/couch/src/test_util.erl b/src/couch/src/test_util.erl
index efb5064609..0c83ae5f34 100644
--- a/src/couch/src/test_util.erl
+++ b/src/couch/src/test_util.erl
@@ -34,6 +34,7 @@
 -export([wait/1, wait/2, wait/3]).
 
 -export([start/1, start/2, start/3, stop/1]).
+-export([maybe_configure_file_logger/0]).
 
 -export([fake_db/1]).
 
@@ -77,6 +78,7 @@ start_couch(IniFiles, ExtraApps) ->
     ok = application:set_env(config, ini_files, IniFiles),
     Apps = start_applications(?DEFAULT_APPS ++ ExtraApps),
     ok = config:delete("compactions", "_default", false),
+    maybe_configure_file_logger(),
     #test_context{started = Apps}.
 
 stop_couch() ->
@@ -87,6 +89,20 @@ stop_couch(#test_context{started = Apps}) ->
 stop_couch(_) ->
     stop_couch().
 
+maybe_configure_file_logger() ->
+    case {os:getenv("EUNIT_LOG_FILE"), os:getenv("EUNIT_LOG_LEVEL")} of
+        {false, _} ->
+            ok;
+        {FilePath, Value} ->
+            Level = if Value == false -> "info"; true -> Value end,
+            LogFile = case filename:pathtype(FilePath) of absolute -> FilePath;
+                _ -> filename:absname(FilePath, ?BUILDDIR()) end,
+            ok = config:set("log", "writer", "file", false),
+            ok = config:set("log", "file", LogFile, false),
+            ok = config:set("log", "level", Level, false),
+            ok
+    end.
+
 start_applications(Apps) ->
     StartOrder = calculate_start_order(Apps),
     start_applications(StartOrder, []).


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to