netopeer2 icon indicating copy to clipboard operation
netopeer2 copied to clipboard

Logging related information

Open meghna-doshi opened this issue 3 years ago • 6 comments

Hello, We wanted to integrate the logging of netopeer, libnetconf, libyang and sysrepo modules with our own logging framework. Can you please help us identify which functions would be required to be updated and if possible what lines in those functions? Basically some help with how to go about making this change.

ex, In netopeer2 we see that function np2log in file src/log.c would be the function to change. Mostly change the following 2 lines of this function:

  1. vsyslog(priority, fmt, ap);
  2. vfprintf(stderr, format, ap);

meghna-doshi avatar Apr 05 '22 21:04 meghna-doshi

In log.c there are 4 logging callbacks, each used for different project messages - libyang, libnetconf2, sysrepo, and the netopeer2 server itself. But, they all call the last function np2log() so that is the one you want to look at, I suppose. And it seems you have found it.

michalvasko avatar Apr 06 '22 06:04 michalvasko

Hi Michal, Ok for netopeer2 i think this is fine, what about libnetconf, libyang and sysrepo. As you said, there is a callback in netopeer2 but then there are some logs in libnetconf, libyang and sysrepo which probably dont get logged via the callback. So is there any common function for these modules also?

ex like sysrepo in see in file src/log.c function sr_log_msg

meghna-doshi avatar Apr 06 '22 18:04 meghna-doshi

You misunderstand, netopeer2 logs all the messages using the single function, eventually. So you only need to modify it and messages from all the libraries will be logged there as well.

michalvasko avatar Apr 07 '22 05:04 michalvasko

Hi Michal, Yes you are right about netopeer2-server logging. But my query is for sysrepo, libyang modules, where other than netopeer2-server we can have sample applications using sysrepo library.

So in such case, which is the final logging function to change if need be?

meghna-doshi avatar Apr 08 '22 00:04 meghna-doshi

In applications using those libraries you should use their API to set up a logging callback, just like netopeer2-server does, you do not have to modify any code.

michalvasko avatar Apr 08 '22 05:04 michalvasko

ya ok got it. Thanks.

meghna-doshi avatar Apr 11 '22 23:04 meghna-doshi