From 1e760b4a1c2b5b7695abe2bd2a3fc27ee3498417 Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 30 Jul 2023 09:13:56 +0900 Subject: [PATCH] log_event_encoder: add explicit flb_log_event_type_t Signed-off-by: Takahiro Yamashita --- include/fluent-bit/flb_log_event_encoder.h | 58 +++++++++++----------- src/flb_log_event_encoder_primitives.c | 8 +-- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/include/fluent-bit/flb_log_event_encoder.h b/include/fluent-bit/flb_log_event_encoder.h index d4c6c2520ad..37f4500e80f 100644 --- a/include/fluent-bit/flb_log_event_encoder.h +++ b/include/fluent-bit/flb_log_event_encoder.h @@ -36,33 +36,35 @@ #define FLB_EVENT_ENCODER_ERROR_SERIALIZATION_FAILURE -5 #define FLB_EVENT_ENCODER_ERROR_INVALID_VALUE_TYPE -6 -#define FLB_LOG_EVENT_APPEND_TERMINATOR_VALUE_TYPE 0 - -#define FLB_LOG_EVENT_STRING_LENGTH_VALUE_TYPE 1 -#define FLB_LOG_EVENT_STRING_BODY_VALUE_TYPE 2 -#define FLB_LOG_EVENT_BINARY_LENGTH_VALUE_TYPE 3 -#define FLB_LOG_EVENT_BINARY_BODY_VALUE_TYPE 4 -#define FLB_LOG_EVENT_EXT_LENGTH_VALUE_TYPE 5 -#define FLB_LOG_EVENT_EXT_BODY_VALUE_TYPE 6 -#define FLB_LOG_EVENT_NULL_VALUE_TYPE 7 -#define FLB_LOG_EVENT_CHAR_VALUE_TYPE 8 -#define FLB_LOG_EVENT_INT8_VALUE_TYPE 9 -#define FLB_LOG_EVENT_INT16_VALUE_TYPE 10 -#define FLB_LOG_EVENT_INT32_VALUE_TYPE 11 -#define FLB_LOG_EVENT_INT64_VALUE_TYPE 12 -#define FLB_LOG_EVENT_UINT8_VALUE_TYPE 13 -#define FLB_LOG_EVENT_UINT16_VALUE_TYPE 14 -#define FLB_LOG_EVENT_UINT32_VALUE_TYPE 15 -#define FLB_LOG_EVENT_UINT64_VALUE_TYPE 16 -#define FLB_LOG_EVENT_DOUBLE_VALUE_TYPE 17 -#define FLB_LOG_EVENT_BOOLEAN_VALUE_TYPE 18 -#define FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE_TYPE 19 -#define FLB_LOG_EVENT_MSGPACK_RAW_VALUE_TYPE 20 -#define FLB_LOG_EVENT_TIMESTAMP_VALUE_TYPE 21 -#define FLB_LOG_EVENT_LEGACY_TIMESTAMP_VALUE_TYPE 22 -#define FLB_LOG_EVENT_FORWARD_V1_TIMESTAMP_VALUE_TYPE 23 -#define FLB_LOG_EVENT_FLUENT_BIT_V1_TIMESTAMP_VALUE_TYPE 24 -#define FLB_LOG_EVENT_FLUENT_BIT_V2_TIMESTAMP_VALUE_TYPE 25 +#define flb_log_event_type_t int32_t + +#define FLB_LOG_EVENT_APPEND_TERMINATOR_VALUE_TYPE (flb_log_event_type_t)0 + +#define FLB_LOG_EVENT_STRING_LENGTH_VALUE_TYPE (flb_log_event_type_t)1 +#define FLB_LOG_EVENT_STRING_BODY_VALUE_TYPE (flb_log_event_type_t)2 +#define FLB_LOG_EVENT_BINARY_LENGTH_VALUE_TYPE (flb_log_event_type_t)3 +#define FLB_LOG_EVENT_BINARY_BODY_VALUE_TYPE (flb_log_event_type_t)4 +#define FLB_LOG_EVENT_EXT_LENGTH_VALUE_TYPE (flb_log_event_type_t)5 +#define FLB_LOG_EVENT_EXT_BODY_VALUE_TYPE (flb_log_event_type_t)6 +#define FLB_LOG_EVENT_NULL_VALUE_TYPE (flb_log_event_type_t)7 +#define FLB_LOG_EVENT_CHAR_VALUE_TYPE (flb_log_event_type_t)8 +#define FLB_LOG_EVENT_INT8_VALUE_TYPE (flb_log_event_type_t)9 +#define FLB_LOG_EVENT_INT16_VALUE_TYPE (flb_log_event_type_t)10 +#define FLB_LOG_EVENT_INT32_VALUE_TYPE (flb_log_event_type_t)11 +#define FLB_LOG_EVENT_INT64_VALUE_TYPE (flb_log_event_type_t)12 +#define FLB_LOG_EVENT_UINT8_VALUE_TYPE (flb_log_event_type_t)13 +#define FLB_LOG_EVENT_UINT16_VALUE_TYPE (flb_log_event_type_t)14 +#define FLB_LOG_EVENT_UINT32_VALUE_TYPE (flb_log_event_type_t)15 +#define FLB_LOG_EVENT_UINT64_VALUE_TYPE (flb_log_event_type_t)16 +#define FLB_LOG_EVENT_DOUBLE_VALUE_TYPE (flb_log_event_type_t)17 +#define FLB_LOG_EVENT_BOOLEAN_VALUE_TYPE (flb_log_event_type_t)18 +#define FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE_TYPE (flb_log_event_type_t)19 +#define FLB_LOG_EVENT_MSGPACK_RAW_VALUE_TYPE (flb_log_event_type_t)20 +#define FLB_LOG_EVENT_TIMESTAMP_VALUE_TYPE (flb_log_event_type_t)21 +#define FLB_LOG_EVENT_LEGACY_TIMESTAMP_VALUE_TYPE (flb_log_event_type_t)22 +#define FLB_LOG_EVENT_FORWARD_V1_TIMESTAMP_VALUE_TYPE (flb_log_event_type_t)23 +#define FLB_LOG_EVENT_FLUENT_BIT_V1_TIMESTAMP_VALUE_TYPE (flb_log_event_type_t)24 +#define FLB_LOG_EVENT_FLUENT_BIT_V2_TIMESTAMP_VALUE_TYPE (flb_log_event_type_t)25 #define FLB_LOG_EVENT_STRING_MIN_VALUE_TYPE FLB_LOG_EVENT_STRING_LENGTH_VALUE_TYPE #define FLB_LOG_EVENT_STRING_MAX_VALUE_TYPE FLB_LOG_EVENT_FLUENT_BIT_V2_TIMESTAMP_VALUE_TYPE @@ -75,7 +77,7 @@ #define FLB_LOG_EVENT_APPEND_UNTIL_TERMINATOR -1 -#define flb_log_event_type_t int32_t + #define FLB_LOG_EVENT_VALUE_LIST_TERMINATOR() \ (flb_log_event_type_t) FLB_LOG_EVENT_APPEND_TERMINATOR_VALUE_TYPE diff --git a/src/flb_log_event_encoder_primitives.c b/src/flb_log_event_encoder_primitives.c index 804316d1871..276b3fda3de 100644 --- a/src/flb_log_event_encoder_primitives.c +++ b/src/flb_log_event_encoder_primitives.c @@ -36,7 +36,7 @@ int flb_log_event_encoder_append_value( struct flb_log_event_encoder *context, int target_field, int increment_entry_count, - int value_type, + flb_log_event_type_t value_type, char *value_buffer, size_t value_length) { @@ -450,7 +450,7 @@ int flb_log_event_encoder_append_msgpack_object( int target_field, msgpack_object *value) { - const int value_type = FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE_TYPE; + const flb_log_event_type_t value_type = FLB_LOG_EVENT_MSGPACK_OBJECT_VALUE_TYPE; return flb_log_event_encoder_append_value(context, target_field, FLB_TRUE, value_type, @@ -463,7 +463,7 @@ int flb_log_event_encoder_append_raw_msgpack( char *value_buffer, size_t value_size) { - const int value_type = FLB_LOG_EVENT_MSGPACK_RAW_VALUE_TYPE; + const flb_log_event_type_t value_type = FLB_LOG_EVENT_MSGPACK_RAW_VALUE_TYPE; return flb_log_event_encoder_append_value(context, target_field, FLB_TRUE, value_type, @@ -502,7 +502,7 @@ int flb_log_event_encoder_append_legacy_timestamp( int target_field, struct flb_time *value) { - const int value_type = FLB_LOG_EVENT_UINT64_VALUE_TYPE; + const flb_log_event_type_t value_type = FLB_LOG_EVENT_UINT64_VALUE_TYPE; uint64_t timestamp; timestamp = value->tm.tv_sec;