Move syslog function

This commit is contained in:
fvanroie 2020-02-01 19:02:48 +01:00
parent ec429820b4
commit cbcefad900
3 changed files with 21 additions and 11 deletions

View File

@ -70,6 +70,22 @@ void serialPrintln(String debugText)
Serial.println(debugTimeText);
}
void syslogSend(uint8_t log, const char * debugText)
{
if(WiFi.isConnected() && debugSyslogHost != "") {
switch(log) {
case 1:
syslog.log(LOG_WARNING, debugText);
break;
case2:
syslog.log(LOG_ERR, debugText);
break;
default:
syslog.log(LOG_INFO, debugText);
}
}
}
void debugStop()
{
Serial.flush();

View File

@ -7,4 +7,6 @@ void debugStop(void);
void serialPrintln(String debugText);
void syslogSend(uint8_t log, const char * debugText);
#endif

View File

@ -15,7 +15,7 @@
void debugPrintln(String debugText)
{
serialPrintln(debugText);
// if(WiFi.isConnected()) syslog.log(LOG_INFO, debugText);
syslogSend(0, debugText.c_str());
}
void errorPrintln(String debugText)
@ -23,11 +23,7 @@ void errorPrintln(String debugText)
char buffer[256];
sprintf_P(buffer, debugText.c_str(), PSTR("[ERROR] "));
serialPrintln(buffer);
if(WiFi.isConnected()) {
char buffer[256];
sprintf_P(buffer, debugText.c_str(), "");
// syslog.log(LOG_ERR, buffer);
}
syslogSend(2, buffer);
}
void warningPrintln(String debugText)
@ -35,9 +31,5 @@ void warningPrintln(String debugText)
char buffer[256];
sprintf_P(buffer, debugText.c_str(), PSTR("[WARNING] "));
serialPrintln(buffer);
if(WiFi.isConnected()) {
char buffer[256];
sprintf_P(buffer, debugText.c_str(), "");
// syslog.log(LOG_WARNING, buffer);
}
syslogSend(1, buffer);
}