Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
win/afw_os_log.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Implementation of afw_log interface for Windows
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw.h"
15 #include "afw_log_impl.h"
16 
17 /* Declares and rti/inf defines for interface afw_log */
18 #define AFW_IMPLEMENTATION_ID "event_log"
19 #include "afw_log_impl_declares.h"
21 
22 /* Typedef for afw_log self. */
23 typedef struct impl_afw_log_self_s {
24  afw_log_t pub;
25 
26  /* Private implementation variables */
27 
29 
30 
31 static const afw_utf8_t impl_factory_description =
32 AFW_UTF8_LITERAL("Log type for writing to event log.");
33 
34 /* Factory singleton instance. */
35 static const afw_log_factory_t impl_afw_log_factory =
36 {
37  &impl_afw_log_factory_inf,
39  &impl_factory_description
40 };
41 
42 
43 /* Get the factory for log type file. */
46 {
47  return &impl_afw_log_factory;
48 }
49 
50 
51 /* Create for os_log */
53  const afw_object_t *properties,
54  const afw_pool_t *p, afw_xctx_t *xctx)
55 {
57 
59  &impl_afw_log_inf, sizeof(impl_afw_os_log_self_),
60  properties, p, xctx);
61 
62  /* Finish processing parameters implementation specific parameters. */
63 
64  /* Return new instance. */
65  return (afw_log_t *)self;
66 }
67 
68 
69 /*
70  * Implementation of method create_log_cede_p of interface afw_log_factory.
71  */
72 const afw_log_t *
73 impl_afw_log_factory_create_log_cede_p (
74  const afw_log_factory_t * instance,
75  const afw_object_t * properties,
76  const afw_pool_t * p,
77  afw_xctx_t *xctx)
78 {
79  return afw_os_log_create(properties, p, xctx);
80 }
81 
82 
83 /*
84  * Implementation of method destroy of interface afw_log.
85  */
86 void
87 impl_afw_log_destroy(
88  const afw_log_t * instance,
89  afw_xctx_t *xctx)
90 {
91  afw_pool_release(instance->p, xctx);
92 }
93 
94 
95 /*
96  * Implementation of method set_mask of interface afw_log.
97  */
98 void
99 impl_afw_log_set_own_mask(
100  const afw_log_t * instance,
102  afw_xctx_t *xctx)
103 {
104  /* Assign instance pointer to self. */
105  impl_afw_os_log_self_ * self =
106  (impl_afw_os_log_self_ *)instance;
107  afw_log_impl_t *impl = (afw_log_impl_t *)instance->impl;
108 
109  /* Set mask. */
110  impl->mask = mask;
111 }
112 
113 
114 
115 /*
116  * Implementation of method write of interface afw_log.
117  */
118 void
120  const afw_log_t * instance,
121  afw_log_priority_t priority,
122  const afw_utf8_z_t * source_z,
123  const afw_utf8_t * message,
124  afw_xctx_t *xctx)
125 {
126  /* Assign instance pointer to self. */
127  impl_afw_os_log_self_ * self =
128  (impl_afw_os_log_self_ *)instance;
129 
131  fprintf(xctx->env->stderr_fd,
132  "FIXME log_type=event_log: %" AFW_UTF8_FMT "\n",
133  AFW_UTF8_FMT_ARG(message));
134 }
Adaptive Framework Core API.
AFW_DEFINE(const afw_object_t *)
Interface afw_interface implementation declares.
Helpers for log implementation development.
Interface afw_interface implementation declares.
#define AFW_IMPLEMENTATION_ID
#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_LITERAL(A_STRING)
String literal initializer.
Definition: afw_common.h:582
int afw_log_priority_mask_t
Definition: afw_common.h:659
#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
enum afw_log_priority_e afw_log_priority_t
Log levels. See afw_log.h for more information.
void impl_afw_log_write(const afw_log_t *instance, afw_log_priority_t priority, const afw_utf8_z_t *source_z, const afw_utf8_t *message, afw_xctx_t *xctx)
afw_log_impl_create_cede_p(const afw_log_inf_t *inf, afw_size_t instance_size, const afw_object_t *properties, const afw_pool_t *p, afw_xctx_t *xctx)
Developers should call this in all create functions for afw_log.
Definition: afw_log.c:769
const afw_log_t * afw_os_log_create(const afw_object_t *properties, const afw_pool_t *p, afw_xctx_t *xctx)
Create an instance of the OS log.
afw_os_log_factory_get()
Get the factory for OS log.
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
FILE * stderr_fd
Open file descriptor used for writing error output. Default stderr.
Definition: afw_common.h:1425
Interface afw_log_factory public struct.
Struct for afw_log_impl_t.
Definition: afw_log_impl.h:35
afw_log_priority_mask_t mask
Definition: afw_log_impl.h:53
Interface afw_log public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_xctx public struct.