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)
// write evaluated format string into buffer
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.
if (ret >= 0) {
if (!SD.exists("/log.txt")) {
File writeLog = SD.open("/log.txt", FILE_WRITE);
if (!SD.exists(filename)) {
File writeLog = SD.open(filename, FILE_WRITE);
if (!writeLog)
Serial.println("Couldn't open spiffs_log.txt");
Serial.println("Couldn't open " + filename + " for writing");
delay(50);
writeLog.close();
}
File logFile = SD.open("/log.txt", FILE_APPEND);
File logFile = SD.open(filename, FILE_APPEND);
// debug output
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