diff --git a/Kconfig b/Kconfig index cc24439..9720539 100644 --- a/Kconfig +++ b/Kconfig @@ -916,8 +916,6 @@ menu "WebGUIApp" endif endmenu - - menu "MQTT settings" config WEBGUIAPP_MQTT_ENABLE bool "Enabled MQTT transport" @@ -981,6 +979,18 @@ menu "WebGUIApp" endif endmenu + menu "System log" + config WEBGUIAPP_SYSLOG_MAX_CHUNKS + int "Number of syslog parts" + range 1 10 + default 4 + + config WEBGUIAPP_SYSLOG_CHUNK_SIZE + int "Size of one part in kilobytes" + range 1 256 + default 50 + endmenu + if WEBGUIAPP_WIFI_ENABLE || WEBGUIAPP_ETHERNET_ENABLE || WEBGUIAPP_GPRS_ENABLE menu "DNS settings" diff --git a/src/SysConfiguration.c b/src/SysConfiguration.c index 1688809..b2dee49 100644 --- a/src/SysConfiguration.c +++ b/src/SysConfiguration.c @@ -592,14 +592,15 @@ void SetUserAppNeedReset(bool res) isUserAppNeedReset = res; } -#define LOG_MAX_CHUNK_SIZE 10 -#define LOG_MAX_CHUNKS 4 +#define LOG_MAX_CHUNK_SIZE CONFIG_WEBGUIAPP_SYSLOG_CHUNK_SIZE +#define LOG_MAX_CHUNKS CONFIG_WEBGUIAPP_SYSLOG_MAX_CHUNKS #define DEFAULT_LOG_FILE_NAME "syslog" +#define LOG_PARTITION "/data/" static void ComposeLogFilename(int chunk, char *filename) { char chunkstr[2]; - strcpy(filename, "/data/"); + strcpy(filename, LOG_PARTITION); strcat(filename, DEFAULT_LOG_FILE_NAME); itoa(chunk, chunkstr, 10); strcat(filename, chunkstr); @@ -618,19 +619,18 @@ void SysLog(char *format, ...) //If first call after reboot, try to find not full chunk if (isstart) { - while (file_stat.st_size > LOG_MAX_CHUNK_SIZE * 1024 && cur_chunk <= LOG_MAX_CHUNKS) + while (file_stat.st_size > LOG_MAX_CHUNK_SIZE * 1024 && cur_chunk <= LOG_MAX_CHUNKS - 1) { cur_chunk++; ComposeLogFilename(cur_chunk, filename); } isstart = 0; } - - stat(filename, &file_stat); + //next if full, else append to current if (file_stat.st_size > LOG_MAX_CHUNK_SIZE * 1024) { - if (++cur_chunk > LOG_MAX_CHUNKS) + if (++cur_chunk > LOG_MAX_CHUNKS - 1) cur_chunk = 0; ComposeLogFilename(cur_chunk, filename); f = fopen(filename, "w");