FluentLogger: fluent-logger-mbed A structured logger for Fluentd (mbed)

Dependents:   FluentLogger_Hello SNIC-FluentLogger-example

FluentLogger

Fluentd Logo

What is this ?

You can logging to Fluentd server.
This library included subset of MassagePack library.

Supported MessagePack formats(encode only)

format namefirst byte (in hex)
positive fixint0x00 - 0x7f
fixmap0x80 - 0x8f
fixarray0x90 - 0x9f
fixstr0xa0 - 0xbf
nil0xc0
false0xc2
true0xc3
float 320xca
float 640xcb
uint 80xcc
uint 160xcd
uint 320xce
uint 640xcf
int 80xd0
int 160xd1
int 320xd2
int 640xd3
str 80xd9
negative fixint0xe0 - 0xff

これは何?

Fluentd サーバにログを送信するためのライブラリです。
サブセット版のMassagePackライブラリも同梱しています。

サーバ側ダウン時の再接続機能は限定的に実装されています。 現時点での実装は送信時に切断を検知し、次回送信時に再接続する仕様です。

Revision:
1:6b1268731465
Parent:
0:b4815a079a4b
--- a/uMP.h	Tue Nov 11 02:14:44 2014 +0000
+++ b/uMP.h	Mon Dec 15 15:37:23 2014 +0000
@@ -19,6 +19,7 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <string>
 
 /** Subset of MessagePack implementation.
  *
@@ -57,7 +58,7 @@
      * @retval true Success
      * @retval false Failure
      */
-    bool set_array(uint32_t size);
+    bool start_array(uint32_t size);
 
     /** Start map format
      *
@@ -65,7 +66,7 @@
      * @retval true Success
      * @retval false Failure
      */
-    bool set_map(uint32_t size);
+    bool start_map(uint32_t size);
 
     /** Set NIL message
      *
@@ -199,6 +200,16 @@
      */
     bool set_str(const char *data, uint32_t size);
 
+    /** Set string message
+     *
+     * Auto route the optimal function.
+     *
+     * @param str string of message string
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool set_str(const std::string& str);
+
     /** Set string message (upto 31 bytes)
      *
      * @param data Pointer of message string
@@ -229,6 +240,105 @@
      */
     bool set_raw(const char *data, uint8_t size);
 
+    /** associate a key with value (bool)
+     *
+     * @param k key string
+     * @param v bool value(true/false)
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, bool v);
+
+    /** associate a key with value (uint8_t)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, uint8_t v);
+
+    /** associate a key with value (uint16_t)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, uint16_t v);
+
+    /** associate a key with value (uint32_t)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, uint32_t v);
+
+    /** associate a key with value (int8_t)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, int8_t v);
+
+    /** associate a key with value (int16_t)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, int16_t v);
+
+    /** associate a key with value (int32_t)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, int32_t v);
+
+    /** associate a key with value (float)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, float v);
+
+    /** associate a key with value (double)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, double v);
+
+    /** associate a key with value (char * string)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, const char *v);
+
+    /** associate a key with value (string)
+     *
+     * @param k key string
+     * @param v value
+     * @retval true Success
+     * @retval false Failure
+     */
+    bool map(const std::string& k, const std::string& v);
+
 private:
     enum MpTag{
         TAG_POSITIVE_FIXNUM = 0x00,