Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_log_file.c
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Implementation of afw_log interface for log director
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
15 #include "afw_internal.h"
16 
17 
18 
19 /* Declares and rti/inf defines for interface afw_log */
20 #define AFW_IMPLEMENTATION_ID "file"
22 #include "afw_log_impl_declares.h"
23 
24 
25 typedef struct impl_log_self_s {
26  afw_log_t pub;
27  const afw_expression_t *expression;
29 
30 
31 static const afw_utf8_t impl_factory_description =
32 AFW_UTF8_LITERAL("Log type for writing log to a file.");
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 /*
52  * Implementation of method create_log_cede_p of interface afw_log_factory.
53  */
54 const afw_log_t *
55 impl_afw_log_factory_create_log_cede_p (
56  const afw_log_factory_t * instance,
57  const afw_object_t * properties,
58  const afw_pool_t * p,
59  afw_xctx_t *xctx)
60 {
62 
64  &impl_afw_log_inf, sizeof(impl_afw_log_file_self_t),
65  properties, p, xctx);
66 
67  /* Finish processing parameters implementation specific parameters. */
68 
69  /* Return new instance. */
70  return (afw_log_t *)self;
71 }
72 
73 
74 
75 /*
76  * Implementation of method destroy of interface afw_log.
77  */
78 void
79 impl_afw_log_destroy(
80  const afw_log_t * instance,
81  afw_xctx_t *xctx)
82 {
83  afw_pool_release(instance->p, xctx);
84 }
85 
86 
87 
88 /*
89  * Implementation of method set_mask of interface afw_log.
90  */
91 void
92 impl_afw_log_set_own_mask(
93  const afw_log_t * instance,
95  afw_xctx_t *xctx)
96 {
97  afw_log_impl_t *impl = (afw_log_impl_t *)instance->impl;
98 
99  /* Set mask. */
100  impl->mask = mask;
101 }
102 
103 
104 
105 /*
106  * Implementation of method write of interface afw_log.
107  */
108 void
110  const afw_log_t * instance,
111  afw_log_priority_t priority,
112  const afw_utf8_z_t * source_z,
113  const afw_utf8_t * message,
114  afw_xctx_t *xctx)
115 {
116  fprintf(xctx->env->stdout_fd, "FIXME log_type=file: %" AFW_UTF8_FMT "\n",
117  AFW_UTF8_FMT_ARG(message));
118 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
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
struct afw_expression_s afw_expression_t
#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)
Definition: afw_log_file.c:109
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
afw_log_file_factory_get()
Get the factory for log type file.
Definition: afw_log_file.c:45
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
FILE * stdout_fd
Open file descriptor used for writing standard output. Default stdout.
Definition: afw_common.h:1428
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.