logger library - syslog device (client)

logger library - syslog device (client)

UNIX syslogd to send messages over the ethernet.

Port 514 UDP, size of message 256 bytes

Download

Import librarylogger

syslog device(client) library http://mbed.org/users/okini3939/notebook/logger/

Sample

Import programsyslog_test

http://mbed.org/users/okini3939/notebook/logger/

#include "mbed.h"
#include "EthernetNetIf.h"
#include "logger.h"

DigitalOut myled(LED1);
EthernetNetIf eth;
logger *syslog;

int main() {
    EthernetErr r;
    int i;
    char buf[100];

    r = eth.setup();
    if (r) {
        printf("Error %d in setup.\n", r);
        return -1;
    }

    syslog = new logger(&eth, "192.168.1.8", "mbed");

    i = 0;
    while(1) {
        sprintf(buf, "message %d", i++);
        syslog->send("test:", buf);
        wait(5);
    }
}

syslogd (collector/server)

ex:/var/log/messages

Jan  1 01:23:45 mbed test: message 0
Jan  1 01:23:50 mbed test: message 1
Jan  1 01:23:55 mbed test: message 2
  :

戻る


Please log in to post comments.