Describe the bug, issue or concern
When following the LoggingGalore example, it turns out that somewhere along the line the TLog "child" objects are duplicated.
I'm not clear as to why, but after adding a Serial.println("write() called on SyslogStream(%p)\n", this) it became quite clear that there ends up being multiple SyslogStream instances (the pointer values for %p differs).
The motivation was because some aspects I only wanted to log to syslog, not to Serial too, and I wanted to be able to switch on/off independent sub-loggers by invoking their begin() and stop() methods independently as configuration settings are updated, and/or network becomes available etc ...
Relevant code example:
#define SYSLOG_SERVER "your.servername.here"
#define SYSLOG_PORT 514
#define WIFI_SSID "your_ssid_here"
#define WIFI_PSK "and your PSK"
#include <WiFi.h>
#include <TLog.h>
#include <SyslogStream.h>
SyslogStream syslogger;
void setup()
{
Serial.begin(115200);
syslogger.setDestination(SYSLOG_SERVER);
syslogger.setPort(SYSLOG_PORT);
syslogger.setRaw(true);
syslogger.setIdentifier(HOSTNAME);
const std::shared_ptr<LOGBase> syslogStreamPtr = std::make_shared<SyslogStream>(syslogger);
Log.addPrintStream(syslogStreamPtr);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
WiFi.setHostname(HOSTNAME);
delay(100);
WiFi.begin(WIFI_SSID, WIFI_PSK);
}
static unsigned long last = 0
loop()
{
if (WiFi.status() == WL_CONNECTED) {
syslogger.begin(); // doesn't work - but if syslogger.println("this will");
Log.begin(); // works
} else {
syslogger.stop(); // doesn't work.
Log.stop(); // works
}
Log.loop();
if (millis() - last >= 5000) {
last = millis();
Log.println("This line will repeat every 5 seconds");
}
}
Describe the bug, issue or concern
When following the LoggingGalore example, it turns out that somewhere along the line the TLog "child" objects are duplicated.
I'm not clear as to why, but after adding a Serial.println("write() called on SyslogStream(%p)\n", this) it became quite clear that there ends up being multiple SyslogStream instances (the pointer values for %p differs).
The motivation was because some aspects I only wanted to log to syslog, not to Serial too, and I wanted to be able to switch on/off independent sub-loggers by invoking their begin() and stop() methods independently as configuration settings are updated, and/or network becomes available etc ...
Relevant code example: