BroadbandForum / obuspa

OB-USP-AGENT is a system daemon providing a User Services Platform (USP) Agent. https://github.com/BroadbandForum/obuspa/wiki
BSD 3-Clause "New" or "Revised" License
93 stars 62 forks source link

Request/Suggestion - Making the Logging mechanism using vendor specific functions #53

Closed shanthakumarks closed 2 years ago

shanthakumarks commented 2 years ago

We are planning to use our own vendor specific logging functions instead of using USP_LOG_XXX functions that are defined in src/core/usp_log.h. Basically we would like to write different #define values for the following functions through vendor_defs.h and comment out the following lines in the usp_log.h .

define USP_LOG_Error(...) if (usp_log_level >= kLogLevel_Error) { USP_LOG_Printf(kLogType_Debug, __VA_ARGS__); if (enable_callstack_debug) { USP_LOG_Callstack(); } }

define USP_LOG_Warning(...) if (usp_log_level >= kLogLevel_Warning) { USP_LOG_Printf(kLogType_Debug, __VA_ARGS__); }

define USP_LOG_Info(...) if (usp_log_level >= kLogLevel_Info) { USP_LOG_Printf(kLogType_Debug, __VA_ARGS__); }

define USP_LOG_Debug(...) if (usp_log_level >= kLogLevel_Debug) { USP_LOG_Printf(kLogType_Debug, __VA_ARGS__); }

We do not want to touch the files under src/core being an integrator. Can we request you to have the above #define code to be wrapped with a #ifndef /#endif statement (like how some of the Device.DeviceInfo. object parameters are made vendor specific by using #ifndef/endif) so that the above piece of code can be conditionally removed based on what is defined in vendor_defs.h. This way , the integrators will get an option to define their own logging functions instead of using USP_LOG_XXX fucntions.

aramf commented 2 years ago

To add to Shantha's comment, we would like to request that the above code be replaced with something like the one below. This is low-risk and should have no effect on any current implementations in the field.

Thanks.

ifndef USP_LOG_Error

define USP_LOG_Error(...) if (usp_log_level >= kLogLevel_Error) { USP_LOG_Printf(kLogType_Debug, VA_ARGS); if (enable_callstack_debug) { USP_LOG_Callstack(); } }

endif

ifndef USP_LOG_Warning

define USP_LOG_Warning(...) if (usp_log_level >= kLogLevel_Warning) { USP_LOG_Printf(kLogType_Debug, VA_ARGS); }

endif

ifndef USP_LOG_Info

define USP_LOG_Info(...) if (usp_log_level >= kLogLevel_Info) { USP_LOG_Printf(kLogType_Debug, VA_ARGS); }

endif

ifndef USP_LOG_Debug

define USP_LOG_Debug(...) if (usp_log_level >= kLogLevel_Debug) { USP_LOG_Printf(kLogType_Debug, VA_ARGS); }

endif

holme-r commented 2 years ago

Could you just register a function to perform the logging using the log_message_cb field of USP_REGISTER_CoreVendorHooks() ? When using that callback, the logging is in addition to the standard logging. To throwaway the standard logging use a file target of '-l stdout' and redirect to /dev/nul, when invoking OBUSPA.

holme-r commented 2 years ago

Closing the issue, assuming that the log_message_cb vendor hook is sufficient. If not, please re-open.