Skip to content

Commit

Permalink
Allow distinction between console and file logging levels
Browse files Browse the repository at this point in the history
Move from a single lager_level configuration option to
lager_console_level and lager_file_level in order to be able to
control these independently. The default level for the console output
is notice to minimize the output display during a run. The default
level for the file output is info in order to capture all of the
logging that previously has been output to the console.
  • Loading branch information
kellymclaughlin committed Dec 12, 2014
1 parent 3794411 commit 62b7efc
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/riak_test_escript.erl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ add_deps(Path) ->

test_setup(ParsedArgs) ->
%% File output
OutDir = proplists:get_value(outdir, ParsedArgs),
OutDir = proplists:get_value(outdir, ParsedArgs, "log"),
ensure_dir(OutDir),

lager_setup(OutDir),
Expand Down Expand Up @@ -272,18 +272,17 @@ ensure_dir(undefined) ->
ensure_dir(Dir) ->
filelib:ensure_dir(Dir).

lager_setup(undefined) ->
set_lager_env(rt_config:get(lager_level, notice)),
lager:start();
lager_setup(_) ->
set_lager_env(notice),
lager_setup(OutputDir) ->
set_lager_env(OutputDir,
rt_config:get(lager_console_level, notice),
rt_config:get(lager_file_level, info)),
lager:start().

set_lager_env(LagerLevel) ->
set_lager_env(OutputDir, ConsoleLevel, FileLevel) ->
application:load(lager),
HandlerConfig = [{lager_console_backend, LagerLevel},
{lager_file_backend, [{file, "log/test.log"},
{level, LagerLevel}]}],
HandlerConfig = [{lager_console_backend, ConsoleLevel},
{lager_file_backend, [{file, filename:join(OutputDir, "test.log")},
{level, FileLevel}]}],
application:set_env(lager, handlers, HandlerConfig).

%% maybe_teardown(false, TestResults, Coverage, Verbose) ->
Expand Down

0 comments on commit 62b7efc

Please sign in to comment.