From f39309a66020e13892350785bf3feff6907c5ee6 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 3 Dec 2013 19:59:28 +0100 Subject: [PATCH] Write ERROR messages to standard_error device --- include/rebar.hrl | 2 +- src/rebar_log.erl | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/rebar.hrl b/include/rebar.hrl index 58debfc..b19fdd3 100644 --- a/include/rebar.hrl +++ b/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))). diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 300a615..8be090b 100644 --- a/src/rebar_log.erl +++ b/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.