Cleanup serial output
This commit is contained in:
@@ -190,7 +190,7 @@ bool EpubHtmlParserSlim::parseAndBuildPages() {
|
||||
int done;
|
||||
|
||||
if (!parser) {
|
||||
Serial.println("Couldn't allocate memory for parser");
|
||||
Serial.printf("[%lu] [EHP] Couldn't allocate memory for parser\n", millis());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ bool EpubHtmlParserSlim::parseAndBuildPages() {
|
||||
|
||||
FILE* file = fopen(filepath, "r");
|
||||
if (!file) {
|
||||
Serial.printf("Couldn't open file %s\n", filepath);
|
||||
Serial.printf("[%lu] [EHP] Couldn't open file %s\n", millis(), filepath);
|
||||
XML_ParserFree(parser);
|
||||
return false;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ bool EpubHtmlParserSlim::parseAndBuildPages() {
|
||||
do {
|
||||
void* const buf = XML_GetBuffer(parser, 1024);
|
||||
if (!buf) {
|
||||
Serial.println("Couldn't allocate memory for buffer");
|
||||
Serial.printf("[%lu] [EHP] Couldn't allocate memory for buffer\n", millis());
|
||||
XML_ParserFree(parser);
|
||||
fclose(file);
|
||||
return false;
|
||||
@@ -217,7 +217,7 @@ bool EpubHtmlParserSlim::parseAndBuildPages() {
|
||||
const size_t len = fread(buf, 1, 1024, file);
|
||||
|
||||
if (ferror(file)) {
|
||||
Serial.println("Read error");
|
||||
Serial.printf("[%lu] [EHP] File read error\n", millis());
|
||||
XML_ParserFree(parser);
|
||||
fclose(file);
|
||||
return false;
|
||||
@@ -226,7 +226,7 @@ bool EpubHtmlParserSlim::parseAndBuildPages() {
|
||||
done = feof(file);
|
||||
|
||||
if (XML_ParseBuffer(parser, static_cast<int>(len), done) == XML_STATUS_ERROR) {
|
||||
Serial.printf("Parse error at line %lu:\n%s\n", XML_GetCurrentLineNumber(parser),
|
||||
Serial.printf("[%lu] [EHP] Parse error at line %lu:\n%s\n", millis(), XML_GetCurrentLineNumber(parser),
|
||||
XML_ErrorString(XML_GetErrorCode(parser)));
|
||||
XML_ParserFree(parser);
|
||||
fclose(file);
|
||||
@@ -251,7 +251,7 @@ bool EpubHtmlParserSlim::parseAndBuildPages() {
|
||||
|
||||
void EpubHtmlParserSlim::makePages() {
|
||||
if (!currentTextBlock) {
|
||||
Serial.println("!! No text block to make pages for !!");
|
||||
Serial.printf("[%lu] [EHP] !! No text block to make pages for !!\n", millis());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,9 @@ PageLine* PageLine::deserialize(std::istream& is) {
|
||||
}
|
||||
|
||||
void Page::render(GfxRenderer& renderer, const int fontId) const {
|
||||
const auto start = millis();
|
||||
for (const auto element : elements) {
|
||||
element->render(renderer, fontId);
|
||||
}
|
||||
Serial.printf("Rendered page elements (%u) in %dms\n", elements.size(), millis() - start);
|
||||
}
|
||||
|
||||
void Page::serialize(std::ostream& os) const {
|
||||
@@ -50,7 +48,7 @@ Page* Page::deserialize(std::istream& is) {
|
||||
uint8_t version;
|
||||
serialization::readPod(is, version);
|
||||
if (version != PAGE_FILE_VERSION) {
|
||||
Serial.printf("Page: Unknown version %u\n", version);
|
||||
Serial.printf("[%lu] [PGE] Deserialization failed: Unknown version %u\n", millis(), version);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
constexpr uint8_t SECTION_FILE_VERSION = 3;
|
||||
|
||||
void Section::onPageComplete(const Page* page) {
|
||||
Serial.printf("Page %d complete - free mem: %lu\n", pageCount, ESP.getFreeHeap());
|
||||
|
||||
const auto filePath = cachePath + "/page_" + std::to_string(pageCount) + ".bin";
|
||||
|
||||
std::ofstream outputFile("/sd" + filePath);
|
||||
page->serialize(outputFile);
|
||||
outputFile.close();
|
||||
|
||||
Serial.printf("[%lu] [SCT] Page %d processed\n", millis(), pageCount);
|
||||
|
||||
pageCount++;
|
||||
delete page;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ bool Section::loadCacheMetadata(const int fontId, const float lineCompression, c
|
||||
if (version != SECTION_FILE_VERSION) {
|
||||
inputFile.close();
|
||||
clearCache();
|
||||
Serial.printf("Section state file: Unknown version %u\n", version);
|
||||
Serial.printf("[%lu] [SCT] Deserialization failed: Unknown version %u\n", millis(), version);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -75,14 +75,14 @@ bool Section::loadCacheMetadata(const int fontId, const float lineCompression, c
|
||||
marginRight != fileMarginRight || marginBottom != fileMarginBottom || marginLeft != fileMarginLeft) {
|
||||
inputFile.close();
|
||||
clearCache();
|
||||
Serial.println("Section state file: Parameters do not match, ignoring");
|
||||
Serial.printf("[%lu] [SCT] Deserialization failed: Parameters do not match\n", millis());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
serialization::readPod(inputFile, pageCount);
|
||||
inputFile.close();
|
||||
Serial.printf("Loaded cache: %d pages\n", pageCount);
|
||||
Serial.printf("[%lu] [SCT] Deserialization succeeded: %d pages\n", millis(), pageCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ bool Section::persistPageDataToSD(const int fontId, const float lineCompression,
|
||||
f.close();
|
||||
|
||||
if (!success) {
|
||||
Serial.println("Failed to stream item contents");
|
||||
Serial.printf("[%lu] [SCT] Failed to stream item contents to temp file\n", millis());
|
||||
return false;
|
||||
}
|
||||
|
||||
Serial.printf("Streamed HTML to %s\n", tmpHtmlPath.c_str());
|
||||
Serial.printf("[%lu] [SCT] Streamed temp HTML to %s\n", millis(), tmpHtmlPath.c_str());
|
||||
|
||||
const auto sdTmpHtmlPath = "/sd" + tmpHtmlPath;
|
||||
|
||||
@@ -120,7 +120,7 @@ bool Section::persistPageDataToSD(const int fontId, const float lineCompression,
|
||||
|
||||
SD.remove(tmpHtmlPath.c_str());
|
||||
if (!success) {
|
||||
Serial.println("Failed to parse and build pages");
|
||||
Serial.printf("[%lu] [SCT] Failed to parse XML and build pages\n", millis());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ bool Section::persistPageDataToSD(const int fontId, const float lineCompression,
|
||||
Page* Section::loadPageFromSD() const {
|
||||
const auto filePath = "/sd" + cachePath + "/page_" + std::to_string(currentPage) + ".bin";
|
||||
if (!SD.exists(filePath.c_str() + 3)) {
|
||||
Serial.printf("Page file does not exist: %s\n", filePath.c_str());
|
||||
Serial.printf("[%lu] [SCT] Page file does not exist: %s\n", millis(), filePath.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user