<div dir="ltr">In my opinion, it could be useful to provide some log <i>sources</i> in the library, i.e. statements that "emit" log messages, especially WARNs or INFOs for exceptional cases that are part of the normal processing paths.<br>
<br>On the other hand the logging infrastructure should be kept simple and not be over-engineered. Therefore the library should provide only a minimal set of log <i>sinks</i>, possibly only a <i>null</i> logger (that swallows everything) and a <i>stderr</i> logger (that writes everything to <font face="courier new, monospace">std::cerr</font> or <font face="courier new, monospace">clog</font>). All log messages must eventually go through a message handler function. Then the library users, i.e. other applications, can modify the logging behavior by installing a custom handler. For example:<br>
<br><font face="courier new, monospace">typedef void (*NdnMessageHandler)(enum LogLevel level, const std::string& context, const std::string& msg);</font><div><font face="courier new, monospace"><br></font></div><div>
<font face="courier new, monospace">static </font><span style="font-family:'courier new',monospace">NdnMessageHandler </span><span style="font-family:'courier new',monospace">g_msgHandler = stderrHandler; // default handler</span></div>
<div><span style="font-family:'courier new',monospace"><br></span></div><div><span style="font-family:'courier new',monospace">NdnMessageHandler</span></div><div><span style="font-family:'courier new',monospace">installMessageHandler(</span><span style="font-family:'courier new',monospace">NdnMessageHandler newHandler)</span></div>
<div><font face="courier new, monospace">{</font></div><div><font face="courier new, monospace">    </font><span style="font-family:'courier new',monospace">NdnMessageHandler old = g_msgHandler;</span></div><div><span style="font-family:'courier new',monospace">    </span><span style="font-family:'courier new',monospace">g_msgHandler = newHandler;</span></div>
<div><span style="font-family:'courier new',monospace">    return old;</span></div><div><font face="courier new, monospace">}<br></font><div><br></div><div>This provides great flexibility while being very simple and lightweight.</div>
<div><br></div><div>Thanks,</div><div>Davide</div><div><br>On Fri, Apr 11, 2014 at 11:45 PM, Alex Afanasyev <<a href="mailto:alexander.afanasyev@ucla.edu">alexander.afanasyev@ucla.edu</a>> wrote:<br>> The ndn-cpp-dev library right now contains some semi-broken logging support (for internal library purposes).<br>
><br>> The question I'm having is whether there is any value of fixing this logging or it would be better to just completely remove it?<br>><br>> ---<br>> Alex<br>><br>><br>> _______________________________________________<br>
> Nfd-dev mailing list<br>> <a href="mailto:Nfd-dev@lists.cs.ucla.edu">Nfd-dev@lists.cs.ucla.edu</a><br>> <a href="http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev">http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev</a><br>
</div></div></div>