diff --git a/examples/hello_world_cpp/hello_world.cc b/examples/hello_world_cpp/hello_world.cc index 1b5ed3003ac..5fdc89aa90e 100644 --- a/examples/hello_world_cpp/hello_world.cc +++ b/examples/hello_world_cpp/hello_world.cc @@ -26,32 +26,35 @@ int main() int n; int ret; char tmp[256]; - struct flb_lib_ctx *ctx; + flb_ctx_t *ctx; + flb_input_t *input; + flb_output_t *output; /* Initialize library */ - ctx = flb_lib_init(NULL, (char *) "stdout", NULL); - if (!ctx) { - exit(EXIT_FAILURE); - } + ctx = flb_create(); + + input = flb_input(ctx, "lib", NULL); + flb_input_set(input, "test"); - /* Verbose mode */ - /* - flb_config_verbose(FLB_TRUE); - */ + output = flb_output(ctx, "stdout", NULL); + flb_output_set(output, "test"); /* Start the background worker */ - flb_lib_start(ctx); + flb_start(ctx); /* Push some data */ for (i = 0; i < 100; i++) { - n = snprintf(tmp, sizeof(tmp) - 1, "{\"key\": \"val %i\"}", i); - flb_lib_push(ctx, tmp, n); + n = snprintf(tmp, sizeof(tmp) - 1, + "[%lu, {\"key\": \"val %i\"}]", + time(NULL), i); + printf("%s\n", tmp); + flb_lib_push(input, tmp, n); } - flb_lib_stop(ctx); + flb_stop(ctx); /* Release Resources */ - flb_lib_exit(ctx); + flb_destroy(ctx); return 0; }