Yuuichi Akagawa / peach_fluentlogger

Dependencies:   EthernetInterface FluentLogger

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* FluentLogger - fluent-logger-mbed sample
00002  * Copyright (c) 2014 Yuuichi Akagawa
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "mbed.h"
00018 #include "EthernetInterface.h"
00019 #include "FluentLogger.h"
00020 
00021 EthernetInterface eth;
00022 FluentLogger logger("192.168.0.1");  // please set your Fluentd server
00023 Serial pc(USBTX, USBRX);
00024 
00025 int main() 
00026 {
00027     uMP mp(64); //Message body
00028     eth.init(); //Use DHCP
00029     eth.connect();
00030     while(1) {
00031        uint32_t t1 = us_ticker_read();
00032        logger.log("debug.test", "Hello GR-PEACH"); //message body is simple string
00033        uint32_t t2 = us_ticker_read();
00034         wait_ms(5000);
00035 //       Thread::wait(5000);
00036        uint32_t t3 = us_ticker_read();
00037        pc.printf("t1:%u t2:%u t3:%u t2-t1:%u t3-t2:%u\r\n", t1, t2, t3, (t2-t1), (t3-t2));
00038     }
00039     logger.close();
00040     eth.disconnect();  
00041 }