mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Rename web_log to log_buffer
This commit is contained in:
parent
93c7f7bb36
commit
2eb4eef08c
@ -1928,7 +1928,7 @@ void SyslogAsync(void) {
|
||||
static uint32_t counter = 1;
|
||||
|
||||
if (!TasmotaGlobal.syslog_level ||
|
||||
(counter == TasmotaGlobal.web_log_index) ||
|
||||
(counter == TasmotaGlobal.log_buffer_pointer) ||
|
||||
TasmotaGlobal.global_state.network_down) { return; }
|
||||
|
||||
do {
|
||||
@ -1944,7 +1944,7 @@ void SyslogAsync(void) {
|
||||
counter++;
|
||||
counter &= 0xFF;
|
||||
if (!counter) { counter++; } // Skip 0 as it is not allowed
|
||||
} while (counter != TasmotaGlobal.web_log_index);
|
||||
} while (counter != TasmotaGlobal.log_buffer_pointer);
|
||||
}
|
||||
|
||||
uint32_t GetLog(uint32_t idx, char** entry_pp, size_t* len_p) {
|
||||
@ -1952,7 +1952,7 @@ uint32_t GetLog(uint32_t idx, char** entry_pp, size_t* len_p) {
|
||||
size_t len = 0;
|
||||
uint32_t loglevel = 0;
|
||||
if (idx) {
|
||||
char* it = TasmotaGlobal.web_log;
|
||||
char* it = TasmotaGlobal.log_buffer;
|
||||
do {
|
||||
uint32_t cur_idx = *it;
|
||||
it++;
|
||||
@ -1966,7 +1966,7 @@ uint32_t GetLog(uint32_t idx, char** entry_pp, size_t* len_p) {
|
||||
break;
|
||||
}
|
||||
it += tmp;
|
||||
} while (it < TasmotaGlobal.web_log + WEB_LOG_SIZE && *it != '\0');
|
||||
} while (it < TasmotaGlobal.log_buffer + LOG_BUFFER_SIZE && *it != '\0');
|
||||
}
|
||||
*entry_pp = entry_p;
|
||||
*len_p = len;
|
||||
@ -1992,24 +1992,24 @@ void AddLog(uint32_t loglevel) {
|
||||
(TasmotaGlobal.masterlog_level <= highest_loglevel)) {
|
||||
// Delimited, zero-terminated buffer of log lines.
|
||||
// Each entry has this format: [index][loglevel][log data]['\1']
|
||||
TasmotaGlobal.web_log_index &= 0xFF;
|
||||
if (!TasmotaGlobal.web_log_index) {
|
||||
TasmotaGlobal.web_log_index++; // Index 0 is not allowed as it is the end of char string
|
||||
TasmotaGlobal.log_buffer_pointer &= 0xFF;
|
||||
if (!TasmotaGlobal.log_buffer_pointer) {
|
||||
TasmotaGlobal.log_buffer_pointer++; // Index 0 is not allowed as it is the end of char string
|
||||
}
|
||||
while (TasmotaGlobal.web_log_index == TasmotaGlobal.web_log[0] || // If log already holds the next index, remove it
|
||||
strlen(TasmotaGlobal.web_log) + strlen(TasmotaGlobal.log_data) + strlen(mxtime) + 4 > WEB_LOG_SIZE) // 4 = web_log_index + '\1' + '\0'
|
||||
while (TasmotaGlobal.log_buffer_pointer == TasmotaGlobal.log_buffer[0] || // If log already holds the next index, remove it
|
||||
strlen(TasmotaGlobal.log_buffer) + strlen(TasmotaGlobal.log_data) + strlen(mxtime) + 4 > LOG_BUFFER_SIZE) // 4 = log_buffer_pointer + '\1' + '\0'
|
||||
{
|
||||
char* it = TasmotaGlobal.web_log;
|
||||
it++; // Skip web_log_index
|
||||
char* it = TasmotaGlobal.log_buffer;
|
||||
it++; // Skip log_buffer_pointer
|
||||
it += strchrspn(it, '\1'); // Skip log line
|
||||
it++; // Skip delimiting "\1"
|
||||
memmove(TasmotaGlobal.web_log, it, WEB_LOG_SIZE -(it-TasmotaGlobal.web_log)); // Move buffer forward to remove oldest log line
|
||||
memmove(TasmotaGlobal.log_buffer, it, LOG_BUFFER_SIZE -(it-TasmotaGlobal.log_buffer)); // Move buffer forward to remove oldest log line
|
||||
}
|
||||
snprintf_P(TasmotaGlobal.web_log, sizeof(TasmotaGlobal.web_log), PSTR("%s%c%c%s%s\1"),
|
||||
TasmotaGlobal.web_log, TasmotaGlobal.web_log_index++, '0'+loglevel, mxtime, TasmotaGlobal.log_data);
|
||||
TasmotaGlobal.web_log_index &= 0xFF;
|
||||
if (!TasmotaGlobal.web_log_index) {
|
||||
TasmotaGlobal.web_log_index++; // Index 0 is not allowed as it is the end of char string
|
||||
snprintf_P(TasmotaGlobal.log_buffer, sizeof(TasmotaGlobal.log_buffer), PSTR("%s%c%c%s%s\1"),
|
||||
TasmotaGlobal.log_buffer, TasmotaGlobal.log_buffer_pointer++, '0'+loglevel, mxtime, TasmotaGlobal.log_data);
|
||||
TasmotaGlobal.log_buffer_pointer &= 0xFF;
|
||||
if (!TasmotaGlobal.log_buffer_pointer) {
|
||||
TasmotaGlobal.log_buffer_pointer++; // Index 0 is not allowed as it is the end of char string
|
||||
}
|
||||
}
|
||||
TasmotaGlobal.prepped_loglevel = 0;
|
||||
|
@ -86,7 +86,7 @@ struct {
|
||||
uint32_t blink_timer; // Power cycle timer
|
||||
uint32_t backlog_timer; // Timer for next command in backlog
|
||||
uint32_t loop_load_avg; // Indicative loop load average
|
||||
uint32_t web_log_index; // Index in Web log buffer
|
||||
uint32_t log_buffer_pointer; // Index in log buffer
|
||||
uint32_t uptime; // Counting every second until 4294967295 = 130 year
|
||||
|
||||
power_t power; // Current copy of Settings.power
|
||||
@ -169,7 +169,7 @@ struct {
|
||||
char mqtt_topic[TOPSZ]; // Composed MQTT topic
|
||||
char mqtt_data[MESSZ]; // MQTT publish buffer and web page ajax buffer
|
||||
char log_data[LOGSZ]; // Logging
|
||||
char web_log[WEB_LOG_SIZE]; // Web log buffer
|
||||
char log_buffer[LOG_BUFFER_SIZE]; // Web log buffer
|
||||
} TasmotaGlobal;
|
||||
|
||||
#ifdef SUPPORT_IF_STATEMENT
|
||||
|
@ -209,11 +209,7 @@ String EthernetMacAddress(void);
|
||||
#define WS2812_LEDS 30 // [Pixels] Number of LEDs
|
||||
#endif
|
||||
|
||||
//#ifdef USE_MQTT_TLS // Set to 4000 on 20200922 per #9305
|
||||
// const uint16_t WEB_LOG_SIZE = 2000; // Max number of characters in weblog
|
||||
//#else
|
||||
const uint16_t WEB_LOG_SIZE = 4000; // Max number of characters in weblog
|
||||
//#endif
|
||||
const uint16_t LOG_BUFFER_SIZE = 4000; // Max number of characters in logbuffer used by weblog, syslog and mqttlog
|
||||
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
||||
#error "Arduino ESP8266 Core versions before 2.7.1 are not supported"
|
||||
|
@ -3017,11 +3017,11 @@ void HandleHttpCommand(void)
|
||||
}
|
||||
|
||||
WSContentBegin(200, CT_JSON);
|
||||
uint32_t curridx = TasmotaGlobal.web_log_index;
|
||||
uint32_t curridx = TasmotaGlobal.log_buffer_pointer;
|
||||
String svalue = Webserver->arg("cmnd");
|
||||
if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) {
|
||||
ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCOMMAND);
|
||||
if (TasmotaGlobal.web_log_index != curridx) {
|
||||
if (TasmotaGlobal.log_buffer_pointer != curridx) {
|
||||
uint32_t counter = curridx;
|
||||
WSContentSend_P(PSTR("{"));
|
||||
bool cflg = false;
|
||||
@ -3046,7 +3046,7 @@ void HandleHttpCommand(void)
|
||||
counter++;
|
||||
counter &= 0xFF;
|
||||
if (!counter) counter++; // Skip 0 as it is not allowed
|
||||
} while (counter != TasmotaGlobal.web_log_index);
|
||||
} while (counter != TasmotaGlobal.log_buffer_pointer);
|
||||
WSContentSend_P(PSTR("}"));
|
||||
} else {
|
||||
WSContentSend_P(PSTR("{\"" D_RSLT_WARNING "\":\"" D_ENABLE_WEBLOG_FOR_RESPONSE "\"}"));
|
||||
@ -3094,14 +3094,14 @@ void HandleConsoleRefresh(void)
|
||||
if (strlen(stmp)) { counter = atoi(stmp); }
|
||||
|
||||
WSContentBegin(200, CT_PLAIN);
|
||||
WSContentSend_P(PSTR("%d}1%d}1"), TasmotaGlobal.web_log_index, Web.reset_web_log_flag);
|
||||
WSContentSend_P(PSTR("%d}1%d}1"), TasmotaGlobal.log_buffer_pointer, Web.reset_web_log_flag);
|
||||
if (!Web.reset_web_log_flag) {
|
||||
counter = 0;
|
||||
Web.reset_web_log_flag = true;
|
||||
}
|
||||
if (counter != TasmotaGlobal.web_log_index) {
|
||||
if (counter != TasmotaGlobal.log_buffer_pointer) {
|
||||
if (!counter) {
|
||||
counter = TasmotaGlobal.web_log_index;
|
||||
counter = TasmotaGlobal.log_buffer_pointer;
|
||||
cflg = false;
|
||||
}
|
||||
do {
|
||||
@ -3120,7 +3120,7 @@ void HandleConsoleRefresh(void)
|
||||
counter++;
|
||||
counter &= 0xFF;
|
||||
if (!counter) { counter++; } // Skip log index 0 as it is not allowed
|
||||
} while (counter != TasmotaGlobal.web_log_index);
|
||||
} while (counter != TasmotaGlobal.log_buffer_pointer);
|
||||
}
|
||||
WSContentSend_P(PSTR("}1"));
|
||||
WSContentEnd();
|
||||
|
@ -296,7 +296,7 @@ void MqttPublishLoggingAsync(void) {
|
||||
|
||||
if (!Settings.flag.mqtt_enabled || // SetOption3 - Enable MQTT
|
||||
!Settings.mqttlog_level ||
|
||||
(counter == TasmotaGlobal.web_log_index) ||
|
||||
(counter == TasmotaGlobal.log_buffer_pointer) ||
|
||||
TasmotaGlobal.global_state.mqtt_down) { return; }
|
||||
|
||||
do {
|
||||
@ -314,7 +314,7 @@ void MqttPublishLoggingAsync(void) {
|
||||
counter++;
|
||||
counter &= 0xFF;
|
||||
if (!counter) { counter++; } // Skip 0 as it is not allowed
|
||||
} while (counter != TasmotaGlobal.web_log_index);
|
||||
} while (counter != TasmotaGlobal.log_buffer_pointer);
|
||||
}
|
||||
|
||||
void MqttPublish(const char* topic, bool retained)
|
||||
|
@ -289,9 +289,9 @@ void TelegramSendGetMe(void) {
|
||||
String TelegramExecuteCommand(const char *svalue) {
|
||||
String response = "";
|
||||
|
||||
uint32_t curridx = TasmotaGlobal.web_log_index;
|
||||
uint32_t curridx = TasmotaGlobal.log_buffer_pointer;
|
||||
ExecuteCommand(svalue, SRC_CHAT);
|
||||
if (TasmotaGlobal.web_log_index != curridx) {
|
||||
if (TasmotaGlobal.log_buffer_pointer != curridx) {
|
||||
uint32_t counter = curridx;
|
||||
response = F("{");
|
||||
bool cflg = false;
|
||||
@ -317,7 +317,7 @@ String TelegramExecuteCommand(const char *svalue) {
|
||||
counter++;
|
||||
counter &= 0xFF;
|
||||
if (!counter) counter++; // Skip 0 as it is not allowed
|
||||
} while (counter != TasmotaGlobal.web_log_index);
|
||||
} while (counter != TasmotaGlobal.log_buffer_pointer);
|
||||
response += F("}");
|
||||
} else {
|
||||
response = F("{\"" D_RSLT_WARNING "\":\"" D_ENABLE_WEBLOG_FOR_RESPONSE "\"}");
|
||||
|
Loading…
x
Reference in New Issue
Block a user