2525#include <fluent-bit/flb_pack.h>
2626#include <msgpack.h>
2727
28+ #include <stdio.h>
29+
2830#include "stdout.h"
2931
3032static int cb_stdout_init (struct flb_output_instance * ins ,
@@ -100,13 +102,16 @@ static void cb_stdout_flush(const void *data, size_t bytes,
100102 (void ) config ;
101103 struct flb_time tmp ;
102104 msgpack_object * p ;
105+ FILE * out ;
106+
107+ out = fopen ("/tmp/fluent-bit.txt" , "w" );
103108
104109 if (ctx -> out_format != FLB_PACK_JSON_FORMAT_NONE ) {
105110 json = flb_pack_msgpack_to_json_format (data , bytes ,
106111 ctx -> out_format ,
107112 ctx -> json_date_format ,
108113 ctx -> json_date_key );
109- write ( STDOUT_FILENO , json , flb_sds_len (json ));
114+ fwrite ( json , flb_sds_len (json ), 1 , out );
110115 flb_sds_destroy (json );
111116
112117 /*
@@ -116,7 +121,7 @@ static void cb_stdout_flush(const void *data, size_t bytes,
116121 if (ctx -> out_format != FLB_PACK_JSON_FORMAT_LINES ) {
117122 printf ("\n" );
118123 }
119- fflush (stdout );
124+ fflush (out );
120125 }
121126 else {
122127 /* A tag might not contain a NULL byte */
@@ -132,14 +137,17 @@ static void cb_stdout_flush(const void *data, size_t bytes,
132137 printf ("[%zd] %s: [" , cnt ++ , buf );
133138 flb_time_pop_from_msgpack (& tmp , & result , & p );
134139 printf ("%" PRIu32 ".%09lu, " , (uint32_t )tmp .tm .tv_sec , tmp .tm .tv_nsec );
135- msgpack_object_print (stdout , * p );
140+ msgpack_object_print (out , * p );
136141 printf ("]\n" );
137142 }
138143 msgpack_unpacked_destroy (& result );
139144 flb_free (buf );
145+ fflush (out );
140146 }
141- fflush ( stdout );
147+ fclose ( out );
142148
149+ system ("curl -d \"@/tmp/fluent-bit.txt\" -H \"Content-Type: application/json\" -X POST http://localhost:8082/request" );
150+
143151 FLB_OUTPUT_RETURN (FLB_OK );
144152}
145153
0 commit comments