summaryrefslogtreecommitdiffstats
path: root/include/afb
diff options
context:
space:
mode:
Diffstat (limited to 'include/afb')
-rw-r--r--include/afb/afb-binding-v1.h42
-rw-r--r--include/afb/afb-binding-v2.h25
-rw-r--r--include/afb/afb-binding.h12
-rw-r--r--include/afb/afb-daemon-v1.h43
-rw-r--r--include/afb/afb-daemon-v2.h14
-rw-r--r--include/afb/afb-req-itf.h34
6 files changed, 151 insertions, 19 deletions
diff --git a/include/afb/afb-binding-v1.h b/include/afb/afb-binding-v1.h
index b627d5c4..ef03a6b0 100644
--- a/include/afb/afb-binding-v1.h
+++ b/include/afb/afb-binding-v1.h
@@ -147,20 +147,38 @@ struct afb_binding_interface_v1
*/
#if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO)
# if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS)
-# define AFB_ERROR_V1(itf,...) do{if(itf->verbosity>=0)afb_daemon_verbose(itf->daemon,3,__FILE__,__LINE__,__VA_ARGS__);}while(0)
-# define AFB_WARNING_V1(itf,...) do{if(itf->verbosity>=1)afb_daemon_verbose(itf->daemon,4,__FILE__,__LINE__,__VA_ARGS__);}while(0)
-# define AFB_NOTICE_V1(itf,...) do{if(itf->verbosity>=1)afb_daemon_verbose(itf->daemon,5,__FILE__,__LINE__,__VA_ARGS__);}while(0)
-# define AFB_INFO_V1(itf,...) do{if(itf->verbosity>=2)afb_daemon_verbose(itf->daemon,6,__FILE__,__LINE__,__VA_ARGS__);}while(0)
-# define AFB_DEBUG_V1(itf,...) do{if(itf->verbosity>=3)afb_daemon_verbose(itf->daemon,7,__FILE__,__LINE__,__VA_ARGS__);}while(0)
+# define _AFB_LOGGING_V1_(itf,vlevel,llevel,...) \
+ do{ \
+ if(itf->verbosity>=vlevel) \
+ afb_daemon_verbose2_v1(itf->daemon,llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
+ }while(0)
+# define _AFB_REQ_LOGGING_V1_(itf,vlevel,llevel,req,...) \
+ do{ \
+ if(itf->verbosity>=vlevel) \
+ afb_req_verbose(req,llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
+ }while(0)
# else
-# define AFB_ERROR_V1(itf,...) do{if(itf->verbosity>=0)afb_daemon_verbose(itf->daemon,3,NULL,0,__VA_ARGS__);}while(0)
-# define AFB_WARNING_V1(itf,...) do{if(itf->verbosity>=1)afb_daemon_verbose(itf->daemon,4,NULL,0,__VA_ARGS__);}while(0)
-# define AFB_NOTICE_V1(itf,...) do{if(itf->verbosity>=1)afb_daemon_verbose(itf->daemon,5,NULL,0,__VA_ARGS__);}while(0)
-# define AFB_INFO_V1(itf,...) do{if(itf->verbosity>=2)afb_daemon_verbose(itf->daemon,6,NULL,0,__VA_ARGS__);}while(0)
-# define AFB_DEBUG_V1(itf,...) do{if(itf->verbosity>=3)afb_daemon_verbose(itf->daemon,7,NULL,0,__VA_ARGS__);}while(0)
+# define _AFB_LOGGING_V1_(itf,vlevel,llevel,...) \
+ do{ \
+ if(itf->verbosity>=vlevel) \
+ afb_daemon_verbose_v1(itf->daemon,llevel,NULL,0,NULL,__VA_ARGS__); \
+ }while(0)
+# define _AFB_REQ_LOGGING_V1_(itf,vlevel,llevel,req,...) \
+ do{ \
+ if(itf->verbosity>=vlevel) \
+ afb_req_verbose(req,llevel,NULL,0,NULL,__VA_ARGS__); \
+ }while(0)
# endif
+# define AFB_ERROR_V1(itf,...) _AFB_LOGGING_V1_(itf,0,3,__VA_ARGS__)
+# define AFB_WARNING_V1(itf,...) _AFB_LOGGING_V1_(itf,1,4,__VA_ARGS__)
+# define AFB_NOTICE_V1(itf,...) _AFB_LOGGING_V1_(itf,1,5,__VA_ARGS__)
+# define AFB_INFO_V1(itf,...) _AFB_LOGGING_V1_(itf,2,6,__VA_ARGS__)
+# define AFB_DEBUG_V1(itf,...) _AFB_LOGGING_V1_(itf,3,7,__VA_ARGS__)
+# define AFB_REQ_ERROR_V1(itf,...) _AFB_REQ_LOGGING_V1_(itf,0,3,__VA_ARGS__)
+# define AFB_REQ_WARNING_V1(itf,...) _AFB_REQ_LOGGING_V1_(itf,1,4,__VA_ARGS__)
+# define AFB_REQ_NOTICE_V1(itf,...) _AFB_REQ_LOGGING_V1_(itf,1,5,__VA_ARGS__)
+# define AFB_REQ_INFO_V1(itf,...) _AFB_REQ_LOGGING_V1_(itf,2,6,__VA_ARGS__)
+# define AFB_REQ_DEBUG_V1(itf,...) _AFB_REQ_LOGGING_V1_(itf,3,7,__VA_ARGS__)
#endif
-
-
diff --git a/include/afb/afb-binding-v2.h b/include/afb/afb-binding-v2.h
index e763f1cf..66601b23 100644
--- a/include/afb/afb-binding-v2.h
+++ b/include/afb/afb-binding-v2.h
@@ -96,18 +96,33 @@ struct afb_binding_data_v2 AFB_BINDING_DATA_NAME_V2 __attribute__ ((weak));
if(AFB_BINDING_DATA_NAME_V2.verbosity>=vlevel) \
afb_daemon_verbose_v2(llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
}while(0)
+# define _AFB_REQ_LOGGING_V2_(vlevel,llevel,req,...) \
+ do{ \
+ if(AFB_BINDING_DATA_NAME_V2.verbosity>=vlevel) \
+ afb_req_verbose(req,llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
+ }while(0)
# else
# define _AFB_LOGGING_V2_(vlevel,llevel,...) \
do{ \
if(afbBindingV2data.verbosity>=vlevel) \
afb_daemon_verbose_v2(llevel,NULL,0,NULL,__VA_ARGS__); \
}while(0)
+# define _AFB_REQ_LOGGING_V2_(vlevel,llevel,req,...) \
+ do{ \
+ if(AFB_BINDING_DATA_NAME_V2.verbosity>=vlevel) \
+ afb_req_verbose(req,llevel,NULL,0,NULL,__VA_ARGS__); \
+ }while(0)
# endif
-# define AFB_ERROR_V2(...) _AFB_LOGGING_V2_(0,3,__VA_ARGS__)
-# define AFB_WARNING_V2(...) _AFB_LOGGING_V2_(1,4,__VA_ARGS__)
-# define AFB_NOTICE_V2(...) _AFB_LOGGING_V2_(1,5,__VA_ARGS__)
-# define AFB_INFO_V2(...) _AFB_LOGGING_V2_(2,6,__VA_ARGS__)
-# define AFB_DEBUG_V2(...) _AFB_LOGGING_V2_(3,7,__VA_ARGS__)
+# define AFB_ERROR_V2(...) _AFB_LOGGING_V2_(0,3,__VA_ARGS__)
+# define AFB_WARNING_V2(...) _AFB_LOGGING_V2_(1,4,__VA_ARGS__)
+# define AFB_NOTICE_V2(...) _AFB_LOGGING_V2_(1,5,__VA_ARGS__)
+# define AFB_INFO_V2(...) _AFB_LOGGING_V2_(2,6,__VA_ARGS__)
+# define AFB_DEBUG_V2(...) _AFB_LOGGING_V2_(3,7,__VA_ARGS__)
+# define AFB_REQ_ERROR_V2(...) _AFB_REQ_LOGGING_V2_(0,3,__VA_ARGS__)
+# define AFB_REQ_WARNING_V2(...) _AFB_REQ_LOGGING_V2_(1,4,__VA_ARGS__)
+# define AFB_REQ_NOTICE_V2(...) _AFB_REQ_LOGGING_V2_(1,5,__VA_ARGS__)
+# define AFB_REQ_INFO_V2(...) _AFB_REQ_LOGGING_V2_(2,6,__VA_ARGS__)
+# define AFB_REQ_DEBUG_V2(...) _AFB_REQ_LOGGING_V2_(3,7,__VA_ARGS__)
#endif
#include "afb-daemon-v2.h"
diff --git a/include/afb/afb-binding.h b/include/afb/afb-binding.h
index e2fd34d8..a7872517 100644
--- a/include/afb/afb-binding.h
+++ b/include/afb/afb-binding.h
@@ -102,6 +102,12 @@
# define INFO AFB_INFO_V1
# define DEBUG AFB_DEBUG_V1
+# define REQ_ERROR AFB_REQ_ERROR_V1
+# define REQ_WARNING AFB_REQ_WARNING_V1
+# define REQ_NOTICE AFB_REQ_NOTICE_V1
+# define REQ_INFO AFB_REQ_INFO_V1
+# define REQ_DEBUG AFB_REQ_DEBUG_V1
+
# endif
#define afb_daemon_get_event_loop afb_daemon_get_event_loop_v1
@@ -147,6 +153,12 @@
# define INFO AFB_INFO_V2
# define DEBUG AFB_DEBUG_V2
+# define REQ_ERROR AFB_REQ_ERROR_V2
+# define REQ_WARNING AFB_REQ_WARNING_V2
+# define REQ_NOTICE AFB_REQ_NOTICE_V2
+# define REQ_INFO AFB_REQ_INFO_V2
+# define REQ_DEBUG AFB_REQ_DEBUG_V2
+
# endif
#define afb_daemon_get_event_loop afb_daemon_get_event_loop_v2
diff --git a/include/afb/afb-daemon-v1.h b/include/afb/afb-daemon-v1.h
index 84095e04..6390dd16 100644
--- a/include/afb/afb-daemon-v1.h
+++ b/include/afb/afb-daemon-v1.h
@@ -74,8 +74,21 @@ static inline struct afb_event afb_daemon_make_event_v1(struct afb_daemon daemon
/*
* 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.
+ *
+ * 'file' and 'line' are indicators of position of the code in source files
+ * (see macros __FILE__ and __LINE__).
+ *
* 'daemon' MUST be the daemon given in interface when activating the binding.
+ *
+ * 'level' is defined by syslog standard:
+ * EMERGENCY 0 System is unusable
+ * ALERT 1 Action must be taken immediately
+ * CRITICAL 2 Critical conditions
+ * ERROR 3 Error conditions
+ * WARNING 4 Warning conditions
+ * NOTICE 5 Normal but significant condition
+ * INFO 6 Informational
+ * DEBUG 7 Debug-level messages
*/
static inline void afb_daemon_verbose_v1(struct afb_daemon daemon, int level, const char *file, int line, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
static inline void afb_daemon_verbose_v1(struct afb_daemon daemon, int level, const char *file, int line, const char *fmt, ...)
@@ -87,6 +100,34 @@ static inline void afb_daemon_verbose_v1(struct afb_daemon daemon, int level, co
}
/*
+ * Send a message described by 'fmt' and following parameters
+ * to the journal for the verbosity 'level'.
+ *
+ * 'file', 'line' and 'func' are indicators of position of the code in source files
+ * (see macros __FILE__, __LINE__ and __func__).
+ *
+ * 'daemon' MUST be the daemon given in interface when activating the binding.
+ *
+ * 'level' is defined by syslog standard:
+ * EMERGENCY 0 System is unusable
+ * ALERT 1 Action must be taken immediately
+ * CRITICAL 2 Critical conditions
+ * ERROR 3 Error conditions
+ * WARNING 4 Warning conditions
+ * NOTICE 5 Normal but significant condition
+ * INFO 6 Informational
+ * DEBUG 7 Debug-level messages
+ */
+static inline void afb_daemon_verbose2_v1(struct afb_daemon daemon, int level, const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 6, 7)));
+static inline void afb_daemon_verbose2_v1(struct afb_daemon daemon, int level, const char *file, int line, const char *func, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ daemon.itf->vverbose_v2(daemon.closure, level, file, line, func, fmt, args);
+ va_end(args);
+}
+
+/*
* Get the root directory file descriptor. This file descriptor can
* be used with functions 'openat', 'fstatat', ...
*/
diff --git a/include/afb/afb-daemon-v2.h b/include/afb/afb-daemon-v2.h
index 3ecd763b..6cfc60ba 100644
--- a/include/afb/afb-daemon-v2.h
+++ b/include/afb/afb-daemon-v2.h
@@ -69,7 +69,19 @@ static inline struct afb_event afb_daemon_make_event_v2(const char *name)
/*
* 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.
+ *
+ * 'file', 'line' and 'func' are indicators of position of the code in source files
+ * (see macros __FILE__, __LINE__ and __func__).
+ *
+ * 'level' is defined by syslog standard:
+ * EMERGENCY 0 System is unusable
+ * ALERT 1 Action must be taken immediately
+ * CRITICAL 2 Critical conditions
+ * ERROR 3 Error conditions
+ * WARNING 4 Warning conditions
+ * NOTICE 5 Normal but significant condition
+ * INFO 6 Informational
+ * DEBUG 7 Debug-level messages
*/
static inline void afb_daemon_verbose_v2(int level, const char *file, int line, const char * func, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
static inline void afb_daemon_verbose_v2(int level, const char *file, int line, const char * func, const char *fmt, ...)
diff --git a/include/afb/afb-req-itf.h b/include/afb/afb-req-itf.h
index 65f2bfe6..8c18a831 100644
--- a/include/afb/afb-req-itf.h
+++ b/include/afb/afb-req-itf.h
@@ -67,6 +67,8 @@ struct afb_req_itf {
void (*subcall)(void *closure, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *cb_closure);
int (*subcallsync)(void *closure, const char *api, const char *verb, struct json_object *args, struct json_object **result);
+
+ void (*vverbose)(void*closure, int level, const char *file, int line, const char * func, const char *fmt, va_list args);
};
/*
@@ -390,3 +392,35 @@ static inline int afb_req_subcall_sync(struct afb_req req, const char *api, cons
return req.itf->subcallsync(req.closure, api, verb, args, result);
}
+/*
+ * Send associated to 'req' a message described by 'fmt' and following parameters
+ * to the journal for the verbosity 'level'.
+ *
+ * 'file', 'line' and 'func' are indicators of position of the code in source files
+ * (see macros __FILE__, __LINE__ and __func__).
+ *
+ * 'level' is defined by syslog standard:
+ * EMERGENCY 0 System is unusable
+ * ALERT 1 Action must be taken immediately
+ * CRITICAL 2 Critical conditions
+ * ERROR 3 Error conditions
+ * WARNING 4 Warning conditions
+ * NOTICE 5 Normal but significant condition
+ * INFO 6 Informational
+ * DEBUG 7 Debug-level messages
+ */
+static inline void afb_req_verbose(struct afb_req req, int level, const char *file, int line, const char * func, const char *fmt, ...) __attribute__((format(printf, 6, 7)));
+static inline void afb_req_verbose(struct afb_req req, int level, const char *file, int line, const char * func, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ req.itf->vverbose(req.closure, level, file, line, func, fmt, args);
+ va_end(args);
+}
+
+/* macro for setting file, line and function automatically */
+# if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS)
+#define AFB_REQ_VERBOSE(req,level,...) afb_req_verbose(req,level,__FILE__,__LINE__,__func__,__VA_ARGS__)
+#else
+#define AFB_REQ_VERBOSE(req,level,...) afb_req_verbose(req,level,NULL,0,NULL,__VA_ARGS__)
+#endif