[erlang-questions] Simple Logging

Niklas Semmler semmler@REDACTED
Tue Feb 4 11:53:21 CET 2014


Hi again,

sorry for the confusion previously. I did not use the +W flag. I attached a minimal example below. 

I did now use the +W flags and got surprising results. Only the first report in the start/0 function is reported. Independent of whether it is a error/warning/info_report. However it's name as appearing in "rb:list()" depend on the flag. For example

"+W w" and first line is a "error_report" -> the message is named "warning report"
no "+W" and first line is a "info_report" -> the message is named "error report"

@Jesper: As you can see I was using the error_logger from the start. Thanks for the dbg reference though. I will read up on it.

Is there anything obvious I miss? Is there a problem in my flags and configuration file combination?

Thanks for your help so far!
-- Niklas


--- Example BEGIN ---
start() ->
    io:format("~s~n", [error_logger:warning_map()]),
    error_logger:error_report("Error"),
    error_logger:warning_report("Warning"),
    error_logger:info_report("Info"),
    erlang:halt().

[{sasl, [
    {sasl_error_logger, false},
    {errlog_type, error},
    {error_logger_mf_dir,"./log"},
    {error_logger_mf_maxbytes, 10485760},
    {error_logger_mf_maxfiles, 2}
]}].

ERLC_FLAGS=-W
ERL_FLAGS=-boot start_sasl -config log.config [+W w <or> i]

compile: erlc $(ERLC_FLAGS) foo.erl 
run: erl $(ERL_FLAGS) foo.beam

log: erl $(ERL_FLAGS) -s rb start '[{report_dir,"./log/"}]'
<Followed by "rb:show().">
--- Example END ---

On Feb 3, 2014, at 11:06 PM, Dmitry Kolesnikov wrote:

> Hello,
> 
> You are looking for +W flag, e.g. erl +W i should make a trick for you.
> 
> +W w | i
> Sets the mapping of warning messages for error_logger. Messages sent to the error logger using one of the warning routines can be mapped either to errors (default), warnings (+W w), or info reports (+W i). The current mapping can be retrieved using error_logger:warning_map/0. See error_logger(3) for further information.
> 
> 
> However, I would still advice to use lagger. It is compatible with error_logger framework and nicely cooperates with legacy code. Long time ago, I’ve passed through your dilemma, as the result. I’ve end-up with lagger.
> 
> BTW, I am also confused with goldrush dependencies in lager. I guess it is used to manage flow control to std io.
> 
> - Dmitry
> 
> On 03 Feb 2014, at 23:29, Niklas Semmler <semmler@REDACTED> wrote:
> 
>> The code I am working on is supposed to be integrated with a bigger system later on. As far as I know the other system uses native logging.
>> 
>> That's why I want to avoid Lager. I would rather work out my own get_event..
>> 
>> -- Niklas 
>> 
>> On Feb 3, 2014, at 9:51 PM, Jesper Louis Andersen wrote:
>> 
>>> On Mon, Feb 3, 2014 at 7:20 PM, Niklas Semmler <semmler@REDACTED> wrote:
>>> 
>>>> PS: Lager is unfortunately not an option as I have to avoid any
>>>> unnecessary dependencies.
>>> 
>>> 
>>> You really want lager for this. What is the rationale for avoiding an
>>> unnecessary dependency?
>>> 
>>> 
>>> -- 
>>> J.
>> 
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list