2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 #include "afb-session-v2.h"
22 #include "afb-verbosity.h"
24 #include "afb-eventid.h"
25 #include "afb-request.h"
26 #include "afb-dynapi.h"
29 * The function afbBindingVdyn if exported allows to create
30 * pure dynamic bindings. When the binding is loaded, it receives
31 * a virtual dynapi that can be used to create apis. The
32 * given API can not be used except for creating dynamic apis.
34 extern int afbBindingVdyn(struct afb_dynapi *dynapi);
37 * Macros for logging messages
39 #if defined(AFB_BINDING_PRAGMA_NO_VERBOSE_DATA)
41 # define _AFB_DYNAPI_LOGGING_(vlevel,llevel,dynapi,...) \
43 if(dynapi->verbosity>=vlevel) {\
44 if (llevel <= AFB_VERBOSITY_LEVEL_ERROR) \
45 afb_dynapi_verbose(dynapi,llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
47 afb_dynapi_verbose(dynapi,llevel,__FILE__,__LINE__,NULL,NULL); \
50 # define _AFB_REQUEST_LOGGING_(vlevel,llevel,request,...) \
52 if(request->dynapi->verbosity>=vlevel) \
53 afb_request_verbose(request,llevel,__FILE__,__LINE__,NULL,NULL); \
56 #elif defined(AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS)
58 # define _AFB_DYNAPI_LOGGING_(vlevel,llevel,dynapi,...) \
60 if(dynapi->verbosity>=vlevel) \
61 afb_dynapi_verbose(dynapi,llevel,NULL,0,NULL,__VA_ARGS__); \
63 # define _AFB_REQUEST_LOGGING_(vlevel,llevel,request,...) \
65 if(request->dynapi->verbosity>=vlevel) \
66 afb_request_verbose(request,llevel,NULL,0,NULL,__VA_ARGS__); \
71 # define _AFB_DYNAPI_LOGGING_(vlevel,llevel,dynapi,...) \
73 if(dynapi->verbosity>=vlevel) \
74 afb_dynapi_verbose(dynapi,llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
76 # define _AFB_REQUEST_LOGGING_(vlevel,llevel,request,...) \
78 if(request->dynapi->verbosity>=vlevel) \
79 afb_request_verbose(request,llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \
84 #define AFB_DYNAPI_ERROR(...) _AFB_DYNAPI_LOGGING_(AFB_VERBOSITY_LEVEL_ERROR,_AFB_SYSLOG_LEVEL_ERROR_,__VA_ARGS__)
85 #define AFB_DYNAPI_WARNING(...) _AFB_DYNAPI_LOGGING_(AFB_VERBOSITY_LEVEL_WARNING,_AFB_SYSLOG_LEVEL_WARNING_,__VA_ARGS__)
86 #define AFB_DYNAPI_NOTICE(...) _AFB_DYNAPI_LOGGING_(AFB_VERBOSITY_LEVEL_NOTICE,_AFB_SYSLOG_LEVEL_NOTICE_,__VA_ARGS__)
87 #define AFB_DYNAPI_INFO(...) _AFB_DYNAPI_LOGGING_(AFB_VERBOSITY_LEVEL_INFO,_AFB_SYSLOG_LEVEL_INFO_,__VA_ARGS__)
88 #define AFB_DYNAPI_DEBUG(...) _AFB_DYNAPI_LOGGING_(AFB_VERBOSITY_LEVEL_DEBUG,_AFB_SYSLOG_LEVEL_DEBUG_,__VA_ARGS__)
89 #define AFB_REQUEST_ERROR(...) _AFB_REQUEST_LOGGING_(AFB_VERBOSITY_LEVEL_ERROR,_AFB_SYSLOG_LEVEL_ERROR_,__VA_ARGS__)
90 #define AFB_REQUEST_WARNING(...) _AFB_REQUEST_LOGGING_(AFB_VERBOSITY_LEVEL_WARNING,_AFB_SYSLOG_LEVEL_WARNING_,__VA_ARGS__)
91 #define AFB_REQUEST_NOTICE(...) _AFB_REQUEST_LOGGING_(AFB_VERBOSITY_LEVEL_NOTICE,_AFB_SYSLOG_LEVEL_NOTICE_,__VA_ARGS__)
92 #define AFB_REQUEST_INFO(...) _AFB_REQUEST_LOGGING_(AFB_VERBOSITY_LEVEL_INFO,_AFB_SYSLOG_LEVEL_INFO_,__VA_ARGS__)
93 #define AFB_REQUEST_DEBUG(...) _AFB_REQUEST_LOGGING_(AFB_VERBOSITY_LEVEL_DEBUG,_AFB_SYSLOG_LEVEL_DEBUG_,__VA_ARGS__)