diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2013-10-12 22:07:03 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2013-12-06 19:05:45 +0100 |
commit | e5d76e7e8cbd923b0f50034c2221f7abe1452804 (patch) | |
tree | 3f8794f0ec55edfb4adce434d4dfa4e73e62be46 | |
parent | 2f636236bf0ef8f7d4c3a98ce6e3c3b1ee3ca0f0 (diff) |
rebar_log: use defines for log level numbers
-rw-r--r-- | src/rebar_log.erl | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 4108c9c..7f32e18 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -30,6 +30,11 @@ set_level/1, default_level/0, log/3]). +-define(ERROR_LEVEL, 0). +-define(WARN_LEVEL, 1). +-define(INFO_LEVEL, 2). +-define(DEBUG_LEVEL, 3). + %% =================================================================== %% Public API %% =================================================================== @@ -37,10 +42,10 @@ init(Config) -> Verbosity = rebar_config:get_global(Config, verbose, default_level()), case valid_level(Verbosity) of - 0 -> set_level(error); - 1 -> set_level(warn); - 2 -> set_level(info); - 3 -> set_level(debug) + ?ERROR_LEVEL -> set_level(error); + ?WARN_LEVEL -> set_level(warn); + ?INFO_LEVEL -> set_level(info); + ?DEBUG_LEVEL -> set_level(debug) end. set_level(Level) -> @@ -55,17 +60,16 @@ log(Level, Str, Args) -> ok end. -default_level() -> error_level(). +default_level() -> ?WARN_LEVEL. %% =================================================================== %% Internal functions %% =================================================================== valid_level(Level) -> - erlang:max(error_level(), erlang:min(Level, debug_level())). + erlang:max(?ERROR_LEVEL, erlang:min(Level, ?DEBUG_LEVEL)). -error_level() -> 0. -debug_level() -> 3. +error_level() -> ?ERROR_LEVEL. should_log(debug, _) -> true; should_log(info, debug) -> false; |