netopeer2
netopeer2 copied to clipboard
Logging related information
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:
- vsyslog(priority, fmt, ap);
- vfprintf(stderr, format, ap);
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.
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
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.
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?
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.
ya ok got it. Thanks.