From 04be3f596372927f07554cde76d1e343c3a146e2 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 1 Nov 2015 00:36:13 +0100 Subject: Make output a bit more discrete --- src/rebar_log.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 06cfa9c..347cda4 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -49,12 +49,15 @@ init(Caller, Verbosity) -> ?INFO_LEVEL -> info; ?DEBUG_LEVEL -> debug end, - Log = ec_cmd_log:new(Level, Caller), + Log = ec_cmd_log:new(Level, Caller, low), 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, 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). -- cgit v1.1 From afd2b9b4fb2f7151a0eae1f2be876b05e7544a17 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Sun, 1 Nov 2015 16:20:38 +0100 Subject: Fixed error log formating --- src/rebar_log.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 347cda4..781da62 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -57,7 +57,7 @@ set_level(Level) -> log(Level = error, Str, Args) -> {ok, LogState} = application:get_env(rebar, log), - ec_cmd_log:Level(LogState, cf:format("~!^~s~n", [Str]), Args); + 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). -- cgit v1.1 From 42695b42b171075b0b349a1e73688dbc19106dc1 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Wed, 4 Nov 2015 18:21:00 +0100 Subject: Allow switching based on env variable --- src/rebar_log.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 781da62..d921110 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -37,6 +37,7 @@ -define(WARN_LEVEL, 1). -define(INFO_LEVEL, 2). -define(DEBUG_LEVEL, 3). +-define(DFLT_INTENSITY, low). %% =================================================================== %% Public API @@ -49,7 +50,15 @@ init(Caller, Verbosity) -> ?INFO_LEVEL -> info; ?DEBUG_LEVEL -> debug end, - Log = ec_cmd_log:new(Level, Caller, low), + Intensity = case os:getenv("REBAR_COLOR") of + "high" -> + high; + "low" -> + low; + _ -> + ?DFLT_INTENSITY + end, + Log = ec_cmd_log:new(Level, Caller, Intensity), application:set_env(rebar, log, Log). set_level(Level) -> -- cgit v1.1 From 949eafd8991292b1726e735d356864f079e8313a Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Tue, 9 Feb 2016 14:03:08 -0500 Subject: Some cleanup --- src/rebar_log.erl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/rebar_log.erl b/src/rebar_log.erl index d921110..eb37869 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -43,6 +43,16 @@ %% Public API %% =================================================================== +intensity() -> + case os:getenv("REBAR_COLOR") of + "high" -> + high; + "low" -> + low; + _ -> + ?DFLT_INTENSITY + end. + init(Caller, Verbosity) -> Level = case valid_level(Verbosity) of ?ERROR_LEVEL -> error; @@ -50,14 +60,7 @@ init(Caller, Verbosity) -> ?INFO_LEVEL -> info; ?DEBUG_LEVEL -> debug end, - Intensity = case os:getenv("REBAR_COLOR") of - "high" -> - high; - "low" -> - low; - _ -> - ?DFLT_INTENSITY - end, + Intensity = intensity(), Log = ec_cmd_log:new(Level, Caller, Intensity), application:set_env(rebar, log, Log). -- cgit v1.1 From c79fe4cf1b123e049f9582c6f829074fe4e45d72 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Tue, 16 Feb 2016 12:08:09 -0500 Subject: Use an app_env to get color intensity --- src/rebar_log.erl | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/rebar_log.erl b/src/rebar_log.erl index eb37869..9eb3da6 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]). @@ -43,14 +44,23 @@ %% 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 os:getenv("REBAR_COLOR") of - "high" -> - high; - "low" -> - low; - _ -> - ?DFLT_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) -> -- cgit v1.1 From 4a5c8bc0e3c5c0ba062d92e44b4bb627ac9d8af5 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Tue, 16 Feb 2016 12:08:23 -0500 Subject: Set relx color intensity env variable --- src/rebar_relx.erl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') 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), -- cgit v1.1