afb-ditf: track daemon state
[src/app-framework-binder.git] / docs / afb-binding-references.md
1 # Binding Reference
2
3 ## Structure for declaring binding
4
5 ### struct afb_binding_v2
6
7 The main structure, of type **afb_binding_v2**, for describing the binding
8 must be exported under the name **afbBindingV2**.
9
10 This structure is defined as below.
11
12 ```C
13 /*
14  * Description of the bindings of type version 2
15  */
16 struct afb_binding_v2
17 {
18         const char *api;                        /* api name for the binding */
19         const char *specification;              /* textual openAPIv3 specification of the binding */
20         const char *info;                       /* some info about the api, can be NULL */
21         const struct afb_verb_v2 *verbs;        /* array of descriptions of verbs terminated by a NULL name */
22         int (*preinit)();                       /* callback at load of the binding */
23         int (*init)();                          /* callback for starting the service */
24         void (*onevent)(const char *event, struct json_object *object); /* callback for handling events */
25         unsigned noconcurrency: 1;              /* avoids concurrent requests to verbs */
26 };
27 ```
28
29 ### struct afb_verb_v2
30
31 Each verb is described with a structure of type **afb_verb_v2**
32 defined below:
33
34 ```C
35 /*
36  * Description of one verb of the API provided by the binding
37  * This enumeration is valid for bindings of type version 2
38  */
39 struct afb_verb_v2
40 {
41         const char *verb;                       /* name of the verb */
42         void (*callback)(struct afb_req req);   /* callback function implementing the verb */
43         const struct afb_auth *auth;            /* required authorization */
44         const char *info;                       /* some info about the verb, can be NULL */
45         uint32_t session;                       /* authorization and session requirements of the verb */
46 };
47 ```
48
49 The **session** flags is one of the constant defined below:
50
51 - AFB_SESSION_NONE : no flag, synonym to 0
52 - AFB_SESSION_LOA_0 : Requires the LOA to be 0 or more, synonym to 0 or AFB_SESSION_NONE
53 - AFB_SESSION_LOA_1 : Requires the LOA to be 1 or more
54 - AFB_SESSION_LOA_2 : Requires the LOA to be 2 or more
55 - AFB_SESSION_LOA_3 : Requires the LOA to be 3 or more
56 - AFB_SESSION_CHECK : Requires the token to be set and valid
57 - AFB_SESSION_REFRESH : Implies a token refresh
58 - AFB_SESSION_CLOSE : Implies cloing the session
59
60 The LOA (Level Of Assurance) is set, by binding, using the function **afb_req_session_set_LOA**.
61
62 ### struct afb_auth and enum afb_auth_type
63
64 The structure **afb_auth** is used within verb description to
65 set security requirements.  
66 The interpretation of the structure depends on the value of the field **type**.
67
68 ```C
69 struct afb_auth
70 {
71         const enum afb_auth_type type;
72         union {
73                 const char *text;
74                 const unsigned loa;
75                 const struct afb_auth *first;
76         };
77         const struct afb_auth *next;
78 };
79 ```
80
81 The possible values for **type** is defined here:
82
83 ```C
84 /*
85  * Enum for Session/Token/Assurance middleware.
86  */
87 enum afb_auth_type
88 {
89         afb_auth_No = 0,        /** never authorized, no data */
90         afb_auth_Token,         /** authorized if token valid, no data */
91         afb_auth_LOA,           /** authorized if LOA greater than data 'loa' */
92         afb_auth_Permission,    /** authorized if permission 'text' is granted */
93         afb_auth_Or,            /** authorized if 'first' or 'next' is authorized */
94         afb_auth_And,           /** authorized if 'first' and 'next' are authorized */
95         afb_auth_Not,           /** authorized if 'first' is not authorized */
96         afb_auth_Yes            /** always authorized, no data */
97 };
98 ```
99
100 Example:
101
102 ```C
103 static const struct afb_auth _afb_auths_v2_monitor[] = {
104     { .type = afb_auth_Permission, .text = "urn:AGL:permission:monitor:public:set" },
105     { .type = afb_auth_Permission, .text = "urn:AGL:permission:monitor:public:get" },
106     { .type = afb_auth_Or, .first = &_afb_auths_v2_monitor[1], .next = &_afb_auths_v2_monitor[0] }
107 };
108 ```
109
110 ## Functions of class afb_daemon
111
112 The 3 following functions are linked to libsystemd.  
113 They allow use of **sd_event** features and access
114 to **sd_bus** features.
115
116 ```C
117 /*
118  * Retrieves the common systemd's event loop of AFB
119  */
120 struct sd_event *afb_daemon_get_event_loop();
121
122 /*
123  * Retrieves the common systemd's user/session d-bus of AFB
124  */
125 struct sd_bus *afb_daemon_get_user_bus();
126
127 /*
128  * Retrieves the common systemd's system d-bus of AFB
129  */
130 struct sd_bus *afb_daemon_get_system_bus();
131 ```
132
133 The 2 following functions are linked to event management.  
134 Broadcasting an event send it to any possible listener.
135
136 ```C
137 /*
138  * Broadcasts widely the event of 'name' with the data 'object'.
139  * 'object' can be NULL.
140  *
141  * For convenience, the function calls 'json_object_put' for 'object'.
142  * Thus, in the case where 'object' should remain available after
143  * the function returns, the function 'json_object_get' shall be used.
144  *
145  * Calling this function is only forbidden during preinit.
146  *
147  * Returns the count of clients that received the event.
148  */
149 int afb_daemon_broadcast_event(const char *name, struct json_object *object);
150
151 /*
152  * Creates an event of 'name' and returns it.
153  *
154  * Calling this function is only forbidden during preinit.
155  *
156  * See afb_event_is_valid to check if there is an error.
157  */
158 struct afb_event afb_daemon_make_event(const char *name);
159 ```
160
161 The following function is used by logging macros and should normally
162 not be used.  
163 Instead, you should use the macros:
164
165 - **AFB\_ERROR**
166 - **AFB\_WARNING**
167 - **AFB\_NOTICE**
168 - **AFB\_INFO**
169 - **AFB\_DEBUG**
170
171 ```C
172 /*
173  * Send a message described by 'fmt' and following parameters
174  * to the journal for the verbosity 'level'.
175  *
176  * 'file', 'line' and 'func' are indicators of position of the code in source files
177  * (see macros __FILE__, __LINE__ and __func__).
178  *
179  * 'level' is defined by syslog standard:
180  *      EMERGENCY         0        System is unusable
181  *      ALERT             1        Action must be taken immediately
182  *      CRITICAL          2        Critical conditions
183  *      ERROR             3        Error conditions
184  *      WARNING           4        Warning conditions
185  *      NOTICE            5        Normal but significant condition
186  *      INFO              6        Informational
187  *      DEBUG             7        Debug-level messages
188  */
189 void afb_daemon_verbose(int level, const char *file, int line, const char * func, const char *fmt, ...);
190 ```
191
192 The 2 following functions MUST be used to access data of the bindings.
193
194 ```C
195 /*
196  * Get the root directory file descriptor. This file descriptor can
197  * be used with functions 'openat', 'fstatat', ...
198  */
199 int afb_daemon_rootdir_get_fd();
200
201 /*
202  * Opens 'filename' within the root directory with 'flags' (see function openat)
203  * using the 'locale' definition (example: "jp,en-US") that can be NULL.
204  * Returns the file descriptor or -1 in case of error.
205  */
206 int afb_daemon_rootdir_open_locale(const char *filename, int flags, const char *locale);
207 ```
208
209 The following function is used to queue jobs.
210
211 ```C
212 /*
213  * Queue the job defined by 'callback' and 'argument' for being executed asynchronously
214  * in this thread (later) or in an other thread.
215  * If 'group' is not NUL, the jobs queued with a same value (as the pointer value 'group')
216  * are executed in sequence in the order of there submission.
217  * If 'timeout' is not 0, it represent the maximum execution time for the job in seconds.
218  * At first, the job is called with 0 as signum and the given argument.
219  * The job is executed with the monitoring of its time and some signals like SIGSEGV and
220  * SIGFPE. When a such signal is catched, the job is terminated and re-executed but with
221  * signum being the signal number (SIGALRM when timeout expired).
222  *
223  * Returns 0 in case of success or -1 in case of error.
224  */
225 int afb_daemon_queue_job(void (*callback)(int signum, void *arg), void *argument, void *group, int timeout)
226 ```
227
228 The following function must be used when a binding depends on other
229 bindings at its initialization.
230
231 ```C
232 /*
233  * Tells that it requires the API of "name" to exist
234  * and if 'initialized' is not null to be initialized.
235  * Calling this function is only allowed within init.
236  * Returns 0 in case of success or -1 in case of error.
237  */
238 int afb_daemon_require_api(const char *name, int initialized)
239 ```
240
241 ## Functions of class afb_service
242
243 The following functions allow services to call verbs of other
244 bindings for themselves.
245
246 ```C
247 /**
248  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the name of the binding.
249  * The result of the call is delivered to the 'callback' function with the 'callback_closure'.
250  *
251  * For convenience, the function calls 'json_object_put' for 'args'.
252  * Thus, in the case where 'args' should remain available after
253  * the function returns, the function 'json_object_get' shall be used.
254  *
255  * The 'callback' receives 3 arguments:
256  *  1. 'closure' the user defined closure pointer 'callback_closure',
257  *  2. 'status' a status being 0 on success or negative when an error occured,
258  *  2. 'result' the resulting data as a JSON object.
259  *
260  * @param api      The api name of the method to call
261  * @param verb     The verb name of the method to call
262  * @param args     The arguments to pass to the method
263  * @param callback The to call on completion
264  * @param callback_closure The closure to pass to the callback
265  *
266  * @see also 'afb_req_subcall'
267  */
268 void afb_service_call(
269     const char *api,
270     const char *verb,
271     struct json_object *args,
272     void (*callback)(void*closure, int status, struct json_object *result),
273     void *callback_closure);
274
275 /**
276  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the name of the binding.
277  * 'result' will receive the response.
278  *
279  * For convenience, the function calls 'json_object_put' for 'args'.
280  * Thus, in the case where 'args' should remain available after
281  * the function returns, the function 'json_object_get' shall be used.
282  *
283  * @param api      The api name of the method to call
284  * @param verb     The verb name of the method to call
285  * @param args     The arguments to pass to the method
286  * @param result   Where to store the result - should call json_object_put on it -
287  *
288  * @returns 0 in case of success or a negative value in case of error.
289  *
290  * @see also 'afb_req_subcall'
291  */
292 int afb_service_call_sync(
293     const char *api,
294     const char *verb,
295     struct json_object *args,
296     struct json_object **result);
297 ```
298
299 ## Functions of class afb_event
300
301 This function checks whether the event is valid.  
302 It must be used when creating events.
303
304 ```C
305 /*
306  * Checks wether the 'event' is valid or not.
307  *
308  * Returns 0 if not valid or 1 if valid.
309  */
310 int afb_event_is_valid(struct afb_event event);
311 ```
312
313 The two following functions are used to broadcast or push
314 event with its data.
315
316 ```C
317 /*
318  * Broadcasts widely the 'event' with the data 'object'.
319  * 'object' can be NULL.
320  *
321  * For convenience, the function calls 'json_object_put' for 'object'.
322  * Thus, in the case where 'object' should remain available after
323  * the function returns, the function 'json_object_get' shall be used.
324  *
325  * Returns the count of clients that received the event.
326  */
327 int afb_event_broadcast(struct afb_event event, struct json_object *object);
328
329 /*
330  * Pushes the 'event' with the data 'object' to its observers.
331  * 'object' can be NULL.
332  *
333  * For convenience, the function calls 'json_object_put' for 'object'.
334  * Thus, in the case where 'object' should remain available after
335  * the function returns, the function 'json_object_get' shall be used.
336  *
337  * Returns the count of clients that received the event.
338  */
339 int afb_event_push(struct afb_event event, struct json_object *object);
340 ```
341
342 The following function destiys the event.
343
344 ```C
345 /*
346  * Drops the data associated to the 'event'
347  * After calling this function, the event
348  * MUST NOT BE USED ANYMORE.
349  */
350 void afb_event_drop(struct afb_event event);
351 ```
352
353 This function allows to retrieve the exact name of the event.
354
355 ```C
356 /*
357  * Gets the name associated to the 'event'.
358  */
359 const char *afb_event_name(struct afb_event event);
360 ```
361
362 ## Functions of class afb_req
363
364 This function checks the validity of the **req**.
365
366 ```C
367 /*
368  * Checks wether the request 'req' is valid or not.
369  *
370  * Returns 0 if not valid or 1 if valid.
371  */
372 int afb_req_is_valid(struct afb_req req);
373 ```
374
375 The following functions retrieves parameters of the request.
376
377 ```C
378 /*
379  * Gets from the request 'req' the argument of 'name'.
380  * Returns a PLAIN structure of type 'struct afb_arg'.
381  * When the argument of 'name' is not found, all fields of result are set to NULL.
382  * When the argument of 'name' is found, the fields are filled,
383  * in particular, the field 'result.name' is set to 'name'.
384  *
385  * There is a special name value: the empty string.
386  * The argument of name "" is defined only if the request was made using
387  * an HTTP POST of Content-Type "application/json". In that case, the
388  * argument of name "" receives the value of the body of the HTTP request.
389  */
390 struct afb_arg afb_req_get(struct afb_req req, const char *name);
391
392 /*
393  * Gets from the request 'req' the string value of the argument of 'name'.
394  * Returns NULL if when there is no argument of 'name'.
395  * Returns the value of the argument of 'name' otherwise.
396  *
397  * Shortcut for: afb_req_get(req, name).value
398  */
399 const char *afb_req_value(struct afb_req req, const char *name);
400
401 /*
402  * Gets from the request 'req' the path for file attached to the argument of 'name'.
403  * Returns NULL if when there is no argument of 'name' or when there is no file.
404  * Returns the path of the argument of 'name' otherwise.
405  *
406  * Shortcut for: afb_req_get(req, name).path
407  */
408 const char *afb_req_path(struct afb_req req, const char *name);
409
410 /*
411  * Gets from the request 'req' the json object hashing the arguments.
412  * The returned object must not be released using 'json_object_put'.
413  */
414 struct json_object *afb_req_json(struct afb_req req);
415 ```
416
417 The following functions emit the reply to the request.
418
419 ```C
420 /*
421  * Sends a reply of kind success to the request 'req'.
422  * The status of the reply is automatically set to "success".
423  * Its send the object 'obj' (can be NULL) with an
424  * informationnal comment 'info (can also be NULL).
425  *
426  * For convenience, the function calls 'json_object_put' for 'obj'.
427  * Thus, in the case where 'obj' should remain available after
428  * the function returns, the function 'json_object_get' shall be used.
429  */
430 void afb_req_success(struct afb_req req, struct json_object *obj, const char *info);
431
432 /*
433  * Same as 'afb_req_success' but the 'info' is a formatting
434  * string followed by arguments.
435  *
436  * For convenience, the function calls 'json_object_put' for 'obj'.
437  * Thus, in the case where 'obj' should remain available after
438  * the function returns, the function 'json_object_get' shall be used.
439  */
440 void afb_req_success_f(struct afb_req req, struct json_object *obj, const char *info, ...);
441
442 /*
443  * Same as 'afb_req_success_f' but the arguments to the format 'info'
444  * are given as a variable argument list instance.
445  *
446  * For convenience, the function calls 'json_object_put' for 'obj'.
447  * Thus, in the case where 'obj' should remain available after
448  * the function returns, the function 'json_object_get' shall be used.
449  */
450 void afb_req_success_v(struct afb_req req, struct json_object *obj, const char *info, va_list args);
451
452 /*
453  * Sends a reply of kind failure to the request 'req'.
454  * The status of the reply is set to 'status' and an
455  * informationnal comment 'info' (can also be NULL) can be added.
456  *
457  * Note that calling afb_req_fail("success", info) is equivalent
458  * to call afb_req_success(NULL, info). Thus even if possible it
459  * is strongly recommended to NEVER use "success" for status.
460  */
461 void afb_req_fail(struct afb_req req, const char *status, const char *info);
462
463 /*
464  * Same as 'afb_req_fail' but the 'info' is a formatting
465  * string followed by arguments.
466  */
467 void afb_req_fail_f(struct afb_req req, const char *status, const char *info, ...);
468
469 /*
470  * Same as 'afb_req_fail_f' but the arguments to the format 'info'
471  * are given as a variable argument list instance.
472  */
473 void afb_req_fail_v(struct afb_req req, const char *status, const char *info, va_list args);
474 ```
475
476 The following functions handle the session data.
477
478 ```C
479 /*
480  * Gets the pointer stored by the binding for the session of 'req'.
481  * When the binding has not yet recorded a pointer, NULL is returned.
482  */
483 void *afb_req_context_get(struct afb_req req);
484
485 /*
486  * Stores for the binding the pointer 'context' to the session of 'req'.
487  * The function 'free_context' will be called when the session is closed
488  * or if binding stores an other pointer.
489  */
490 void afb_req_context_set(struct afb_req req, void *context, void (*free_context)(void*));
491
492 /*
493  * Gets the pointer stored by the binding for the session of 'req'.
494  * If the stored pointer is NULL, indicating that no pointer was
495  * already stored, afb_req_context creates a new context by calling
496  * the function 'create_context' and stores it with the freeing function
497  * 'free_context'.
498  */
499 void *afb_req_context(struct afb_req req, void *(*create_context)(), void (*free_context)(void*));
500
501 /*
502  * Frees the pointer stored by the binding for the session of 'req'
503  * and sets it to NULL.
504  *
505  * Shortcut for: afb_req_context_set(req, NULL, NULL)
506  */
507 void afb_req_context_clear(struct afb_req req);
508
509 /*
510  * Closes the session associated with 'req'
511  * and delete all associated contexts.
512  */
513 void afb_req_session_close(struct afb_req req);
514
515 /*
516  * Sets the level of assurance of the session of 'req'
517  * to 'level'. The effect of this function is subject of
518  * security policies.
519  * Returns 1 on success or 0 if failed.
520  */
521 int afb_req_session_set_LOA(struct afb_req req, unsigned level);
522 ```
523
524 The 4 following functions must be used for asynchronous handling requests.
525
526 ```C
527 /*
528  * Adds one to the count of references of 'req'.
529  * This function MUST be called by asynchronous implementations
530  * of verbs if no reply was sent before returning.
531  */
532 void afb_req_addref(struct afb_req req);
533
534 /*
535  * Substracts one to the count of references of 'req'.
536  * This function MUST be called by asynchronous implementations
537  * of verbs after sending the asynchronous reply.
538  */
539 void afb_req_unref(struct afb_req req);
540
541 /*
542  * Stores 'req' on heap for asynchronous use.
543  * Returns a handler to the stored 'req' or NULL on memory depletion.
544  * The count of reference to 'req' is incremented on success
545  * (see afb_req_addref).
546  */
547 struct afb_stored_req *afb_req_store(struct afb_req req);
548
549 /*
550  * Retrieves the afb_req stored at 'sreq'.
551  * Returns the stored request.
552  * The count of reference is UNCHANGED, thus, the
553  * function 'afb_req_unref' should be called on the result
554  * after that the asynchronous reply if sent.
555  */
556 struct afb_req afb_req_unstore(struct afb_stored_req *sreq);
557 ```
558
559 The two following functions are used to associate client with events
560 (subscription).
561
562 ```C
563 /*
564  * Establishes for the client link identified by 'req' a subscription
565  * to the 'event'.
566  * Returns 0 in case of successful subscription or -1 in case of error.
567  */
568 int afb_req_subscribe(struct afb_req req, struct afb_event event);
569
570 /*
571  * Revokes the subscription established to the 'event' for the client
572  * link identified by 'req'.
573  * Returns 0 in case of successful subscription or -1 in case of error.
574  */
575 int afb_req_unsubscribe(struct afb_req req, struct afb_event event);
576 ```
577
578 The following functions must be used to make request in the name of the
579 client (with its permissions).
580
581 ```C
582 /*
583  * Makes a call to the method of name 'api' / 'verb' with the object 'args'.
584  * This call is made in the context of the request 'req'.
585  * On completion, the function 'callback' is invoked with the
586  * 'closure' given at call and two other parameters: 'iserror' and 'result'.
587  * 'status' is 0 on success or negative when on an error reply.
588  * 'result' is the json object of the reply, you must not call json_object_put
589  * on the result.
590  *
591  * For convenience, the function calls 'json_object_put' for 'args'.
592  * Thus, in the case where 'args' should remain available after
593  * the function returns, the function 'json_object_get' shall be used.
594  *
595  * See also:
596  *  - 'afb_req_subcall_req' that is convenient to keep request alive automatically.
597  *  - 'afb_req_subcall_sync' the synchronous version
598  */
599 void afb_req_subcall(
600                 struct afb_req req,
601                 const char *api,
602                 const char *verb,
603                 struct json_object *args,
604                 void (*callback)(void *closure, int status, struct json_object *result),
605                 void *closure);
606
607 /*
608  * Makes a call to the method of name 'api' / 'verb' with the object 'args'.
609  * This call is made in the context of the request 'req'.
610  * On completion, the function 'callback' is invoked with the
611  * original request 'req', the 'closure' given at call and two
612  * other parameters: 'iserror' and 'result'.
613  * 'status' is 0 on success or negative when on an error reply.
614  * 'result' is the json object of the reply, you must not call json_object_put
615  * on the result.
616  *
617  * For convenience, the function calls 'json_object_put' for 'args'.
618  * Thus, in the case where 'args' should remain available after
619  * the function returns, the function 'json_object_get' shall be used.
620  *
621  * See also:
622  *  - 'afb_req_subcall' that doesn't keep request alive automatically.
623  *  - 'afb_req_subcall_sync' the synchronous version
624  */
625 static inline void afb_req_subcall_req(struct afb_req req, const char *api, const char *verb, struct json_object *args, void (*callback)(void *closure, int iserror, struct json_object *result, struct afb_req req), void *closure)
626 {
627         req.itf->subcall_req(req.closure, api, verb, args, callback, closure);
628 }
629
630 /*
631  * Makes a call to the method of name 'api' / 'verb' with the object 'args'.
632  * This call is made in the context of the request 'req'.
633  * This call is synchronous, it waits untill completion of the request.
634  * It returns 0 on success or a negative value on error answer.
635  * The object pointed by 'result' is filled and must be released by the caller
636  * after its use by calling 'json_object_put'.
637  *
638  * For convenience, the function calls 'json_object_put' for 'args'.
639  * Thus, in the case where 'args' should remain available after
640  * the function returns, the function 'json_object_get' shall be used.
641  *
642  * See also:
643  *  - 'afb_req_subcall_req' that is convenient to keep request alive automatically.
644  *  - 'afb_req_subcall' that doesn't keep request alive automatically.
645  */
646 int afb_req_subcall_sync(
647                 struct afb_req req,
648                 const char *api,
649                 const char *verb,
650                 struct json_object *args,
651                 struct json_object **result);
652 ```
653
654 The following function is used by logging macros and should normally
655 not be used.  
656 Instead, you should use the macros:
657
658 - **AFB_REQ_ERROR**
659 - **AFB_REQ_WARNING**
660 - **AFB_REQ_NOTICE**
661 - **AFB_REQ_INFO**
662 - **AFB_REQ_DEBUG**
663
664 ```C
665 /*
666  * Send associated to 'req' a message described by 'fmt' and following parameters
667  * to the journal for the verbosity 'level'.
668  *
669  * 'file', 'line' and 'func' are indicators of position of the code in source files
670  * (see macros __FILE__, __LINE__ and __func__).
671  *
672  * 'level' is defined by syslog standard:
673  *      EMERGENCY         0        System is unusable
674  *      ALERT             1        Action must be taken immediately
675  *      CRITICAL          2        Critical conditions
676  *      ERROR             3        Error conditions
677  *      WARNING           4        Warning conditions
678  *      NOTICE            5        Normal but significant condition
679  *      INFO              6        Informational
680  *      DEBUG             7        Debug-level messages
681  */
682 void afb_req_verbose(struct afb_req req, int level, const char *file, int line, const char * func, const char *fmt, ...);
683 ```
684
685 The function below allows a binding to check whether a client
686 has a permission of not.
687
688 ```C
689
690 /*
691  * Check whether the 'permission' is granted or not to the client
692  * identified by 'req'.
693  *
694  * Returns 1 if the permission is granted or 0 otherwise.
695  */
696 int afb_req_has_permission(struct afb_req req, const char *permission);
697 ```
698
699 ## Logging macros
700
701 The following macros must be used for logging:
702
703 ```C
704 AFB_ERROR(fmt,...)
705 AFB_WARNING(fmt,...)
706 AFB_NOTICE(fmt,...)
707 AFB_INFO(fmt,...)
708 AFB_DEBUG(fmt,...)
709 ```
710
711 The following macros can be used for logging in the context
712 of a request **req** of type **afb_req**:
713
714 ```C
715 AFB_REQ_ERROR(req,fmt,...)
716 AFB_REQ_WARNING(req,fmt,...)
717 AFB_REQ_NOTICE(req,fmt,...)
718 AFB_REQ_INFO(req,fmt,...)
719 AFB_REQ_DEBUG(req,fmt,...)
720 ```
721
722 By default, the logging macros add file, line and function
723 indication.