summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_log.erl27
-rw-r--r--src/rebar_prv_install_deps.erl8
-rw-r--r--src/rebar_prv_upgrade.erl2
-rw-r--r--src/rebar_relx.erl2
4 files changed, 35 insertions, 4 deletions
diff --git a/src/rebar_log.erl b/src/rebar_log.erl
index 06cfa9c..be92199 100644
--- a/src/rebar_log.erl
+++ b/src/rebar_log.erl
@@ -30,6 +30,7 @@
set_level/1,
error_level/0,
default_level/0,
+ intensity/0,
log/3,
is_verbose/1]).
@@ -37,11 +38,31 @@
-define(WARN_LEVEL, 1).
-define(INFO_LEVEL, 2).
-define(DEBUG_LEVEL, 3).
+-define(DFLT_INTENSITY, high).
%% ===================================================================
%% Public API
%% ===================================================================
+%% @doc Returns the color intensity, we first check the application envorinment
+%% if that is not set we check the environment variable REBAR_COLOR.
+intensity() ->
+ case application:get_env(rebar, color_intensity) of
+ undefined ->
+ R = case os:getenv("REBAR_COLOR") of
+ "high" ->
+ high;
+ "low" ->
+ low;
+ _ ->
+ ?DFLT_INTENSITY
+ end,
+ application:set_env(rebar, color_intensity, R),
+ R;
+ {ok, Mode} ->
+ Mode
+ end.
+
init(Caller, Verbosity) ->
Level = case valid_level(Verbosity) of
?ERROR_LEVEL -> error;
@@ -49,12 +70,16 @@ init(Caller, Verbosity) ->
?INFO_LEVEL -> info;
?DEBUG_LEVEL -> debug
end,
- Log = ec_cmd_log:new(Level, Caller),
+ Intensity = intensity(),
+ Log = ec_cmd_log:new(Level, Caller, Intensity),
application:set_env(rebar, log, Log).
set_level(Level) ->
ok = application:set_env(rebar, log_level, Level).
+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);
log(Level, Str, Args) ->
{ok, LogState} = application:get_env(rebar, log),
ec_cmd_log:Level(LogState, Str++"~n", Args).
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index a484c5f..5e6aa4c 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -35,7 +35,8 @@
-include("rebar.hrl").
-include_lib("providers/include/providers.hrl").
--export([handle_deps_as_profile/4,
+-export([do_/1,
+ handle_deps_as_profile/4,
profile_dep_dir/2,
find_cycles/1,
cull_compile/2]).
@@ -69,8 +70,11 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
+ ?INFO("Verifying dependencies...", []),
+ do_(State).
+
+do_(State) ->
try
- ?INFO("Verifying dependencies...", []),
Profiles = rebar_state:current_profiles(State),
ProjectApps = rebar_state:project_apps(State),
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl
index a2864ab..c5c43e4 100644
--- a/src/rebar_prv_upgrade.erl
+++ b/src/rebar_prv_upgrade.erl
@@ -61,7 +61,7 @@ do(State) ->
State4 = rebar_state:set(State3, upgrade, true),
UpdatedLocks = [L || L <- rebar_state:lock(State4),
lists:keymember(rebar_app_info:name(L), 1, Locks0)],
- Res = rebar_prv_install_deps:do(rebar_state:lock(State4, UpdatedLocks)),
+ Res = rebar_prv_install_deps:do_(rebar_state:lock(State4, UpdatedLocks)),
case Res of
{ok, State5} ->
rebar_utils:info_useless(
diff --git a/src/rebar_relx.erl b/src/rebar_relx.erl
index 5d29258..45e1c96 100644
--- a/src/rebar_relx.erl
+++ b/src/rebar_relx.erl
@@ -14,6 +14,8 @@
-spec do(atom(), string(), atom(), rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
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()),
Options = rebar_state:command_args(State),
DepsDir = rebar_dir:deps_dir(State),
ProjectAppDirs = lists:delete(".", ?DEFAULT_PROJECT_APP_DIRS),