diff options
author | Tristan Sloughter <t@crashfast.com> | 2016-03-07 12:20:57 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2016-03-07 12:57:54 -0600 |
commit | c67ac9292c4c264a209e6b9308b619c65d03d86c (patch) | |
tree | 3e000b00fe4647796ced7c0e85fff3eaa6ad641c /src | |
parent | 925ecefc12fffd4075f5dd6d1a9c31ae07610e9b (diff) |
pass loglevel used in rebar3 to relx
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_log.erl | 19 | ||||
-rw-r--r-- | src/rebar_relx.erl | 7 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/rebar_log.erl b/src/rebar_log.erl index be92199..23ae81e 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -28,11 +28,13 @@ -export([init/2, set_level/1, + get_level/0, error_level/0, default_level/0, intensity/0, log/3, - is_verbose/1]). + is_verbose/1, + valid_level/1]). -define(ERROR_LEVEL, 0). -define(WARN_LEVEL, 1). @@ -72,11 +74,20 @@ init(Caller, Verbosity) -> end, Intensity = intensity(), Log = ec_cmd_log:new(Level, Caller, Intensity), + set_level(valid_level(Verbosity)), application:set_env(rebar, log, Log). set_level(Level) -> ok = application:set_env(rebar, log_level, Level). +get_level() -> + case application:get_env(rebar, log_level) of + undefined -> + default_level(); + {ok, Level} -> + Level + end. + log(Level = error, Str, Args) -> {ok, LogState} = application:get_env(rebar, log), ec_cmd_log:Level(LogState, lists:flatten(cf:format("~!^~s~n", [Str])), Args); @@ -90,9 +101,9 @@ default_level() -> ?INFO_LEVEL. is_verbose(State) -> rebar_state:get(State, is_verbose, false). +valid_level(Level) -> + erlang:max(?ERROR_LEVEL, erlang:min(Level, ?DEBUG_LEVEL)). + %% =================================================================== %% Internal functions %% =================================================================== - -valid_level(Level) -> - erlang:max(?ERROR_LEVEL, erlang:min(Level, ?DEBUG_LEVEL)). diff --git a/src/rebar_relx.erl b/src/rebar_relx.erl index 125da47..5c653a3 100644 --- a/src/rebar_relx.erl +++ b/src/rebar_relx.erl @@ -16,6 +16,7 @@ do(Module, Command, Provider, State) -> %% We set the color mode for relx as a application env application:set_env(relx, color_intensity, rebar_log:intensity()), + LogLevel = rebar_log:get_level(), Options = rebar_state:command_args(State), DepsDir = rebar_dir:deps_dir(State), ProjectAppDirs = lists:delete(".", ?DEFAULT_PROJECT_APP_DIRS), @@ -30,12 +31,14 @@ do(Module, Command, Provider, State) -> case rebar_state:get(State, relx, []) of [] -> relx:main([{lib_dirs, LibDirs} - ,{caller, api} | output_dir(OutputDir, Options)], AllOptions); + ,{caller, api} + ,{log_level, LogLevel} | output_dir(OutputDir, Options)], AllOptions); Config -> Config1 = merge_overlays(Config), relx:main([{lib_dirs, LibDirs} ,{config, Config1} - ,{caller, api} | output_dir(OutputDir, Options)], AllOptions) + ,{caller, api} + ,{log_level, LogLevel} | output_dir(OutputDir, Options)], AllOptions) end, rebar_hooks:run_project_and_app_hooks(Cwd, post, Provider, Providers, State), {ok, State} |