aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rlx_app_discovery.erl2
-rw-r--r--src/rlx_cmd_args.erl7
-rw-r--r--src/rlx_depsolver.erl1
-rw-r--r--src/rlx_dscv_util.erl4
-rw-r--r--src/rlx_log.erl76
-rw-r--r--src/rlx_rel_discovery.erl2
-rw-r--r--src/rlx_state.erl15
7 files changed, 60 insertions, 47 deletions
diff --git a/src/rlx_app_discovery.erl b/src/rlx_app_discovery.erl
index 6407124..d321638 100644
--- a/src/rlx_app_discovery.erl
+++ b/src/rlx_app_discovery.erl
@@ -35,7 +35,7 @@
%% @doc recursively dig down into the library directories specified in the state
%% looking for OTP Applications
--spec do(rlx_state:t(), [filename:name()]) -> {ok, [rlx_app_info:t()]} | relx:error().
+-spec do(rlx_state:t(), [file:name()]) -> {ok, [rlx_app_info:t()]} | relx:error().
do(State, LibDirs) ->
rlx_log:info(rlx_state:log(State),
fun() ->
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index 4fbadba..d144953 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -100,7 +100,8 @@ handle_config(Opts, Targets, CommandLineConfig) ->
convert_targets(Targets) ->
convert_targets(Targets, []).
--spec convert_targets([string()], [string()]) -> {ok, release | relup} | relx:error().
+-spec convert_targets([string()], [rlx_state:action()]) ->
+ {ok, [rlx_state:action()]} | relx:error().
convert_targets([], []) ->
{ok, [release]};
convert_targets([], Acc) ->
@@ -134,7 +135,7 @@ create_log(Opts, Acc) ->
LogLevel = proplists:get_value(log_level, Opts, 0),
if
LogLevel >= 0, LogLevel =< 2 ->
- create_goals(Opts, [{log, rlx_log:new(LogLevel)} | Acc]);
+ create_goals(Opts, [{log, rlx_log:new(LogLevel, command_line)} | Acc]);
true ->
?RLX_ERROR({invalid_log_level, LogLevel})
end.
@@ -245,7 +246,7 @@ create_disable_default_libs(Opts, Acc) ->
Def = proplists:get_value(disable_default_libs, Opts, false),
create_upfrom(Opts, [{disable_default_libs, Def} | Acc]).
--spec create_upfrom([getopt:option()], rcl:cmd_args()) ->
+-spec create_upfrom([getopt:option()], rlx_state:cmd_args()) ->
{ok, rlx_state:cmd_args()} | relx:error().
create_upfrom(Opts, Acc) ->
case proplists:get_value(upfrom, Opts, undefined) of
diff --git a/src/rlx_depsolver.erl b/src/rlx_depsolver.erl
index 2b6e420..20423d0 100644
--- a/src/rlx_depsolver.erl
+++ b/src/rlx_depsolver.erl
@@ -100,6 +100,7 @@
-export_type([t/0,
pkg/0,
constraint_op/0,
+ raw_constraint/0,
pkg_name/0,
vsn/0,
constraint/0,
diff --git a/src/rlx_dscv_util.erl b/src/rlx_dscv_util.erl
index 3d90b08..779534c 100644
--- a/src/rlx_dscv_util.erl
+++ b/src/rlx_dscv_util.erl
@@ -33,7 +33,7 @@
%% Types
%%============================================================================
--type process_fun(Result) :: fun((filename:name(), file | directory) ->
+-type process_fun(Result) :: fun((file:name(), file | directory) ->
{ok, Result} |
{error, term()} |
{ok, Result, Recurse::boolean()} |
@@ -46,7 +46,7 @@
%% @doc recursively dig down into the library directories specified in the state
%% looking for OTP Applications
--spec do(process_fun([term()] | term()), [filename:name()]) ->
+-spec do(process_fun([term()] | term()), [file:name()]) ->
[term() | {error, term()}].
do(ProcessDir, LibDirs) ->
lists:flatten(ec_plists:map(fun(LibDir) ->
diff --git a/src/rlx_log.erl b/src/rlx_log.erl
index 6122e9b..608c0af 100644
--- a/src/rlx_log.erl
+++ b/src/rlx_log.erl
@@ -23,6 +23,7 @@
-module(rlx_log).
-export([new/1,
+ new/2,
log/4,
should/2,
debug/2,
@@ -35,14 +36,27 @@
atom_log_level/1,
format/1]).
--export_type([int_log_level/0,
+-export_type([t/0,
+ int_log_level/0,
atom_log_level/0,
log_level/0,
- log_fun/0,
- t/0]).
+ log_fun/0]).
-include_lib("relx/include/relx.hrl").
+-define(RED, 31).
+-define(GREEN, 32).
+-define(YELLOW, 33).
+-define(BLUE, 34).
+-define(MAGENTA, 35).
+-define(CYAN, 36).
+
+-define(PREFIX, "===> ").
+
+-record(state_t, {mod=?MODULE :: rlx_log,
+ log_level=0 :: int_log_level(),
+ caller=api :: api | command_line}).
+
%%============================================================================
%% types
%%============================================================================
@@ -55,29 +69,23 @@
%% and warn
-type atom_log_level() :: error | info | debug.
--opaque t() :: {?MODULE, int_log_level()}.
-
-type log_fun() :: fun(() -> iolist()).
-type color() :: 31..36.
--define(RED, 31).
--define(GREEN, 32).
--define(YELLOW, 33).
--define(BLUE, 34).
--define(MAGENTA, 35).
--define(CYAN, 36).
-
--define(PREFIX, "===> ").
+-opaque t() :: record(state_t).
%%============================================================================
%% API
%%============================================================================
%% @doc Create a new 'log level' for the system
-spec new(log_level()) -> t().
-new(LogLevel) when LogLevel >= 0, LogLevel =< 2 ->
- {?MODULE, LogLevel};
-new(AtomLogLevel)
+new(LogLevel) ->
+ new(LogLevel, api).
+
+new(LogLevel, Caller) when LogLevel >= 0, LogLevel =< 2 ->
+ #state_t{mod=?MODULE, log_level=LogLevel, caller=Caller};
+new(AtomLogLevel, Caller)
when AtomLogLevel =:= error;
AtomLogLevel =:= info;
AtomLogLevel =:= debug ->
@@ -86,7 +94,7 @@ new(AtomLogLevel)
info -> 1;
debug -> 2
end,
- new(LogLevel).
+ new(LogLevel, Caller).
%% @doc log at the debug level given the current log state with a string or
@@ -94,7 +102,7 @@ new(AtomLogLevel)
-spec debug(t(), string() | log_fun()) -> ok.
debug(LogState, Fun)
when erlang:is_function(Fun) ->
- log(LogState, ?RLX_DEBUG, fun() -> colorize(?CYAN, false, Fun()) end);
+ log(LogState, ?RLX_DEBUG, fun() -> colorize(LogState, ?CYAN, false, Fun()) end);
debug(LogState, String) ->
debug(LogState, "~s~n", [String]).
@@ -102,14 +110,14 @@ debug(LogState, String) ->
%% and argements @see io:format/2
-spec debug(t(), string(), [any()]) -> ok.
debug(LogState, FormatString, Args) ->
- log(LogState, ?RLX_DEBUG, colorize(?CYAN, false, FormatString), Args).
+ log(LogState, ?RLX_DEBUG, colorize(LogState, ?CYAN, false, FormatString), Args).
%% @doc log at the info level given the current log state with a string or
%% function that returns a string
-spec info(t(), string() | log_fun()) -> ok.
info(LogState, Fun)
when erlang:is_function(Fun) ->
- log(LogState, ?RLX_INFO, fun() -> colorize(?GREEN, false, Fun()) end);
+ log(LogState, ?RLX_INFO, fun() -> colorize(LogState, ?GREEN, false, Fun()) end);
info(LogState, String) ->
info(LogState, "~s~n", [String]).
@@ -117,14 +125,14 @@ info(LogState, String) ->
%% and argements @see io:format/2
-spec info(t(), string(), [any()]) -> ok.
info(LogState, FormatString, Args) ->
- log(LogState, ?RLX_INFO, colorize(?GREEN, false, FormatString), Args).
+ log(LogState, ?RLX_INFO, colorize(LogState, ?GREEN, false, FormatString), Args).
%% @doc log at the error level given the current log state with a string or
%% format string that returns a function
-spec error(t(), string() | log_fun()) -> ok.
error(LogState, Fun)
when erlang:is_function(Fun) ->
- log(LogState, ?RLX_ERROR, fun() -> colorize(?RED, false, Fun()) end);
+ log(LogState, ?RLX_ERROR, fun() -> colorize(LogState, ?RED, false, Fun()) end);
error(LogState, String) ->
error(LogState, "~s~n", [String]).
@@ -132,11 +140,11 @@ error(LogState, String) ->
%% and argements @see io:format/2
-spec error(t(), string(), [any()]) -> ok.
error(LogState, FormatString, Args) ->
- log(LogState, ?RLX_ERROR, colorize(?GREEN, false, FormatString), Args).
+ log(LogState, ?RLX_ERROR, colorize(LogState, ?GREEN, false, FormatString), Args).
%% @doc Execute the fun passed in if log level is as expected.
-spec log(t(), int_log_level(), log_fun()) -> ok.
-log({?MODULE, DetailLogLevel}, LogLevel, Fun)
+log(#state_t{mod=?MODULE, log_level=DetailLogLevel}, LogLevel, Fun)
when DetailLogLevel >= LogLevel ->
io:format("~s~n", [Fun()]);
log(_, _, _) ->
@@ -145,7 +153,7 @@ log(_, _, _) ->
%% @doc when the module log level is less then or equal to the log level for the
%% call then write the log info out. When its not then ignore the call.
-spec log(t(), int_log_level(), string(), [any()]) -> ok.
-log({?MODULE, DetailLogLevel}, LogLevel, FormatString, Args)
+log(#state_t{mod=?MODULE, log_level=DetailLogLevel}, LogLevel, FormatString, Args)
when DetailLogLevel >= LogLevel,
erlang:is_list(Args) ->
io:format(FormatString, Args);
@@ -155,7 +163,7 @@ log(_, _, _, _) ->
%% @doc return a boolean indicating if the system should log for the specified
%% levelg
-spec should(t(), int_log_level() | any()) -> boolean().
-should({?MODULE, DetailLogLevel}, LogLevel)
+should(#state_t{mod=?MODULE, log_level=DetailLogLevel}, LogLevel)
when DetailLogLevel >= LogLevel ->
true;
should(_, _) ->
@@ -163,16 +171,16 @@ should(_, _) ->
%% @doc get the current log level as an integer
-spec log_level(t()) -> int_log_level().
-log_level({?MODULE, DetailLogLevel}) ->
+log_level(#state_t{mod=?MODULE, log_level=DetailLogLevel}) ->
DetailLogLevel.
%% @doc get the current log level as an atom
-spec atom_log_level(t()) -> atom_log_level().
-atom_log_level({?MODULE, ?RLX_ERROR}) ->
+atom_log_level(#state_t{mod=?MODULE, log_level=?RLX_ERROR}) ->
error;
-atom_log_level({?MODULE, ?RLX_INFO}) ->
+atom_log_level(#state_t{mod=?MODULE, log_level=?RLX_INFO}) ->
info;
-atom_log_level({?MODULE, ?RLX_DEBUG}) ->
+atom_log_level(#state_t{mod=?MODULE, log_level=?RLX_DEBUG}) ->
debug.
-spec format(t()) -> iolist().
@@ -182,11 +190,11 @@ format(Log) ->
erlang:atom_to_list(atom_log_level(Log)),
<<")">>].
--spec colorize(color(), boolean(), string()) -> string().
-colorize(Color, false, Msg) when is_integer(Color) ->
+-spec colorize(t(), color(), boolean(), string()) -> string().
+colorize(#state_t{caller=command_line}, Color, false, Msg) when is_integer(Color) ->
colorize_(Color, 0, Msg);
-colorize(Color, true, Msg) when is_integer(Color) ->
- colorize_(Color, 1, Msg).
+colorize(_LogState, _Color, _Bold, Msg) ->
+ Msg.
-spec colorize_(color(), integer(), string()) -> string().
colorize_(Color, Bold, Msg) when is_integer(Color), is_integer(Bold)->
diff --git a/src/rlx_rel_discovery.erl b/src/rlx_rel_discovery.erl
index 6f23ad0..1616f52 100644
--- a/src/rlx_rel_discovery.erl
+++ b/src/rlx_rel_discovery.erl
@@ -35,7 +35,7 @@
%% @doc recursively dig down into the library directories specified in the state
%% looking for OTP Applications
--spec do(rlx_state:t(), [filename:name()], [rlx_app_info:t()]) ->
+-spec do(rlx_state:t(), [file:name()], [rlx_app_info:t()]) ->
{ok, [rlx_release:t()]} | relx:error().
do(State, LibDirs, AppMeta) ->
rlx_log:info(rlx_state:log(State),
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 81f6bef..6d3c4ee 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -66,13 +66,14 @@
-export_type([t/0,
- releases/0,
- cmd_args/0]).
+ releases/0,
+ cmd_args/0,
+ action/0]).
-record(state_t, {log :: rlx_log:t(),
root_dir :: file:name(),
caller :: caller(),
- actions=[] :: [atom()],
+ actions=[] :: [action()],
output_dir :: file:name(),
lib_dirs=[] :: [file:name()],
config_file=[] :: file:filename() | undefined,
@@ -99,6 +100,7 @@
rlx_release:t()).
-type cmd_args() :: proplists:proplist().
-type caller() :: command_line | api.
+-type action() :: release | relup | tar.
-opaque t() :: record(state_t).
@@ -113,13 +115,14 @@ new(PropList, Targets)
when erlang:is_list(PropList),
erlang:is_list(Targets) ->
{ok, Root} = file:get_cwd(),
+ Caller = proplists:get_value(caller, PropList, api),
State0 =
- #state_t{log = proplists:get_value(log, PropList, rlx_log:new(error)),
+ #state_t{log = proplists:get_value(log, PropList, rlx_log:new(error, Caller)),
output_dir=proplists:get_value(output_dir, PropList, ""),
lib_dirs=[to_binary(Dir) || Dir <- proplists:get_value(lib_dirs, PropList, [])],
config_file=proplists:get_value(config, PropList, undefined),
actions = Targets,
- caller = proplists:get_value(caller, PropList, api),
+ caller = Caller,
goals=proplists:get_value(goals, PropList, []),
providers = [],
configured_releases=ec_dictionary:new(ec_dict),
@@ -135,7 +138,7 @@ new(PropList, Targets)
proplists:get_value(disable_default_libs, PropList, false)).
%% @doc the actions targeted for this system
--spec actions(t()) -> atom().
+-spec actions(t()) -> [action()].
actions(#state_t{actions=Actions}) ->
Actions.