X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=include%2Fafb%2Fafb-plugin.h;h=6f5cd08c67c3b30486c79494a81659c6e9e87868;hb=be4e0e2d3855ccbd3b683bfe6cc4c7f9d3254314;hp=41e53ce1bf411c19f340ca2d3437ec6a1d8df934;hpb=cd438c6c7074c9c279f15dd9e5c69b90b412b8a5;p=src%2Fapp-framework-binder.git diff --git a/include/afb/afb-plugin.h b/include/afb/afb-plugin.h index 41e53ce1..6f5cd08c 100644 --- a/include/afb/afb-plugin.h +++ b/include/afb/afb-plugin.h @@ -17,6 +17,8 @@ #pragma once +#include + /***************************************************************************** * This files is the main file to include for writing plugins dedicated to * @@ -142,6 +144,7 @@ struct afb_daemon_itf { struct sd_event *(*get_event_loop)(void *closure); /* get the common systemd's event loop */ struct sd_bus *(*get_user_bus)(void *closure); /* get the common systemd's user d-bus */ struct sd_bus *(*get_system_bus)(void *closure); /* get the common systemd's system d-bus */ + void (*vverbose)(void*closure, int level, const char *file, int line, const char *fmt, va_list args); }; /* @@ -204,4 +207,24 @@ static inline struct sd_bus *afb_daemon_get_system_bus(struct afb_daemon daemon) return daemon.itf->get_system_bus(daemon.closure); } +/* + * Send a message described by 'fmt' and following parameters + * to the journal for the verbosity 'level'. + * 'file' and 'line' are indicators of position of the code in source files. + * 'daemon' MUST be the daemon given in interface when activating the plugin. + */ +static inline void afb_daemon_verbose(struct afb_daemon daemon, int level, const char *file, int line, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + return daemon.itf->vverbose(daemon.closure, level, file, line, fmt, args); + va_end(args); +} +#if !defined(NO_PLUGIN_VERBOSE_MACRO) +# define ERROR(itf,...) do{if(itf->verbosity>=0)afb_daemon_verbose(itf->daemon,3,__FILE__,__LINE__,__VA_ARGS__);}while(0) +# define WARNING(itf,...) do{if(itf->verbosity>=1)afb_daemon_verbose(itf->daemon,4,__FILE__,__LINE__,__VA_ARGS__);}while(0) +# define NOTICE(itf,...) do{if(itf->verbosity>=1)afb_daemon_verbose(itf->daemon,5,__FILE__,__LINE__,__VA_ARGS__);}while(0) +# define INFO(itf,...) do{if(itf->verbosity>=2)afb_daemon_verbose(itf->daemon,6,__FILE__,__LINE__,__VA_ARGS__);}while(0) +# define DEBUG(itf,...) do{if(itf->verbosity>=3)afb_daemon_verbose(itf->daemon,7,__FILE__,__LINE__,__VA_ARGS__);}while(0) +#endif