Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_debug.c
Go to the documentation of this file.
1 //>>> See COPYING at repository root
2 /*
3  * Adaptive Framework Debug
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
15 #include "afw_internal.h"
16 
17 
18 
19 /* Write debug. */
20 AFW_DEFINE(void)
23  const afw_utf8_z_t *source_z,
24  const afw_utf8_t *message,
25  afw_xctx_t *xctx)
26 {
27  if (rti) {
28  fprintf(xctx->env->debug_fd,
29  ">debug [%" AFW_UTF8_FMT ":%" AFW_UTF8_FMT "] %" AFW_UTF8_FMT
30  " (%s)\n",
31  AFW_UTF8_FMT_ARG(&rti->interface_name),
32  AFW_UTF8_FMT_ARG(&rti->implementation_id),
33  AFW_UTF8_FMT_ARG(message),
34  afw_utf8_z_source_file(source_z));
35  }
36  else {
37  fprintf(xctx->env->debug_fd, ">debug %" AFW_UTF8_FMT " (%s)\n",
38  AFW_UTF8_FMT_ARG(message), afw_utf8_z_source_file(source_z));
39  }
40  fflush(xctx->env->debug_fd);
41 }
42 
43 
44 /* Write debug using a printf style format. */
45 AFW_DEFINE(void)
48  const afw_utf8_z_t * source_z,
49  afw_xctx_t *xctx,
50  const afw_utf8_z_t * format_z,
51  ...)
52 {
53  va_list ap;
54  afw_utf8_t message;
55 
56  va_start(ap, format_z);
57  message.s = apr_pvsprintf(afw_pool_get_apr_pool(xctx->p), format_z, ap);
58  message.len = strlen(message.s);
59  afw_debug_write(rti, source_z, &message, xctx);
60  va_end(ap);
61 }
62 
63 
64 /* Write debug using a printf style format and va_list. */
65 AFW_DEFINE(void)
68  const afw_utf8_z_t *source_z,
69  const afw_utf8_z_t *format_z,
70  va_list ap,
71  afw_xctx_t *xctx)
72 {
73  const afw_utf8_t *message;
74 
75  message = afw_utf8_printf_v(format_z, ap, xctx->p, xctx);
76  afw_debug_write(rti, source_z, message, xctx);
77 }
78 
79 /* Write debug from zero terminate string. */
80 AFW_DEFINE(void)
83  const afw_utf8_z_t * source_z,
84  const afw_utf8_z_t * message_z,
85  afw_xctx_t *xctx)
86 {
87  afw_utf8_t message;
88 
89  message.s = message_z;
90  message.len = strlen(message_z);
91  afw_debug_write(rti, source_z, &message, xctx);
92 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
Definition: afw_common.h:605
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
Definition: afw_common.h:523
afw_debug_write_z(const afw_interface_implementation_rti_t *rti, const afw_utf8_z_t *source_z, const afw_utf8_z_t *message_z, afw_xctx_t *xctx)
Write debug from zero terminate string.
Definition: afw_debug.c:81
afw_debug_write_vz(const afw_interface_implementation_rti_t *rti, const afw_utf8_z_t *source_z, const afw_utf8_z_t *format_z, va_list ap, afw_xctx_t *xctx)
Write debug using a printf style format and va_list.
Definition: afw_debug.c:66
afw_debug_write(const afw_interface_implementation_rti_t *rti, const afw_utf8_z_t *source_z, const afw_utf8_t *message, afw_xctx_t *xctx)
Write debug.
Definition: afw_debug.c:21
afw_debug_write_fz(const afw_interface_implementation_rti_t *rti, const afw_utf8_z_t *source_z, afw_xctx_t *xctx, const afw_utf8_z_t *format_z,...)
Write debug using a printf style format.
Definition: afw_debug.c:46
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
afw_utf8_printf_v(const afw_utf8_z_t *format, va_list arg, const afw_pool_t *p, afw_xctx_t *xctx)
Create a utf-8 string using a c format string in specified pool.
Definition: afw_utf8.c:477
afw_utf8_z_source_file(const afw_utf8_z_t *source_z)
Returns value of source_z after last '/ 'or '\'.
Definition: afw_utf8.c:1037
Interface Implementation Run Time Information.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_xctx public struct.