TOC
自作したnginx-moduleから直接fluentdへログを出したかったので、C言語のlibで簡単にfluentdのデータを投げられるライブラリを作成しました。
まあ、socketで接続してデータ送信しているだけですが!
データのjson化 or msgpack化は自力でお願いします。json化とかはjson-c使えば簡単にできるですよ。
サンプルはこんな感じ↓
#include
#include "fluentlogger.h"
int main()
{
fluent_context_t *c = fluent_connect("127.0.0.1", 24225);
if(c == NULL)
{
printf("connect error\n");
return(1);
}
if(fluent_post_json(c, "debug.test", "{\"Hello\":\"MessagePack\"}") != 0)
{
fluent_free(c);
printf("post error\n");
return(1);
}
fluent_free(c);
return(0);
}