Skip to content

Commit

Permalink
log_event_encoder: add explicit flb_log_event_type_t
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 committed Jul 30, 2023
1 parent 6c71b38 commit 1e760b4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
58 changes: 30 additions & 28 deletions include/fluent-bit/flb_log_event_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/flb_log_event_encoder_primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1e760b4

Please sign in to comment.