@@ -183,9 +183,6 @@ static inline int pack_line(struct flb_syslog *ctx,
183183 }
184184
185185 if (result == FLB_EVENT_ENCODER_SUCCESS ) {
186- flb_input_log_append (ctx -> ins , NULL , 0 ,
187- ctx -> log_encoder -> output_buffer ,
188- ctx -> log_encoder -> output_length );
189186 result = 0 ;
190187 }
191188 else {
@@ -194,8 +191,6 @@ static inline int pack_line(struct flb_syslog *ctx,
194191 result = -1 ;
195192 }
196193
197- flb_log_event_encoder_reset (ctx -> log_encoder );
198-
199194 if (modified_data_buffer != NULL ) {
200195 flb_free (modified_data_buffer );
201196 }
@@ -221,6 +216,8 @@ int syslog_prot_process(struct syslog_conn *conn)
221216 eof = conn -> buf_data ;
222217 end = conn -> buf_data + conn -> buf_len ;
223218
219+ flb_log_event_encoder_reset (ctx -> log_encoder );
220+
224221 /* Always parse while some remaining bytes exists */
225222 while (eof < end ) {
226223 /* Lookup the ending byte */
@@ -281,6 +278,12 @@ int syslog_prot_process(struct syslog_conn *conn)
281278 conn -> buf_data [conn -> buf_len ] = '\0' ;
282279 }
283280
281+ if (ctx -> log_encoder -> output_length > 0 ) {
282+ flb_input_log_append (ctx -> ins , NULL , 0 ,
283+ ctx -> log_encoder -> output_buffer ,
284+ ctx -> log_encoder -> output_length );
285+ }
286+
284287 return 0 ;
285288}
286289
@@ -300,6 +303,8 @@ int syslog_prot_process_udp(struct syslog_conn *conn)
300303 ctx = conn -> ctx ;
301304 connection = conn -> connection ;
302305
306+ flb_log_event_encoder_reset (ctx -> log_encoder );
307+
303308 ret = flb_parser_do (ctx -> parser , buf , size ,
304309 & out_buf , & out_size , & out_time );
305310 if (ret >= 0 ) {
@@ -320,5 +325,11 @@ int syslog_prot_process_udp(struct syslog_conn *conn)
320325 return -1 ;
321326 }
322327
328+ if (ctx -> log_encoder -> output_length > 0 ) {
329+ flb_input_log_append (ctx -> ins , NULL , 0 ,
330+ ctx -> log_encoder -> output_buffer ,
331+ ctx -> log_encoder -> output_length );
332+ }
333+
323334 return 0 ;
324335}
0 commit comments