Skip to content

Commit

Permalink
Fix for #210
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Feb 20, 2024
1 parent cc742ea commit f9932ef
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
4 changes: 2 additions & 2 deletions data_source/settings.htm
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ <h4>Calibrate Flowmeters</h4>

<div class="col-3">
<div class="row form-group">
<select class="form-control" name="flowmeter" id="flowmeter">
<select class="form-control form-select" name="flowmeter" id="flowmeter">
<option value="0">1</option>
<option value="1">2</option>
<option value="2">3</option>
Expand Down Expand Up @@ -2697,7 +2697,7 @@ <h4>Debug Configuration</h4>
</label>
</div>
<div class="col-sm-4">
<select class="form-select" id="loglevel" name="loglevel" data-form-type="other">
<select class="form-select form-control" id="loglevel" name="loglevel" data-form-type="other">
<option>0 - Silent, no output</option>
<option>1 - Fatal errors </option>
<option>2 - All errors </option>
Expand Down
4 changes: 2 additions & 2 deletions data_source/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"fw_version": "1.3.0",
"fs_version": "1.3.0"
"fw_version": "1.3.1-Beta.1",
"fs_version": "1.3.1-Beta.1"
}
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ lib_deps =
lbussy/LCBUrl @ ~1.1.9
bblanchon/ArduinoJson @ ~6.21.2
https://github.com/lbussy/DS18B20_RT @ ~0.1.4
https://github.com/lbussy/Arduino-Log @ ~1.0.3
https://github.com/lbussy/Arduino-Log @ 1.1.1+sha.31d7620
https://github.com/lbussy/AsyncWiFiManager.git
https://github.com/lbussy/AsyncTCP#smarthomerocks
https://github.com/lbussy/ESPAsyncWebServer @ ~1.2.3
Expand Down
30 changes: 25 additions & 5 deletions src/serialhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ void serialBegin()
{
SERIAL.setDebugOutput(false);
Log.begin(LOG_LEVEL_SILENT, &SERIAL, true);
Log.setPrefix(printTimestamp);
Log.setPrefix(printPrefix);
}
else if (!app.copconfig.serial)
{
SERIAL.setDebugOutput(true);
Log.begin(app.copconfig.loglevel, &SERIAL, true);
Log.setPrefix(printTimestamp);
Log.setPrefix(printPrefix);
Log.notice(F("Serial logging started at %l." CR), BAUD);
}
#endif
Expand All @@ -88,13 +88,13 @@ void serialStop()
{
Serial.setDebugOutput(false);
Log.begin(LOG_LEVEL_SILENT, &SERIAL, true);
Log.setPrefix(printTimestamp);
Log.setPrefix(printPrefix);
}
else if (!app.copconfig.serial)
{
Serial.setDebugOutput(true);
Log.begin(LOG_LEVEL, &SERIAL, true);
Log.setPrefix(printTimestamp);
Log.setPrefix(printPrefix);
Log.notice(F("Local serial logging started at %l." CR), BAUD);
}
#endif
Expand All @@ -107,6 +107,11 @@ void serialRestart()
serialBegin();
}

void printPrefix(Print* _logOutput, int logLevel) {
printTimestamp(_logOutput);
printLogLevel (_logOutput, logLevel);
}

void printTimestamp(Print *_logOutput)
{
time_t now;
Expand All @@ -118,6 +123,21 @@ void printTimestamp(Print *_logOutput)
_logOutput->print(locTime);
}

void printLogLevel(Print* _logOutput, int logLevel) {
/// Show log description based on log level
switch (logLevel)
{
default:
case 0:_logOutput->print("SILENT " ); break;
case 1:_logOutput->print("FATAL " ); break;
case 2:_logOutput->print("ERROR " ); break;
case 3:_logOutput->print("WARNING "); break;
case 4:_logOutput->print("INFO " ); break;
case 5:_logOutput->print("TRACE " ); break;
case 6:_logOutput->print("VERBOSE "); break;
}
}

size_t printDot()
{
return SERIAL.print(F("."));
Expand Down Expand Up @@ -524,7 +544,7 @@ void toggleSerialCompat(bool enable)
SERIAL.flush();
SERIAL.setDebugOutput(true);
Log.begin(LOG_LEVEL, &SERIAL, true);
Log.setPrefix(printTimestamp);
Log.setPrefix(printPrefix);
Log.notice(F("Serial communications (terse mode) disabled, debug print enabled." CR));
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/serialhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ void serialBegin();
void serialStop();
void serialRestart();
void toggleSerialCompat(bool);
void printPrefix(Print* _logOutput, int logLevel);
void printTimestamp(Print *_logOutput);
void printLogLevel(Print* _logOutput, int logLevel);
void serialLoop();

// Telnet Handlers
Expand Down

0 comments on commit f9932ef

Please sign in to comment.