<div dir="ltr">Have a log function such as this inside your library code.<div><br></div><div>log_msg(Fmt, Args) -></div><div> log_msg(application:get_env(my_library, logging_mf), Fmt, Args).</div><div><br></div><div>log_msg({ok, {Mod, Fun}}, Fmt, Args) when is_atom(Mod), is_atom(Fun) -></div><div> catch apply(Mod, Fun, [Fmt, Args]);</div><div>log_msg(_, _, _) -></div><div> ok.</div><div><br></div><div>That way, the user can control how the messages get logged.</div><div><br></div><div>cheers,</div><div>Chandru</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 January 2016 at 07:34, Max Lapshin <span dir="ltr"><<a href="mailto:max.lapshin@gmail.com" target="_blank">max.lapshin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi.<div><br></div><div>As we know, it is good when library doesn't have any hardcoded dependencies at all.<br></div><div><br></div><div>I don't understand what is a good way to remove lager (or any other logging library) from library dependencies.</div><div><br></div><div><br></div><div>For example, we have an mpegts decoder/encoder library. This library takes binary and unpacks it to list of frames or packs back:</div><div><br></div><div>mpegts_decoder:decode(Binary, mpegts_decoder:init(Options)) -> {ok, Frames, State}</div><div><br></div><div><br></div><div>There are calls to lager in some places of code that are used for indicating some statuses:</div><div><div><br></div><div>dump_psi(Decoder, NewPMT),</div></div><div>lager:info("PMT: ~p", [Descriptors]),<br></div><div>...</div><div><br></div><div><br></div><div>What is the proper way to refuse from adding logger as a dependency for such pure library?</div><div>Pass a callback into initialisation options?</div><div><br></div><div><br></div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>