tuning logs, max queue size, preallocate strings, all working
This commit is contained in:
parent
9c6b39fd50
commit
8f32fb0c94
@ -1,22 +1,20 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <queue>
|
#include <list>
|
||||||
|
|
||||||
class WsSerial{
|
class WsSerial{
|
||||||
std::queue<String> debug;
|
std::list<String> debug;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline void print(const String& line){
|
inline void print(const String& line){ println(line); }
|
||||||
// enable debug the debugging Serial.println(line.c_str());
|
|
||||||
debug.push(line);
|
|
||||||
}
|
|
||||||
inline void println(const String& line){
|
inline void println(const String& line){
|
||||||
// enable debug the debugging Serial.println(line.c_str());
|
// enable debug the debugging Serial.println(line.c_str());
|
||||||
debug.push(line);
|
if(debug.size() > 100 ) debug.pop_back();
|
||||||
|
debug.push_front(line);
|
||||||
}
|
}
|
||||||
inline void println(const float num){ println(String(num)) ; };
|
inline void println(const float num){ println(String(num)) ; };
|
||||||
|
|
||||||
inline const String& first(){ return debug.front();};
|
inline const String& first(){ return debug.front();};
|
||||||
inline void pop(){ debug.pop(); };
|
inline void pop(){ return debug.pop_front();};
|
||||||
inline bool empty(){ return debug.empty();};
|
inline bool empty(){ return debug.empty();};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ void server_setup(){
|
|||||||
DEBUG_OUT.println("log start");
|
DEBUG_OUT.println("log start");
|
||||||
AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
|
AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
|
||||||
if(debug_out.empty()) return 0;
|
if(debug_out.empty()) return 0;
|
||||||
String to_send = String(maxLen);
|
String to_send = String();
|
||||||
|
to_send.reserve(maxLen);
|
||||||
while(!debug_out.empty()){
|
while(!debug_out.empty()){
|
||||||
String add_next = debug_out.first();
|
String add_next = debug_out.first();
|
||||||
if( (add_next.length() + 5 + to_send.length() ) > maxLen ) break ; // dont overflow buffer
|
if( (add_next.length() + 5 + to_send.length() ) > maxLen ) break ; // dont overflow buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user