瀏覽代碼

Write ERROR messages to standard_error device

pull/3/head
Tuncer Ayaz 11 年之前
父節點
當前提交
f39309a660
共有 2 個檔案被更改,包括 7 行新增3 行删除
  1. +1
    -1
      include/rebar.hrl
  2. +6
    -2
      src/rebar_log.erl

+ 1
- 1
include/rebar.hrl 查看文件

@ -9,6 +9,6 @@
-define(DEBUG(Str, Args), rebar_log:log(debug, Str, Args)).
-define(INFO(Str, Args), rebar_log:log(info, Str, Args)).
-define(WARN(Str, Args), rebar_log:log(warn, Str, Args)).
-define(ERROR(Str, Args), rebar_log:log(error, Str, Args)).
-define(ERROR(Str, Args), rebar_log:log(standard_error, error, Str, Args)).
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).

+ 6
- 2
src/rebar_log.erl 查看文件

@ -30,7 +30,8 @@
set_level/1,
error_level/0,
default_level/0,
log/3]).
log/3,
log/4]).
-define(ERROR_LEVEL, 0).
-define(WARN_LEVEL, 1).
@ -54,10 +55,13 @@ 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(log_prefix(Level) ++ Str, Args);
io:format(Device, log_prefix(Level) ++ Str, Args);
false ->
ok
end.

Loading…
取消
儲存