Usage

#include <uuid/syslog.h>

Create a uuid::syslog::SyslogService and call start(). Then set the destination host, log level and optional local hostname.

The default log level is uuid::log::Level::ALL so it can capture messages logged during startup before any configuration is read.

Call loop() regularly and when WiFi connectivity is available the queued messages will be sent.

On ESP8266 and ESP32 platforms an ARP query will be made every second until a route to the destination host is available, before sending messages at a rate of 100 per second. On other platforms messages will be sent at a rate of 10 per second to allow time for ARP lookups to complete and avoid dropping messages.

Whenever possible, the current system time is included in the outgoing syslog message.

Example

#include <Arduino.h>
#ifdef ARDUINO_ARCH_ESP8266
# include <ESP8266WiFi.h>
#else
# include <WiFi.h>
#endif
#include <uuid/common.h>
#include <uuid/log.h>
#include <uuid/syslog.h>

static uuid::syslog::SyslogService syslog;

void setup() {
	static uuid::log::Logger logger{F("setup")};

	syslog.start();
	/* Retrieve settings after calling start()
	 * in case the settings read process logs
	 * some messages.
	 */
	syslog.hostname("example");
	syslog.log_level(uuid::log::DEBUG);
	syslog.mark_interval(3600);
	syslog.destination(IPAddress(192, 0, 2, 1));

	WiFi.persistent(false);
	WiFi.mode(WIFI_STA);
	WiFi.begin("SSID", "password");

	Serial.begin(115200);

	logger.info(F("Application started"));
}

void loop() {
	static uuid::log::Logger logger{F("loop")};
	static unsigned int i = 0;

	uuid::loop();
	syslog.loop();

	logger.debug(F("Hello %u World!"), i++);

	delay(1000);
}