mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Revert "Merge branch 'platinumthinker-color_in_logs'"
This reverts commit49930fe566
, reversing changes made to6e6b0fd43f
.
This commit is contained in:
parent
49930fe566
commit
4ba8f74787
4 changed files with 11 additions and 67 deletions
1
THANKS
1
THANKS
|
@ -129,4 +129,3 @@ Andras Horvath
|
||||||
Drew Varner
|
Drew Varner
|
||||||
Roberto Aloi
|
Roberto Aloi
|
||||||
Luis Rascao
|
Luis Rascao
|
||||||
Andrey Teplyashin
|
|
||||||
|
|
|
@ -56,9 +56,6 @@
|
||||||
%% Default log level
|
%% Default log level
|
||||||
{log_level, warn},
|
{log_level, warn},
|
||||||
|
|
||||||
%% Log colored
|
|
||||||
{log_colored, true},
|
|
||||||
|
|
||||||
%% any_dir processing modules
|
%% any_dir processing modules
|
||||||
{any_dir_modules, [
|
{any_dir_modules, [
|
||||||
rebar_require_vsn,
|
rebar_require_vsn,
|
||||||
|
|
|
@ -40,40 +40,23 @@ run(_Dir) ->
|
||||||
SharedExpected = "==> logging_rt \\(compile\\)",
|
SharedExpected = "==> logging_rt \\(compile\\)",
|
||||||
%% provoke ERROR due to an invalid app file
|
%% provoke ERROR due to an invalid app file
|
||||||
retest:log(info, "Check 'compile' failure output~n"),
|
retest:log(info, "Check 'compile' failure output~n"),
|
||||||
{Error, Warn, Info, Debug} =
|
|
||||||
case application:get_env(rebar, log_colored) of
|
|
||||||
{ok, true} ->
|
|
||||||
{
|
|
||||||
"\\e\\[1m\\e\\[31mERROR: \\e\\[0m",
|
|
||||||
"\\e\\[33mWARN: \\e\\[0m",
|
|
||||||
"\\e\\[32mINFO: \\e\\[0m",
|
|
||||||
"\\e\\[34mDEBUG: \\e\\[0m"
|
|
||||||
};
|
|
||||||
_ ->
|
|
||||||
{
|
|
||||||
"ERROR: ",
|
|
||||||
"WARN: ",
|
|
||||||
"INFO: ",
|
|
||||||
"DEBUG: "
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
ok = check_output("./rebar compile -q", should_fail,
|
ok = check_output("./rebar compile -q", should_fail,
|
||||||
[SharedExpected, Error],
|
[SharedExpected, "ERROR: "],
|
||||||
[Warn, Info, Debug]),
|
["WARN: ", "INFO: ", "DEBUG: "]),
|
||||||
%% fix bad app file
|
%% fix bad app file
|
||||||
ok = file:write_file(?APP_FILE, app(logging, [])),
|
ok = file:write_file(?APP_FILE, app(logging, [])),
|
||||||
retest:log(info, "Check 'compile' success output~n"),
|
retest:log(info, "Check 'compile' success output~n"),
|
||||||
ok = check_output("./rebar compile", should_succeed,
|
ok = check_output("./rebar compile", should_succeed,
|
||||||
[SharedExpected],
|
[SharedExpected],
|
||||||
[Error, Warn, Info, Debug]),
|
["ERROR: ", "WARN: ", "INFO: ", "DEBUG: "]),
|
||||||
retest:log(info, "Check 'compile -v' success output~n"),
|
retest:log(info, "Check 'compile -v' success output~n"),
|
||||||
ok = check_output("./rebar compile -v", should_succeed,
|
ok = check_output("./rebar compile -v", should_succeed,
|
||||||
[SharedExpected],
|
[SharedExpected],
|
||||||
[Error, Info, Debug]),
|
["ERROR: ", "INFO: ", "DEBUG: "]),
|
||||||
retest:log(info, "Check 'compile -vv' success output~n"),
|
retest:log(info, "Check 'compile -vv' success output~n"),
|
||||||
ok = check_output("./rebar compile -vv", should_succeed,
|
ok = check_output("./rebar compile -vv", should_succeed,
|
||||||
[SharedExpected, Debug],
|
[SharedExpected, "DEBUG: "],
|
||||||
[Error, Info]),
|
["ERROR: ", "INFO: "]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
check_output(Cmd, FailureMode, Expected, Unexpected) ->
|
check_output(Cmd, FailureMode, Expected, Unexpected) ->
|
||||||
|
@ -90,7 +73,7 @@ check_output(Cmd, FailureMode, Expected, Unexpected) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check_output1(Cmd, Captured, Expected, Unexpected) ->
|
check_output1(Cmd, Captured, Expected, Unexpected) ->
|
||||||
ReOpts = [{capture, all, list}, unicode],
|
ReOpts = [{capture, all, list}],
|
||||||
ExMatches =
|
ExMatches =
|
||||||
lists:zf(
|
lists:zf(
|
||||||
fun(Pattern) ->
|
fun(Pattern) ->
|
||||||
|
|
|
@ -50,28 +50,19 @@ init(Config) ->
|
||||||
?WARN_LEVEL -> set_level(warn);
|
?WARN_LEVEL -> set_level(warn);
|
||||||
?INFO_LEVEL -> set_level(info);
|
?INFO_LEVEL -> set_level(info);
|
||||||
?DEBUG_LEVEL -> set_level(debug)
|
?DEBUG_LEVEL -> set_level(debug)
|
||||||
end,
|
end.
|
||||||
LogColored = rebar_config:get_global(Config, log_colored, true),
|
|
||||||
set_log_colored(LogColored).
|
|
||||||
|
|
||||||
|
|
||||||
set_level(Level) ->
|
set_level(Level) ->
|
||||||
erlang:put(rebar_log_level, Level).
|
ok = application:set_env(rebar, log_level, Level).
|
||||||
|
|
||||||
set_log_colored(true) ->
|
|
||||||
erlang:put(rebar_log_colored, true);
|
|
||||||
set_log_colored(_LogColored) ->
|
|
||||||
erlang:put(rebar_log_colored, false).
|
|
||||||
|
|
||||||
log(Level, Str, Args) ->
|
log(Level, Str, Args) ->
|
||||||
log(standard_io, Level, Str, Args).
|
log(standard_io, Level, Str, Args).
|
||||||
|
|
||||||
log(Device, Level, Str, Args) ->
|
log(Device, Level, Str, Args) ->
|
||||||
LogLevel = erlang:get(rebar_log_level),
|
{ok, LogLevel} = application:get_env(rebar, log_level),
|
||||||
LogColored = erlang:get(rebar_log_colored),
|
|
||||||
case should_log(LogLevel, Level) of
|
case should_log(LogLevel, Level) of
|
||||||
true ->
|
true ->
|
||||||
io:format(Device, log_prefix(Level, LogColored) ++ Str, Args);
|
io:format(Device, log_prefix(Level) ++ Str, Args);
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
@ -99,33 +90,7 @@ should_log(error, error) -> true;
|
||||||
should_log(error, _) -> false;
|
should_log(error, _) -> false;
|
||||||
should_log(_, _) -> false.
|
should_log(_, _) -> false.
|
||||||
|
|
||||||
log_prefix(Level, _Colored = false) ->
|
|
||||||
log_prefix(Level);
|
|
||||||
log_prefix(Level, _Colored = true) ->
|
|
||||||
color_from_level(Level) ++ log_prefix(Level) ++ reset_color().
|
|
||||||
|
|
||||||
log_prefix(debug) -> "DEBUG: ";
|
log_prefix(debug) -> "DEBUG: ";
|
||||||
log_prefix(info) -> "INFO: ";
|
log_prefix(info) -> "INFO: ";
|
||||||
log_prefix(warn) -> "WARN: ";
|
log_prefix(warn) -> "WARN: ";
|
||||||
log_prefix(error) -> "ERROR: ".
|
log_prefix(error) -> "ERROR: ".
|
||||||
|
|
||||||
color_from_level(debug) ->
|
|
||||||
color_foreground(blue);
|
|
||||||
color_from_level(info) ->
|
|
||||||
color_foreground(green);
|
|
||||||
color_from_level(warn) ->
|
|
||||||
color_foreground(yellow);
|
|
||||||
color_from_level(error) ->
|
|
||||||
color_bold() ++ color_foreground(red).
|
|
||||||
|
|
||||||
color_foreground(black) -> "\e[30m";
|
|
||||||
color_foreground(red) -> "\e[31m";
|
|
||||||
color_foreground(green) -> "\e[32m";
|
|
||||||
color_foreground(yellow) -> "\e[33m";
|
|
||||||
color_foreground(blue) -> "\e[34m";
|
|
||||||
color_foreground(magenta) -> "\e[35m";
|
|
||||||
color_foreground(cyan) -> "\e[36m";
|
|
||||||
color_foreground(white) -> "\e[37m".
|
|
||||||
|
|
||||||
color_bold() -> "\e[1m".
|
|
||||||
reset_color() -> "\e[0m".
|
|
||||||
|
|
Loading…
Reference in a new issue