FluentLogger sample for GR-PEACH

Dependencies:   EthernetInterface FluentLogger

Committer:
YuuichiAkagawa
Date:
Tue Jan 20 15:05:33 2015 +0000
Revision:
2:f5d11b69b6f8
Parent:
1:0a8269ab9a47
fix typo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
YuuichiAkagawa 0:5edb05436aa5 1 /* FluentLogger - fluent-logger-mbed sample
YuuichiAkagawa 0:5edb05436aa5 2 * Copyright (c) 2014 Yuuichi Akagawa
YuuichiAkagawa 0:5edb05436aa5 3 *
YuuichiAkagawa 0:5edb05436aa5 4 * Licensed under the Apache License, Version 2.0 (the "License");
YuuichiAkagawa 0:5edb05436aa5 5 * you may not use this file except in compliance with the License.
YuuichiAkagawa 0:5edb05436aa5 6 * You may obtain a copy of the License at
YuuichiAkagawa 0:5edb05436aa5 7 *
YuuichiAkagawa 0:5edb05436aa5 8 * http://www.apache.org/licenses/LICENSE-2.0
YuuichiAkagawa 0:5edb05436aa5 9 *
YuuichiAkagawa 0:5edb05436aa5 10 * Unless required by applicable law or agreed to in writing, software
YuuichiAkagawa 0:5edb05436aa5 11 * distributed under the License is distributed on an "AS IS" BASIS,
YuuichiAkagawa 0:5edb05436aa5 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
YuuichiAkagawa 0:5edb05436aa5 13 * See the License for the specific language governing permissions and
YuuichiAkagawa 0:5edb05436aa5 14 * limitations under the License.
YuuichiAkagawa 0:5edb05436aa5 15 */
YuuichiAkagawa 0:5edb05436aa5 16
YuuichiAkagawa 0:5edb05436aa5 17 #include "mbed.h"
YuuichiAkagawa 0:5edb05436aa5 18 #include "EthernetInterface.h"
YuuichiAkagawa 0:5edb05436aa5 19 #include "FluentLogger.h"
YuuichiAkagawa 0:5edb05436aa5 20
YuuichiAkagawa 0:5edb05436aa5 21 EthernetInterface eth;
YuuichiAkagawa 0:5edb05436aa5 22 FluentLogger logger("192.168.0.1"); // please set your Fluentd server
YuuichiAkagawa 1:0a8269ab9a47 23 Serial pc(USBTX, USBRX);
YuuichiAkagawa 0:5edb05436aa5 24
YuuichiAkagawa 0:5edb05436aa5 25 int main()
YuuichiAkagawa 0:5edb05436aa5 26 {
YuuichiAkagawa 0:5edb05436aa5 27 uMP mp(64); //Message body
YuuichiAkagawa 0:5edb05436aa5 28 eth.init(); //Use DHCP
YuuichiAkagawa 0:5edb05436aa5 29 eth.connect();
YuuichiAkagawa 0:5edb05436aa5 30 while(1) {
YuuichiAkagawa 1:0a8269ab9a47 31 uint32_t t1 = us_ticker_read();
YuuichiAkagawa 1:0a8269ab9a47 32 logger.log("debug.test", "Hello GR-PEACH"); //message body is simple string
YuuichiAkagawa 1:0a8269ab9a47 33 uint32_t t2 = us_ticker_read();
YuuichiAkagawa 1:0a8269ab9a47 34 wait_ms(5000);
YuuichiAkagawa 2:f5d11b69b6f8 35 // Thread::wait(5000);
YuuichiAkagawa 1:0a8269ab9a47 36 uint32_t t3 = us_ticker_read();
YuuichiAkagawa 1:0a8269ab9a47 37 pc.printf("t1:%u t2:%u t3:%u t2-t1:%u t3-t2:%u\r\n", t1, t2, t3, (t2-t1), (t3-t2));
YuuichiAkagawa 0:5edb05436aa5 38 }
YuuichiAkagawa 0:5edb05436aa5 39 logger.close();
YuuichiAkagawa 0:5edb05436aa5 40 eth.disconnect();
YuuichiAkagawa 0:5edb05436aa5 41 }