[Nfd-dev] Opinion needed about logging in the library

Davide Pesavento davidepesa at gmail.com
Sun Apr 13 09:02:31 PDT 2014


In my opinion, it could be useful to provide some log *sources* 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.

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 *sinks*, possibly only a *null* logger (that swallows everything)
and a *stderr* logger (that writes everything to std::cerr or clog). 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:

typedef void (*NdnMessageHandler)(enum LogLevel level, const std::string&
context, const std::string& msg);

static NdnMessageHandler g_msgHandler = stderrHandler; // default handler

NdnMessageHandler
installMessageHandler(NdnMessageHandler newHandler)
{
    NdnMessageHandler old = g_msgHandler;
    g_msgHandler = newHandler;
    return old;
}

This provides great flexibility while being very simple and lightweight.

Thanks,
Davide

On Fri, Apr 11, 2014 at 11:45 PM, Alex Afanasyev <
alexander.afanasyev at ucla.edu> wrote:
> The ndn-cpp-dev library right now contains some semi-broken logging
support (for internal library purposes).
>
> 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?
>
> ---
> Alex
>
>
> _______________________________________________
> Nfd-dev mailing list
> Nfd-dev at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20140413/ba565f1d/attachment.html>


More information about the Nfd-dev mailing list