20 #define AFW_IMPLEMENTATION_ID "log"
25 impl_log_current_variable_get_cb(
49 { NULL, afw_log_priority_invalid,
"Invalid log priority" }
86 impl_reset_environment_log_mask(
afw_xctx_t *xctx)
97 for (e = self->head->first_log; e; e = e->next) {
99 new_mask |= e->log->impl->
mask;
103 impl->
mask = new_mask;
105 *env_mask = new_mask;
119 impl_log_current_variable_get_cb(
142 source->internal.len = strlen(source->internal.s);
176 context_type_id, xctx->env->
p, xctx);
177 qualifier_definitions =
179 context_type_object, xctx);
181 &afw_s_a_context_type_application_qualifier_definitions_path,
184 variable_definitions =
186 context_type_object, &afw_s_log, xctx);
188 variable_definitions, conf_object_type_id,
191 variable_definitions =
193 context_type_object, &afw_s_current, xctx);
195 &afw_s_message, &afw_s_internal,
198 "Unformatted message that is being logged.",
202 &afw_s_xctxUUID, &afw_s_internal,
205 "The current UUID of the execution context (xctx).",
209 &afw_s_source, &afw_s_internal,
212 "Source file that issued message.",
217 context_type_object, xctx);
232 self->pub.inf = &impl_afw_log_inf;
236 afw_memory_copy(&self->pub.log_id, &impl_afw_log_inf.rti.implementation_id);
237 self->pub.p = xctx->p;
252 return &impl_log_priority_id_map[0];
263 for (e = &impl_log_priority_id_map[0]; e->priority_id; e++) {
278 for (e = &impl_log_priority_id_map[0]; e->priority_id; e++)
280 if (priority == e->priority)
break;
283 return e->priority_id;
312 head = env_log->head;
315 env_log->head = head;
320 for (e = head->first_log; e; e = e->next) {
342 if (!head->first_log) {
346 head->last_log->next = e;
353 afw_log_set_mask((
const afw_log_t *)env_log, impl->
mask, xctx);
368 impl_reset_environment_log_mask(xctx);
399 conf, source_location,
408 impl_afw_log_destroy(
420 impl_afw_log_set_own_mask(
434 impl_write_formatted_message(
450 if (wa->e && (wa->e->log->impl->
filter || wa->e->log->impl->
format))
453 wa->e->log->properties,
456 impl_log_current_variable_get_cb, (
void *)wa,
466 if (wa->e && wa->e->log->impl->
filter) {
478 if (wa->e && wa->e->log->impl->
format) {
483 "log format did not evaluate to single string",
486 wa->formatted_message =
505 wa->source_z, wa->formatted_message, xctx);
548 wa.priority = priority;
549 wa.source_z = source_z;
550 wa.message = message;
560 wa.mask = 1 << priority;
563 wa.e = wa.self->head->first_log;
566 for (; wa.e; wa.e = wa.e->next) {
569 if (wa.e->log->impl->
mask & wa.mask)
571 impl_write_formatted_message(&wa, xctx);
582 impl_write_formatted_message(&wa, xctx);
608 afw_log_internal_register_service_type(
afw_xctx_t *xctx)
613 self->inf = &impl_afw_service_type_inf;
616 if (!self->conf_type) {
620 self->title = &afw_s_a_service_type_log_title;
631 impl_afw_service_type_related_instance_count (
639 return (log) ? 1 : 0;
648 impl_afw_service_type_start_cede_p (
659 &afw_s_logType, p, xctx);
667 "logType %" AFW_UTF8_FMT " is not a registered log type.",
673 properties, p, xctx);
701 for (e = self->head->first_log; e; e = e->next)
716 impl_reset_environment_log_mask(xctx);
725 impl_afw_service_type_restart_cede_p (
735 impl_afw_service_type_start_cede_p(instance, properties, p, xctx);
785 (instance_size != 0) ? instance_size :
sizeof(
afw_log_t),
797 properties, &afw_s_sourceLocation, xctx);
798 if (!self->source_location) {
799 self->source_location = &afw_s_log;
804 &afw_s_logId, p, xctx);
823 &afw_s_filter, xctx);
826 self->source_location, NULL, NULL, p, xctx);
831 &afw_s_format, xctx);
834 self->source_location, NULL, NULL, p, xctx);
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
Interface afw_interface implementation declares.
#define afw_value_is_boolean(A_VALUE)
Macro to determine if value is evaluated boolean.
#define afw_object_old_get_property_as_boolean(object, property_name, found, xctx)
Get property function for data type boolean value.
afw_value_create_string(const afw_utf8_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type string value.
#define afw_object_old_get_property_as_string(object, property_name, xctx)
Get property function for data type string value.
afw_value_allocate_string(const afw_pool_t *p, afw_xctx_t *xctx)
Allocate function for unmanaged data type string value.
afw_value_evaluated_string_inf
Unmanaged evaluated value inf for data type string.
#define afw_value_is_string(A_VALUE)
Macro to determine if value is evaluated string.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
int afw_log_priority_mask_t
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
apr_size_t afw_size_t
size_t.
enum afw_log_priority_e afw_log_priority_t
Log levels. See afw_log.h for more information.
apr_int64_t afw_integer_t
typedef for big signed int.
@ afw_log_priority_trace3
@ afw_log_priority_trace8
@ afw_log_priority_trace4
@ afw_log_priority_notice
@ afw_log_priority_trace2
@ afw_log_priority_trace5
@ afw_log_priority_trace7
@ afw_log_priority_trace6
@ afw_log_priority_warning
@ afw_log_priority_trace1
#define afw_compile_hybrid_source(string, source_location, parent, shared, p, xctx)
Compile hybrid.
afw_context_variable_definition_add_z(const afw_object_t *variable_definitions, const afw_utf8_t *variable_name, const afw_utf8_t *source, const afw_value_inf_t *value_inf, const afw_utf8_z_t *label_z, const afw_utf8_z_t *description_z, const afw_utf8_z_t *data_type_parameter_z, const afw_utf8_z_t *data_type_parameter_formatted_z, afw_xctx_t *xctx)
Add variable definition using 0 terminated label and description.
afw_context_type_insure_qualifier_definitions_object_exists(const afw_object_t *context_type_object, afw_xctx_t *xctx)
Insure qualifier definitions object exists.
afw_context_type_insure_variable_definitions_object_exists(const afw_object_t *context_type_object, const afw_utf8_t *qualifier_id, afw_xctx_t *xctx)
Insure variable definitions object exists for qualifier id.
afw_context_variable_definitions_add_based_on_object_type_id(const afw_object_t *variable_definitions, const afw_utf8_t *object_type_id, afw_boolean_t include_evaluated, afw_xctx_t *xctx)
Add variable definitions based on object type id.
afw_context_type_create(const afw_utf8_t *context_type_id, const afw_pool_t *p, afw_xctx_t *xctx)
Create a context type object.
void afw_environment_register_context_type(const afw_utf8_t *context_type_id, const afw_object_t *context_type_object, afw_xctx_t *xctx)
Register an context type.
void afw_environment_register_service_type(const afw_utf8_t *service_type_id, const afw_service_type_t *service_type, afw_xctx_t *xctx)
Register a service type.
const afw_environment_conf_type_t * afw_environment_get_conf_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the conf_type associated with type.
const afw_object_t * afw_environment_prepare_conf_type_properties(const afw_object_t *properties, afw_xctx_t *xctx)
Prepare properties for a conf type.
const afw_log_t * afw_environment_get_log(const afw_utf8_t *log_id, afw_xctx_t *xctx)
Get the log instance associated with log id.
const afw_log_factory_t * afw_environment_get_log_type(const afw_utf8_t *log_type, afw_xctx_t *xctx)
Get the log factory instance associated with log type.
void afw_environment_register_log(const afw_utf8_t *log_id, const afw_log_t *log, afw_xctx_t *xctx)
Register a log.
#define AFW_FINALLY
Always executed regardless of error.
#define AFW_CATCH_UNHANDLED
Catch an unhandled error that occurs in a AFW_TRY block.
#define AFW_ENDTRY
Ends an AFW try block.
#define AFW_TRY
Begin an AFW TRY block.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_ERROR_THROWN
Access the thrown error. See AFW_TRY.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_LOCK_BEGIN(instance)
Macro to begin a lock section.
afw_lock_release(const afw_lock_t *instance, afw_xctx_t *xctx)
Release lock.
afw_lock_obtain(const afw_lock_t *instance, afw_xctx_t *xctx)
Obtain lock.
#define AFW_LOCK_END
Macro to end a lock section.
#define afw_log_factory_create_log_cede_p(instance, properties, p, xctx)
Call method create_log_cede_p of interface afw_log_factory.
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.
afw_log_impl_throw_property_required(const afw_log_t *log, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Developers should call this for missing required configuration property.
afw_log_impl_throw_property_invalid(const afw_log_t *log, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Developers should call this for configuration property errors.
#define afw_log_write(instance, priority, source_z, message, xctx)
Call method write of interface afw_log.
#define afw_log_set_own_mask(instance, mask, xctx)
Call method set_own_mask of interface afw_log.
void afw_log_internal_conf_type_create_cede_p(const afw_utf8_t *type, const afw_object_t *conf, const afw_utf8_t *source_location, const afw_pool_t *p, afw_xctx_t *xctx)
Configuration handler for entry type "log".
const afw_log_t * afw_log_internal_create_environment_log(afw_xctx_t *xctx)
Internal create environment log.
void afw_log_internal_register_logType_context_type(const afw_utf8_t *log_type_id, afw_xctx_t *xctx)
Register logType context type.
afw_log_add_to_environment(const afw_log_t *instance, afw_xctx_t *xctx)
Add a log to the list of logs called by environment log.
afw_log_write_vz(const afw_log_t *instance, afw_log_priority_t priority, const afw_utf8_z_t *source_z, const afw_utf8_z_t *format_z, va_list ap, afw_xctx_t *xctx)
Log an message using a printf style format and va_list.
afw_log_priority_to_priority_id(afw_log_priority_t priority)
Convert a log priority to priority id.
afw_log_priority_id_to_priority(const afw_utf8_t *priority_id)
Convert a log priority id to priority.
void afw_log_set_priority_in_mask(afw_log_priority_mask_t *mask, afw_log_priority_t priority, afw_boolean_t value)
Set the corresponding bit for a priority in a mask.
afw_log_get_priority_id_map()
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
afw_object_old_get_property_as_utf8(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Get an object's property value as a string in specified pool.
#define afw_pool_destroy(instance, xctx)
Call method destroy of interface afw_pool.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
const afw_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
afw_runtime_get_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Get a runtime object.
void impl_afw_service_type_stop(const afw_service_type_t *instance, const afw_utf8_t *id, afw_xctx_t *xctx)
afw_service_start_using_AdaptiveConf_cede_p(const afw_object_t *conf, const afw_utf8_t *source_location, const afw_pool_t *p, afw_xctx_t *xctx)
Start a service using AdaptiveConf object and cede p.
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.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
afw_utf8_printf(const afw_pool_t *p, afw_xctx_t *xctx, const afw_utf8_z_t *format,...)
Create a utf-8 string using a c format string in specified pool.
afw_utf8_z_source_file(const afw_utf8_z_t *source_z)
Returns value of source_z after last '/ 'or '\'.
#define afw_value_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
afw_value_empty_string
Adaptive value empty string.
afw_xctx_get_qualifier_stack_top(afw_xctx_t *xctx)
Get qualifier stack top.
afw_xctx_push_qualifier_object(const afw_utf8_t *qualifier_name, const afw_object_t *qualifier_object, afw_boolean_t secure, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifier object on to stack.
afw_xctx_set_qualifier_stack_top(int top, afw_xctx_t *xctx)
Set stack top index.
#define afw_xctx_calloc_type(type, xctx)
Macro to allocate cleared memory to hold type in xctx's pool.
afw_xctx_push_qualifier(const afw_utf8_t *qualifier, const afw_object_t *qualifier_object, afw_boolean_t secure, afw_xctx_get_variable_t get, void *data, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifier on to stack.
afw_utf8_t application_id
The id of the application.
const afw_lock_t * active_log_list_lock
Lock for protecting changes to active log list.
const afw_log_t * log
Director log. This log will direct to other logs.
const afw_pool_t * p
Pool used to hold environment.
afw_log_priority_mask_t log_mask
Copy of director log's mask for short circuit tests.
FILE * stderr_fd
Open file descriptor used for writing error output. Default stderr.
Interface afw_log_factory public struct.
Struct for afw_log_impl_t.
afw_log_priority_mask_t mask
const afw_object_t * custom_variables
const afw_value_t * filter
const afw_value_t * format
Interface afw_log_inf_s struct.
Interface afw_log public struct.
Interface afw_object public struct.
Interface afw_pool public struct.
Interface afw_service_type public struct.
NFC normalized UTF-8 string.
struct for data type boolean values.
Interface afw_value public struct.
struct for data type string values.
void * data
Data that will be passed to get/set.
Interface afw_xctx public struct.