summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap/bootstrap6
-rw-r--r--ebin/rebar.app1
-rw-r--r--src/rebar.erl3
-rw-r--r--src/rebar_base_compiler.erl10
-rw-r--r--src/rebar_config.erl4
-rw-r--r--src/rebar_log.erl48
-rw-r--r--src/rebar_otp_app.erl2
-rw-r--r--src/rebar_prv_app_builder.erl4
8 files changed, 30 insertions, 48 deletions
diff --git a/bootstrap/bootstrap b/bootstrap/bootstrap
index 18a243f..1a1afcd 100755
--- a/bootstrap/bootstrap
+++ b/bootstrap/bootstrap
@@ -79,8 +79,10 @@ main(Args) ->
%% Run rebar compile to do proper .app validation etc.
%% and rebar escriptize to create the rebar script
- RebarArgs = Args -- ["debug"], %% Avoid trying to run 'debug' command
- rebar:main(["compile", "escriptize"] ++ RebarArgs),
+ %RebarArgs = Args -- ["debug"], %% Avoid trying to run 'debug' command
+ %rebar:main(["compile", "escriptize"] ++ RebarArgs),
+
+ os:cmd("./bootstrap/rebar compile escriptize"),
%% Finally, update executable perms for our script on *nix,
%% or write out script files on win32.
diff --git a/ebin/rebar.app b/ebin/rebar.app
index 5c5cc70..9d4501b 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -45,6 +45,7 @@
crypto,
syntax_tools,
tools,
+ erlware_commons,
relx]},
{env, [
%% Default log level
diff --git a/src/rebar.erl b/src/rebar.erl
index 4189b91..8b9758f 100644
--- a/src/rebar.erl
+++ b/src/rebar.erl
@@ -70,6 +70,7 @@ main(Args) ->
%% Erlang-API entry point
run(BaseConfig, Commands) ->
_ = application:load(rebar),
+ ok = rebar_log:init(api, BaseConfig),
run_aux(BaseConfig, Commands).
%% ====================================================================
@@ -141,7 +142,7 @@ init_config({Options, _NonOptArgs}) ->
GlobalConfig2 = set_log_level(GlobalConfig1, Options),
%% Initialize logging system
- ok = rebar_log:init(GlobalConfig2),
+ ok = rebar_log:init(command_line, GlobalConfig2),
BaseConfig = rebar_config:base_config(GlobalConfig2),
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl
index b400512..278c159 100644
--- a/src/rebar_base_compiler.erl
+++ b/src/rebar_base_compiler.erl
@@ -135,14 +135,14 @@ compile_each([], _Config, _CompileFn) ->
compile_each([Source | Rest], Config, CompileFn) ->
case compile(Source, Config, CompileFn) of
ok ->
- ?CONSOLE("Compiled ~s\n", [Source]);
+ ?INFO("Compiled ~s\n", [Source]);
{ok, Warnings} ->
report(Warnings),
- ?CONSOLE("Compiled ~s\n", [Source]);
+ ?INFO("Compiled ~s\n", [Source]);
skipped ->
- ?INFO("Skipped ~s\n", [Source]);
+ ?DEBUG("Skipped ~s\n", [Source]);
Error ->
- ?CONSOLE("Compiling ~s failed:\n",
+ ?INFO("Compiling ~s failed:\n",
[maybe_absname(Config, Source)]),
maybe_report(Error),
?DEBUG("Compilation failed: ~p\n", [Error]),
@@ -181,7 +181,7 @@ compile_queue(Config, Pids, Targets) ->
compile_queue(Config, Pids, Targets);
{skipped, Source} ->
- ?INFO("Skipped ~s\n", [Source]),
+ ?DEBUG("Skipped ~s\n", [Source]),
compile_queue(Config, Pids, Targets);
{'DOWN', Mref, _, Pid, normal} ->
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
index 11756b7..079801a 100644
--- a/src/rebar_config.erl
+++ b/src/rebar_config.erl
@@ -26,7 +26,7 @@
%% -------------------------------------------------------------------
-module(rebar_config).
--export([new/0, new/1, new2/2, base_config/1, consult_file/1,
+-export([new/0, new/1, new/2, new2/2, base_config/1, consult_file/1,
get/3, get_local/3, get_list/3,
get_all/2,
set/3,
@@ -96,7 +96,7 @@ new(_ParentConfig=#config{opts=Opts0, globals=Globals, skip_dirs=SkipDirs, xconf
new(#config{opts=Opts0, globals=Globals, skip_dirs=SkipDirs, xconf=Xconf},
?DEFAULT_NAME).
-new(ParentConfig, ConfName) ->
+new(ParentConfig=#config{}, ConfName) ->
%% Load terms from rebar.config, if it exists
Dir = rebar_utils:get_cwd(),
new(ParentConfig, ConfName, Dir).
diff --git a/src/rebar_log.erl b/src/rebar_log.erl
index ba25332..1a8520f 100644
--- a/src/rebar_log.erl
+++ b/src/rebar_log.erl
@@ -26,12 +26,11 @@
%% -------------------------------------------------------------------
-module(rebar_log).
--export([init/1,
+-export([init/2,
set_level/1,
error_level/0,
default_level/0,
log/3,
- log/4,
is_verbose/1]).
-define(ERROR_LEVEL, 0).
@@ -43,32 +42,26 @@
%% Public API
%% ===================================================================
-init(Config) ->
+init(Caller, Config) ->
Verbosity = rebar_config:get_global(Config, verbose, default_level()),
- case valid_level(Verbosity) of
- ?ERROR_LEVEL -> set_level(error);
- ?WARN_LEVEL -> set_level(warn);
- ?INFO_LEVEL -> set_level(info);
- ?DEBUG_LEVEL -> set_level(debug)
- end.
+ Level = case valid_level(Verbosity) of
+ ?ERROR_LEVEL -> error;
+ ?WARN_LEVEL -> warn;
+ ?INFO_LEVEL -> info;
+ ?DEBUG_LEVEL -> debug
+ end,
+ Log = ec_cmd_log:new(Level, Caller),
+ application:set_env(rebar, log, Log).
set_level(Level) ->
ok = application:set_env(rebar, log_level, Level).
log(Level, Str, Args) ->
- log(standard_io, Level, Str, Args).
-
-log(Device, Level, Str, Args) ->
- {ok, LogLevel} = application:get_env(rebar, log_level),
- case should_log(LogLevel, Level) of
- true ->
- io:format(Device, log_prefix(Level) ++ Str, Args);
- false ->
- ok
- end.
+ {ok, LogState} = application:get_env(rebar, log),
+ ec_cmd_log:Level(LogState, Str, Args).
error_level() -> ?ERROR_LEVEL.
-default_level() -> ?WARN_LEVEL.
+default_level() -> ?INFO_LEVEL.
is_verbose(Config) ->
rebar_config:get_xconf(Config, is_verbose, false).
@@ -79,18 +72,3 @@ is_verbose(Config) ->
valid_level(Level) ->
erlang:max(?ERROR_LEVEL, erlang:min(Level, ?DEBUG_LEVEL)).
-
-should_log(debug, _) -> true;
-should_log(info, debug) -> false;
-should_log(info, _) -> true;
-should_log(warn, debug) -> false;
-should_log(warn, info) -> false;
-should_log(warn, _) -> true;
-should_log(error, error) -> true;
-should_log(error, _) -> false;
-should_log(_, _) -> false.
-
-log_prefix(debug) -> "DEBUG: ";
-log_prefix(info) -> "INFO: ";
-log_prefix(warn) -> "WARN: ";
-log_prefix(error) -> "ERROR: ".
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index e390f3b..6dfb6b0 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -146,7 +146,7 @@ preprocess(Config, Dir, AppSrcFile) ->
load_app_vars(Config) ->
case rebar_config:get_local(Config, app_vars_file, undefined) of
undefined ->
- ?INFO("No app_vars_file defined.\n", []),
+ ?DEBUG("No app_vars_file defined.\n", []),
[];
Filename ->
?INFO("Loading app vars from ~p\n", [Filename]),
diff --git a/src/rebar_prv_app_builder.erl b/src/rebar_prv_app_builder.erl
index 6d1498d..3b974a9 100644
--- a/src/rebar_prv_app_builder.erl
+++ b/src/rebar_prv_app_builder.erl
@@ -33,8 +33,8 @@ do(Config) ->
Apps = rebar_config:apps_to_build(Config),
Config1 =
lists:foldl(fun(AppInfo, ConfigAcc) ->
- ?CONSOLE("Building ~p version ~p~n", [rebar_app_info:name(AppInfo)
- ,rebar_app_info:original_vsn(AppInfo)]),
+ ?INFO("Building ~p version ~p~n", [rebar_app_info:name(AppInfo)
+ ,rebar_app_info:original_vsn(AppInfo)]),
{_AppInfo1, ConfigAcc1} = build(ConfigAcc, AppInfo),
ConfigAcc
end, Config, Deps++Apps),