<html><head></head><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:13px"><div id="yui_3_16_0_1_1452526021579_36947"><span>Macros is the approach we've used in some places (basho_bench) for example. But a lot of these other suggestions are good. :)</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: verdana, helvetica, sans-serif; font-size: 13px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> On Monday, January 11, 2016 2:40 AM, Dmitry Kolesnikov <dmkolesnikov@gmail.com> wrote:<br></font></div> <br><br> <div class="y_msg_container">Hello,<br clear="none"><br clear="none">I am using macro to wrap logger library. <br clear="none">This gives me a freedom to config desired library and behavior at build time. <br clear="none"><br clear="none"><br clear="none">-ifndef(EMERGENCY).<br clear="none">-define(EMERGENCY(Fmt, Args), lager:emergency(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifndef(ALERT).<br clear="none">-define(ALERT(Fmt, Args), lager:alert(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifndef(CRITICAL).<br clear="none">-define(CRITICAL(Fmt, Args), lager:critical(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifndef(ERROR).<br clear="none">-define(ERROR(Fmt, Args), lager:error(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifndef(WARNING).<br clear="none">-define(WARNING(Fmt, Args), lager:warning(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifndef(NOTICE).<br clear="none">-define(NOTICE(Fmt, Args), lager:notice(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifndef(INFO).<br clear="none">-define(INFO(Fmt, Args), lager:info(Fmt, Args)).<br clear="none">-endif.<br clear="none"><br clear="none">-ifdef(CONFIG_DEBUG).<br clear="none"> -define(DEBUG(Str, Args), lager:debug(Str, Args)).<br clear="none">-else.<br clear="none"> -define(DEBUG(Str, Args), ok).<br clear="none">-endif.<br clear="none"><br clear="none"><br clear="none">Best Regards,<br clear="none">Dmitry<br clear="none"><br clear="none"><br clear="none">> On Jan 11, 2016, at 9:34 AM, Max Lapshin <<a shape="rect" ymailto="mailto:max.lapshin@gmail.com" href="mailto:max.lapshin@gmail.com">max.lapshin@gmail.com</a>> wrote:<br clear="none">> <br clear="none">> Hi.<br clear="none">> <br clear="none">> As we know, it is good when library doesn't have any hardcoded dependencies at all.<br clear="none">> <br clear="none">> I don't understand what is a good way to remove lager (or any other logging library) from library dependencies.<br clear="none">> <br clear="none">> <br clear="none">> For example, we have an mpegts decoder/encoder library. This library takes binary and unpacks it to list of frames or packs back:<br clear="none">> <br clear="none">> mpegts_decoder:decode(Binary, mpegts_decoder:init(Options)) -> {ok, Frames, State}<br clear="none">> <br clear="none">> <br clear="none">> There are calls to lager in some places of code that are used for indicating some statuses:<br clear="none">> <br clear="none">> dump_psi(Decoder, NewPMT),<br clear="none">> lager:info("PMT: ~p", [Descriptors]),<br clear="none">> ...<br clear="none">> <br clear="none">> <br clear="none">> What is the proper way to refuse from adding logger as a dependency for such pure library?<br clear="none">> Pass a callback into initialisation options?<br clear="none">> <br clear="none">> <br clear="none">> _______________________________________________<br clear="none">> erlang-questions mailing list<br clear="none">> <a shape="rect" ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br clear="none">> <a shape="rect" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><div class="yqt6280183342" id="yqtfd78386"><br clear="none"><br clear="none">_______________________________________________<br clear="none">erlang-questions mailing list<br clear="none"><a shape="rect" ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br clear="none"><a shape="rect" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br clear="none"></div><br><br></div> </div> </div> </div></div></body></html>