Skip to content
Snippets Groups Projects
Verified Commit 81bd3361 authored by Zoe Michaela Dietmar Pfister's avatar Zoe Michaela Dietmar Pfister :gay_pride_flag:
Browse files

WIP: Refactor logging facility. log to file with filename related to date

parent 156fbafd
No related branches found
No related tags found
4 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!14Merge gsm host into development
...@@ -83,17 +83,20 @@ int vprintf_into_sd(const char *szFormat, va_list args) ...@@ -83,17 +83,20 @@ int vprintf_into_sd(const char *szFormat, va_list args)
// write evaluated format string into buffer // write evaluated format string into buffer
int ret = vsnprintf(log_print_buffer, sizeof(log_print_buffer), logstring.c_str(), args); int ret = vsnprintf(log_print_buffer, sizeof(log_print_buffer), logstring.c_str(), args);
String date = rtc.getDate();
String filename = "/log_" + date + ".txt";
// output is now in buffer. write to file. // output is now in buffer. write to file.
if (ret >= 0) { if (ret >= 0) {
if (!SD.exists("/log.txt")) { if (!SD.exists(filename)) {
File writeLog = SD.open("/log.txt", FILE_WRITE); File writeLog = SD.open(filename, FILE_WRITE);
if (!writeLog) if (!writeLog)
Serial.println("Couldn't open spiffs_log.txt"); Serial.println("Couldn't open " + filename + " for writing");
delay(50); delay(50);
writeLog.close(); writeLog.close();
} }
File logFile = SD.open("/log.txt", FILE_APPEND); File logFile = SD.open(filename, FILE_APPEND);
// debug output // debug output
vprintf(logstring.c_str(), args); vprintf(logstring.c_str(), args);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment