From af8f0b245bb04ac1259a20818aeef2b1e9a23929 Mon Sep 17 00:00:00 2001 From: Dominik Wernberger Date: Thu, 28 Dec 2023 14:49:08 +0100 Subject: [PATCH] Split log into separate logs per stream to avoid synchronization issues when running multiple streams or container in parallel --- src/Container.cpp | 36 +-- src/ContainerContext.hpp | 44 +++- src/DataStream.cpp | 21 +- src/DataStream.hpp | 9 +- src/FutureData.hpp | 22 +- src/GenericParser.cpp | 94 ++++---- src/PageSettings.cpp | 212 +++++++++--------- src/PinShape.hpp | 13 +- src/Primitives/Point.cpp | 6 +- src/Primitives/PrimArc.cpp | 6 +- src/Primitives/PrimBezier.cpp | 8 +- src/Primitives/PrimBitmap.cpp | 48 ++-- src/Primitives/PrimBitmap.hpp | 4 + src/Primitives/PrimCommentText.cpp | 22 +- src/Primitives/PrimEllipse.cpp | 6 +- src/Primitives/PrimLine.cpp | 6 +- src/Primitives/PrimPolygon.cpp | 8 +- src/Primitives/PrimPolyline.cpp | 8 +- src/Primitives/PrimRect.cpp | 6 +- src/Primitives/PrimSymbolVector.cpp | 8 +- src/RecordFactory.cpp | 4 +- src/Stream.hpp | 6 +- src/StreamContext.hpp | 15 +- src/StreamFactory.cpp | 44 ++-- src/Streams/StreamAdminData.cpp | 8 +- src/Streams/StreamCache.cpp | 28 +-- src/Streams/StreamCellsDirectory.cpp | 18 +- src/Streams/StreamDsnStream.cpp | 6 +- src/Streams/StreamERC.cpp | 6 +- src/Streams/StreamExportBlocksDirectory.cpp | 12 +- src/Streams/StreamGraphicsDirectory.cpp | 14 +- src/Streams/StreamHSObjects.cpp | 6 +- src/Streams/StreamHierarchy.cpp | 22 +- src/Streams/StreamLibrary.cpp | 28 +-- src/Streams/StreamNetBundleMapData.cpp | 16 +- src/Streams/StreamPackage.cpp | 10 +- src/Streams/StreamPackagesDirectory.cpp | 12 +- src/Streams/StreamPage.cpp | 46 ++-- src/Streams/StreamPartsDirectory.cpp | 12 +- src/Streams/StreamSchematic.cpp | 16 +- src/Streams/StreamSymbol.cpp | 6 +- src/Streams/StreamSymbolsDirectory.cpp | 12 +- src/Streams/StreamType.cpp | 6 +- src/Streams/StreamViewsDirectory.cpp | 12 +- src/Structures/StructAlias.cpp | 18 +- src/Structures/StructBookMarkSymbolInst.cpp | 6 +- src/Structures/StructBusEntry.cpp | 16 +- src/Structures/StructERCSymbol.cpp | 6 +- src/Structures/StructERCSymbolInst.cpp | 12 +- src/Structures/StructGeneralProperties.cpp | 122 +++++----- src/Structures/StructGlobal.cpp | 6 +- src/Structures/StructGlobalSymbol.cpp | 10 +- src/Structures/StructGraphicArcInst.cpp | 6 +- src/Structures/StructGraphicBezierInst.cpp | 6 +- src/Structures/StructGraphicBitMapInst.cpp | 6 +- src/Structures/StructGraphicBoxInst.cpp | 6 +- .../StructGraphicCommentTextInst.cpp | 6 +- src/Structures/StructGraphicEllipseInst.cpp | 6 +- src/Structures/StructGraphicInst.cpp | 22 +- src/Structures/StructGraphicLineInst.cpp | 6 +- src/Structures/StructGraphicOleEmbedInst.cpp | 6 +- src/Structures/StructGraphicPolygonInst.cpp | 6 +- src/Structures/StructGraphicPolylineInst.cpp | 6 +- src/Structures/StructHierarchicSymbol.cpp | 44 ++-- src/Structures/StructNetDbIdMapping.cpp | 6 +- src/Structures/StructOffPageConnector.cpp | 6 +- src/Structures/StructOffPageSymbol.cpp | 10 +- src/Structures/StructPartInst.cpp | 22 +- src/Structures/StructPinIdxMapping.cpp | 14 +- src/Structures/StructPinShapeSymbol.cpp | 10 +- src/Structures/StructPort.cpp | 6 +- src/Structures/StructPrimitives.cpp | 20 +- src/Structures/StructProperties.cpp | 18 +- src/Structures/StructSthInHierarchy1.cpp | 6 +- src/Structures/StructSthInHierarchy2.cpp | 6 +- src/Structures/StructSthInHierarchy3.cpp | 6 +- src/Structures/StructSthInPages0.cpp | 30 +-- src/Structures/StructSymbolBBox.cpp | 60 ++--- src/Structures/StructSymbolDisplayProp.cpp | 10 +- src/Structures/StructSymbolPin.cpp | 10 +- src/Structures/StructT0x10.cpp | 18 +- src/Structures/StructT0x1f.cpp | 16 +- src/Structures/StructT0x34.cpp | 116 +++++----- src/Structures/StructT0x35.cpp | 136 +++++------ src/Structures/StructT0x45.cpp | 6 +- src/Structures/StructT0x5b.cpp | 6 +- src/Structures/StructTitleBlock.cpp | 6 +- src/Structures/StructTitleBlockSymbol.cpp | 10 +- src/Structures/StructWire.cpp | 26 +-- src/Win32/LOGFONTA.hpp | 6 +- src/XmlExporter.cpp | 3 +- test/src/Helper.hpp | 34 ++- 92 files changed, 995 insertions(+), 902 deletions(-) diff --git a/src/Container.cpp b/src/Container.cpp index 885cc4e..2b61af6 100644 --- a/src/Container.cpp +++ b/src/Container.cpp @@ -60,8 +60,12 @@ Container::Container(const fs::path& aCfbfContainer, ParserConfig aCfg) : const fs::path extractTo = fs::temp_directory_path() / "OpenOrCadParser" / uuid; mCtx.mExtractedCfbfPath = extractContainer(aCfbfContainer, extractTo); - spdlog::debug("Using parser configuration:"); - spdlog::debug(to_string(mCfg)); + // @todo This is a hack, since mExtractedCfbfPath is not available at construction of the context + const fs::path logPath = extractTo / "logs" / "OpenOrCadParser.log"; + mCtx.configureLogger(logPath); + + mCtx.mLogger.debug("Using parser configuration:"); + mCtx.mLogger.debug(to_string(mCfg)); } @@ -72,7 +76,7 @@ Container::~Container() // Remove temporary extracted files fs::remove_all(mCtx.mExtractedCfbfPath.parent_path()); - spdlog::debug("Deleted CFBF container at `{}`", mCtx.mExtractedCfbfPath.string()); + mCtx.mLogger.debug("Deleted CFBF container at `{}`", mCtx.mExtractedCfbfPath.string()); } } @@ -125,9 +129,9 @@ std::vector> equallyDistributeElementsIntoLists( */ void Container::parseLibrary() { - spdlog::info("Using {} threads", mCtx.mCfg.mThreadCount); + mCtx.mLogger.info("Using {} threads", mCtx.mCfg.mThreadCount); - spdlog::info("Start parsing library located at {}", mCtx.mExtractedCfbfPath.string()); + mCtx.mLogger.info("Start parsing library located at {}", mCtx.mExtractedCfbfPath.string()); // Parse all streams in the container i.e. files in the file system for(const auto& dir_entry : fs::recursive_directory_iterator(mCtx.mExtractedCfbfPath)) @@ -155,14 +159,14 @@ void Container::parseLibrary() for(std::size_t i{0U}; i < threadJobList.size(); ++i) { - spdlog::info("Assigning thread {} with the following {}/{} jobs:", + mCtx.mLogger.info("Assigning thread {} with the following {}/{} jobs:", i, threadJobList.at(i).size(), mFileCtr); const auto& threadJobs = threadJobList.at(i); for(const auto& job : threadJobs) { - spdlog::debug(" {}", (*job)->mCtx.mInputStream.string()); + mCtx.mLogger.debug(" {}", (*job)->mCtx.mInputStream.string()); } } @@ -194,9 +198,9 @@ void Container::parseLibrary() errCtrStr = fmt::format((mFileErrCtr == 0u) ? fg(fmt::color::green) : fg(fmt::color::crimson), errCtrStr); - spdlog::info(errCtrStr); + mCtx.mLogger.info(errCtrStr); - // spdlog::info(to_string(mLibrary)); + // mCtx.mLogger.info(to_string(mLibrary)); } @@ -208,17 +212,17 @@ void Container::exceptionHandling() } catch(const std::exception& e) { - spdlog::error(fmt::format(fg(fmt::color::crimson), "--------ERROR REPORT--------")); - spdlog::error(fmt::format(fg(fmt::color::crimson), "Input Container: {}", mCtx.mInputCfbfFile.string())); + mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), "--------ERROR REPORT--------")); + mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), "Input Container: {}", mCtx.mInputCfbfFile.string())); // @todo - // spdlog::error(fmt::format(fg(fmt::color::crimson), "Current File: {}", mCtx.mInputStream.string())); - // spdlog::error(fmt::format(fg(fmt::color::crimson), mCtx.mDs.getCurrentOffsetStrMsg())); - spdlog::error(fmt::format(fg(fmt::color::crimson), "\nError Message: {}\n\n", e.what())); + // mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), "Current File: {}", mCtx.mInputStream.string())); + // mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), mCtx.mDs.getCurrentOffsetStrMsg())); + mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), "\nError Message: {}\n\n", e.what())); } catch(...) { - spdlog::error(fmt::format(fg(fmt::color::crimson), "--------ERROR REPORT--------")); - spdlog::error(fmt::format(fg(fmt::color::crimson), "Unknown exception caught!\n")); + mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), "--------ERROR REPORT--------")); + mCtx.mLogger.error(fmt::format(fg(fmt::color::crimson), "Unknown exception caught!\n")); } } diff --git a/src/ContainerContext.hpp b/src/ContainerContext.hpp index e449d28..cbae243 100644 --- a/src/ContainerContext.hpp +++ b/src/ContainerContext.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "General.hpp" @@ -47,6 +48,20 @@ class CfbfStreamLocation mStreamLocation = std::move(streamLocation); } + fs::path get_relative_fs_path() const + { + const auto vec = get_vector(); + + fs::path fsPath{}; + + for(const auto& part : vec) + { + fsPath = fsPath / part; + } + + return fsPath; + } + const std::vector& get_vector() const { return mStreamLocation; @@ -154,22 +169,44 @@ class ContainerContext public: ContainerContext(const fs::path& aInputCfbfFile, - const fs::path& aExtractedCfbfPath, ParserConfig aCfg, Container& aContainer) : mContainer{aContainer} + const fs::path& aExtractedCfbfPath, ParserConfig aCfg, Container& aContainer) : mContainer{aContainer}, + mLogger{"tmp"} { mInputCfbfFile = aInputCfbfFile; mExtractedCfbfPath = aExtractedCfbfPath; mCfg = aCfg; mFileFormatVersion = FileFormatVersion::C; mFileType = FileType::Library; + mLogLevel = spdlog::level::trace; + + const fs::path logPath = mExtractedCfbfPath / "logs" / "OpenOrCadParser.log"; + configureLogger(logPath); } - ContainerContext(const ContainerContext& aCtx) : mContainer{aCtx.mContainer} + ContainerContext(const ContainerContext& aCtx) : mContainer{aCtx.mContainer}, mLogger{"tmp"} { mInputCfbfFile = aCtx.mInputCfbfFile; mExtractedCfbfPath = aCtx.mExtractedCfbfPath; mCfg = aCtx.mCfg; mFileFormatVersion = aCtx.mFileFormatVersion; mFileType = aCtx.mFileType; + mLogLevel = aCtx.mLogLevel; + } + + void configureLogger(const fs::path& aLogPath) + { + if(aLogPath.has_parent_path()) + { + fs::create_directories(aLogPath.parent_path()); + } + + auto file_sink = std::make_shared(aLogPath); + mLogger = spdlog::logger{"file logger", {file_sink}}; + mLogger.set_pattern("[%^%l%$] %v"); + mLogger.set_level(mLogLevel); + + mLogger.info("Created log file at {}", aLogPath.string()); + spdlog::info("Created log file at {}", aLogPath.string()); } Container& mContainer; @@ -181,6 +218,9 @@ class ContainerContext FileFormatVersion mFileFormatVersion; FileType mFileType; + + spdlog::level::level_enum mLogLevel; + spdlog::logger mLogger; }; diff --git a/src/DataStream.cpp b/src/DataStream.cpp index 9dab256..30703c3 100644 --- a/src/DataStream.cpp +++ b/src/DataStream.cpp @@ -8,6 +8,7 @@ #include "DataStream.hpp" #include "General.hpp" +#include "StreamContext.hpp" void DataStream::discardBytes(size_t aLen) @@ -58,7 +59,7 @@ std::string DataStream::readStringZeroTerm() const std::string msg = fmt::format("Loop canceled because the string is unexpectedly large.\n" "More than {} characters! The following string was read until now:\n{}", max_chars, str); - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -89,7 +90,7 @@ std::string DataStream::readStringLenTerm() { const std::string msg = "Didn't expect null byte within string!"; - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -103,7 +104,7 @@ std::string DataStream::readStringLenTerm() const std::string msg = "Loop cancled because the string is unexpectedly large. More than " + std::to_string(max_chars) + " characters!"; - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -126,7 +127,7 @@ std::string DataStream::readStringLenZeroTerm() + ") does not match the preceding length (" + std::to_string(len) + ") definition!"; - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -143,8 +144,8 @@ void DataStream::printUnknownData(size_t aLen, const std::string& aComment) if(aLen > 0u) { - spdlog::debug(aComment); - spdlog::debug(dataToStr(data)); + mCtx.mLogger.debug(aComment); + mCtx.mLogger.debug(dataToStr(data)); } } @@ -160,7 +161,7 @@ void DataStream::padRest(size_t aStartOffset, size_t aBlockSize, bool aPadIsZero + " bytes but should have only been " + std::to_string(aBlockSize) + "!"; - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::runtime_error(msg); } @@ -177,7 +178,7 @@ void DataStream::padRest(size_t aStartOffset, size_t aBlockSize, bool aPadIsZero { const std::string msg = "Padding byte is expected to be 0x00!"; - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -199,7 +200,7 @@ std::string DataStream::getCurrentOffsetStrMsg() void DataStream::printData(const std::vector& aData) { - spdlog::info(dataToStr(aData)); + mCtx.mLogger.info(dataToStr(aData)); } @@ -272,7 +273,7 @@ void DataStream::assumeData(const std::vector& aExpectedData, const std + "Expected:\n" + dataToStr(aExpectedData) + + "but got:\n" + dataToStr(data); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::runtime_error(msg); } diff --git a/src/DataStream.hpp b/src/DataStream.hpp index ce2596e..2638d25 100644 --- a/src/DataStream.hpp +++ b/src/DataStream.hpp @@ -21,6 +21,7 @@ class FutureDataLst; class Record; +class StreamContext; namespace fs = std::filesystem; @@ -30,10 +31,10 @@ class DataStream : public std::ifstream { public: - DataStream() : std::ifstream{} - { } + // DataStream() : std::ifstream{} + // { } - DataStream(const fs::path& aFile) : std::ifstream{aFile, std::ifstream::binary} + DataStream(const fs::path& aFile, StreamContext& aCtx) : std::ifstream{aFile, std::ifstream::binary}, mCtx{aCtx} { } // Checks whether the stream has reached the end of the file. @@ -215,6 +216,8 @@ class DataStream : public std::ifstream std::string dataToStr(const std::vector& aData); void assumeData(const std::vector& aExpectedData, const std::string& aComment = ""); + + StreamContext& mCtx; }; diff --git a/src/FutureData.hpp b/src/FutureData.hpp index 6f07049..83cd32e 100644 --- a/src/FutureData.hpp +++ b/src/FutureData.hpp @@ -77,7 +77,7 @@ class FutureDataLst : public std::vector std::optional getByStartOffset(std::size_t aAbsStartOffset) const { - spdlog::debug("Searching for StartOffset 0x{:08x}", aAbsStartOffset); + mCtx.get().mLogger.debug("Searching for StartOffset 0x{:08x}", aAbsStartOffset); const auto cmp = [&aAbsStartOffset] (FutureData aFutureData) -> bool { return aFutureData.getStartOffset() == aAbsStartOffset; }; @@ -94,7 +94,7 @@ class FutureDataLst : public std::vector std::optional getByStopOffset(std::size_t aAbsStopOffset) const { - spdlog::debug("Searching for StopOffset 0x{:08x}", aAbsStopOffset); + mCtx.get().mLogger.debug("Searching for StopOffset 0x{:08x}", aAbsStopOffset); const auto cmp = [&aAbsStopOffset] (FutureData aFutureData) -> bool { return aFutureData.getStopOffset() == aAbsStopOffset; }; @@ -159,14 +159,14 @@ class FutureDataLst : public std::vector const std::string msg = fmt::format("{}: Checkpoint position at 0x{:08x} is duplicated", getMethodName(this, __func__), currOffset); - spdlog::error(msg); + mCtx.get().mLogger.error(msg); throw std::runtime_error(msg); } else { futureData.setParsed(true); - spdlog::debug("{}: Checkpoint at 0x{:08x} was successful", + mCtx.get().mLogger.debug("{}: Checkpoint at 0x{:08x} was successful", getMethodName(this, __func__), currOffset); } } @@ -177,11 +177,11 @@ class FutureDataLst : public std::vector const std::string msg = fmt::format("{}: Checkpoint position at 0x{:08x} is incorrect", getMethodName(this, __func__), currOffset); - spdlog::error(msg); + mCtx.get().mLogger.error(msg); throw std::runtime_error(msg); } - spdlog::trace("{}: Checkpoint at 0x{:08x} was not found", + mCtx.get().mLogger.trace("{}: Checkpoint at 0x{:08x} was not found", getMethodName(this, __func__), currOffset); } } @@ -196,7 +196,7 @@ class FutureDataLst : public std::vector { checkpoint_missing = true; - spdlog::debug("{}: Checkpoint missing for 0x{:08x} -> 0x{:08x}", + mCtx.get().mLogger.debug("{}: Checkpoint missing for 0x{:08x} -> 0x{:08x}", getMethodName(this, __func__), data.getStartOffset(), data.getStopOffset()); } @@ -207,7 +207,7 @@ class FutureDataLst : public std::vector const std::string msg = fmt::format("{}: Check your code for missing checkpoints!\n{}", getMethodName(this, __func__), string()); - spdlog::debug(msg); + mCtx.get().mLogger.debug(msg); throw std::runtime_error(msg); } } @@ -266,14 +266,14 @@ class FutureDataLst : public std::vector } else { - spdlog::debug("{}: Did not find any future data following current offset 0x{:08x}", + mCtx.get().mLogger.debug("{}: Did not find any future data following current offset 0x{:08x}", getMethodName(this, __func__), curPos); } } void readRestOfStructure() { - spdlog::trace(string()); + mCtx.get().mLogger.trace(string()); // We don't know anything about the // structure, therefore do nothing @@ -314,7 +314,7 @@ class FutureDataLst : public std::vector " Expected it to end at 0x{:08x} but ended at 0x{:08x}. Too large by {} Byte.", getMethodName(this, __func__), endPos, curPos, std::abs(byteDiff)); - spdlog::debug(msg); + mCtx.get().mLogger.debug(msg); throw std::runtime_error(msg); } } diff --git a/src/GenericParser.cpp b/src/GenericParser.cpp index 6a2ae23..4075f41 100644 --- a/src/GenericParser.cpp +++ b/src/GenericParser.cpp @@ -48,7 +48,7 @@ void GenericParser::discard_until_preamble() const std::string msg = fmt::format("{}: Unexpectedly reached end-of-file!", getMethodName(this, __func__)); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::runtime_error(msg); } } @@ -61,19 +61,18 @@ void GenericParser::discard_until_preamble() const size_t endOffset = mCtx.mDs.getCurrentOffset(); - spdlog::debug("{}: Discarded {} Byte until next preamble", + mCtx.mLogger.debug("{}: Discarded {} Byte until next preamble", getMethodName(this, __func__), endOffset - startOffset); } Structure GenericParser::auto_read_prefixes(FutureDataLst& aFutureDataLst) { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); const size_t startOffset = mCtx.mDs.getCurrentOffset(); - const auto logLevel = spdlog::get_level(); - spdlog::set_level(spdlog::level::off); + mCtx.mLogger.set_level(spdlog::level::off); bool failed = true; size_t prefixCtr = 0U; @@ -119,7 +118,7 @@ Structure GenericParser::auto_read_prefixes(FutureDataLst& aFutureDataLst) // reset the EoF flag. mCtx.mDs.clear(); - spdlog::set_level(logLevel); + mCtx.mLogger.set_level(mCtx.mLogLevel); if(failed) { @@ -127,7 +126,7 @@ Structure GenericParser::auto_read_prefixes(FutureDataLst& aFutureDataLst) " (maximum is set to {} but could be higher)", getMethodName(this, __func__), maxPrefixes); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::runtime_error(msg); } @@ -137,13 +136,13 @@ Structure GenericParser::auto_read_prefixes(FutureDataLst& aFutureDataLst) // I.e. figure out the numbers for each structure and move the // parsing code into the structure specific parser. This should // get rid of auto_read_prefixes. - spdlog::debug("{}: Found {} prefixes for {}\n", + mCtx.mLogger.debug("{}: Found {} prefixes for {}\n", getMethodName(this, __func__), prefixCtr, ::to_string(structure)); - spdlog::debug(" {}", aFutureDataLst.string()); + mCtx.mLogger.debug(" {}", aFutureDataLst.string()); mCtx.mDs.sanitizeNoEoF(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return structure; } @@ -158,7 +157,7 @@ Structure GenericParser::auto_read_prefixes(Structure aExpectedStruct, FutureDat const std::string err = fmt::format("{}: Expected {} but got {}", getMethodName(this, __func__), ::to_string(aExpectedStruct), ::to_string(actualStruct)); - spdlog::debug(err); + mCtx.mLogger.debug(err); throw std::runtime_error(err); } @@ -183,7 +182,7 @@ Structure GenericParser::auto_read_prefixes(const std::vector& aExpec std::accumulate(expectedStrStructs.cbegin(), expectedStrStructs.cend(), std::string{", "}), ::to_string(actualStruct)); - spdlog::debug(err); + mCtx.mLogger.debug(err); throw std::runtime_error(err); } @@ -194,7 +193,7 @@ Structure GenericParser::auto_read_prefixes(const std::vector& aExpec // Read number of prefixes, where the last one is a short prefix Structure GenericParser::read_prefixes(size_t aNumber, FutureDataLst& aFutureDataLst) { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); if(aNumber == 0U) { @@ -237,30 +236,30 @@ Structure GenericParser::read_prefixes(size_t aNumber, FutureDataLst& aFutureDat getMethodName(this, __func__), ::to_string(currStruct), ::to_string(firstStruct)); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::runtime_error(msg); } } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return firstStruct; } std::pair GenericParser::read_single_prefix() { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); const Structure typeId = ToStructure(mCtx.mDs.readUint8()); const uint32_t byteOffset = mCtx.mDs.readUint32(); - spdlog::debug("{:>2} = {}: Offset = {}\n", static_cast(typeId), ::to_string(typeId), byteOffset); + mCtx.mLogger.debug("{:>2} = {}: Offset = {}\n", static_cast(typeId), ::to_string(typeId), byteOffset); mCtx.mDs.printUnknownData(4, getMethodName(this, __func__) + ": 0"); // assumeData({0x00, 0x00, 0x00, 0x00}, getMethodName(this, __func__) + ": 0"); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return std::pair{typeId, byteOffset}; } @@ -268,13 +267,13 @@ std::pair GenericParser::read_single_prefix() std::pair GenericParser::read_single_prefix_short() { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); const Structure typeId = ToStructure(mCtx.mDs.readUint8()); const int16_t size = mCtx.mDs.readInt16(); - spdlog::debug("{:>2} = {}: Size = {}\n", static_cast(typeId), ::to_string(typeId), size); + mCtx.mLogger.debug("{:>2} = {}: Size = {}\n", static_cast(typeId), ::to_string(typeId), size); if(size >= 0) { @@ -307,14 +306,14 @@ std::pair GenericParser::read_single_prefix_short() return ""; }; - spdlog::debug(" {}: {} <- {}", i, getStr(nameValueMapping.at(i).first), getStr(nameValueMapping.at(i).second)); + mCtx.mLogger.debug(" {}: {} <- {}", i, getStr(nameValueMapping.at(i).first), getStr(nameValueMapping.at(i).second)); } catch(const std::exception& e) { const std::string msg = fmt::format("{}: Tried to access strLst out of range!\n{}", getMethodName(this, __func__), e.what()); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::out_of_range(msg); } } @@ -323,10 +322,10 @@ std::pair GenericParser::read_single_prefix_short() { // @todo Why is -1 used? The value 0 would also suffice... // Until now I only saw it for PinIdxMapping, Properties and SymbolDisplayProp - spdlog::debug("{}: What does {} mean?", ::to_string(typeId), size); // @todo Figure out + mCtx.mLogger.debug("{}: What does {} mean?", ::to_string(typeId), size); // @todo Figure out } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return std::pair{typeId, size}; } @@ -334,7 +333,7 @@ std::pair GenericParser::read_single_prefix_short() void GenericParser::readPreamble() { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); const std::size_t startOffset = mCtx.mDs.getCurrentOffset(); @@ -349,16 +348,16 @@ void GenericParser::readPreamble() mCtx.mDs.printUnknownData(dataLen, fmt::format("{}: Trailing preamble data", getMethodName(this, __func__))); - // spdlog::debug("{}: Found preamble", getMethodName(this, __func__)); + // mCtx.mLogger.debug("{}: Found preamble", getMethodName(this, __func__)); } catch(const std::runtime_error& err) { mCtx.mDs.setCurrentOffset(startOffset); - spdlog::debug("{}: Skipping preamble", getMethodName(this, __func__)); + mCtx.mLogger.debug("{}: Skipping preamble", getMethodName(this, __func__)); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); } @@ -373,7 +372,7 @@ Primitive GenericParser::readPrefixPrimitive() getMethodName(this, __func__), ::to_string(primitive1), ::to_string(primitive2)); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); throw std::runtime_error(msg); } @@ -383,13 +382,13 @@ Primitive GenericParser::readPrefixPrimitive() std::unique_ptr GenericParser::readPrimitive() { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); Primitive typeId = ToPrimitive(mCtx.mDs.peek(1)[0]); std::unique_ptr obj = readPrimitive(typeId); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return obj; } @@ -397,7 +396,7 @@ std::unique_ptr GenericParser::readPrimitive() std::unique_ptr GenericParser::readPrimitive(Primitive aPrimitive) { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); const size_t startOffset = mCtx.mDs.getCurrentOffset(); @@ -413,7 +412,7 @@ std::unique_ptr GenericParser::readPrimitive(Primitive aPrimitive) { if(mCtx.mCfg.mSkipInvalidPrim) { - spdlog::debug("{}: Skipping invalid Primitive {}", + mCtx.mLogger.debug("{}: Skipping invalid Primitive {}", getMethodName(this, __func__), ::to_string(aPrimitive)); // Reset file position to the state before @@ -442,14 +441,14 @@ std::unique_ptr GenericParser::readPrimitive(Primitive aPrimitive) const std::string msg = fmt::format("{}: Primitive {} is not implemented!", getMethodName(this, __func__), ::to_string(aPrimitive)); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); if(!mCtx.mCfg.mSkipUnknownPrim) { throw std::runtime_error(msg); } - spdlog::debug("{}: Skipping unimplemented Primitive {}", + mCtx.mLogger.debug("{}: Skipping unimplemented Primitive {}", getMethodName(this, __func__), ::to_string(aPrimitive)); const uint32_t byteLength = mCtx.mDs.readUint32(); @@ -460,7 +459,7 @@ std::unique_ptr GenericParser::readPrimitive(Primitive aPrimitive) readPreamble(); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return obj; } @@ -468,13 +467,13 @@ std::unique_ptr GenericParser::readPrimitive(Primitive aPrimitive) std::unique_ptr GenericParser::readStructure() { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); Structure typeId = ToStructure(mCtx.mDs.peek(1)[0]); std::unique_ptr obj = readStructure(typeId); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return obj; } @@ -482,7 +481,7 @@ std::unique_ptr GenericParser::readStructure() std::unique_ptr GenericParser::readStructure(Structure aStructure) { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); const size_t startOffset = mCtx.mDs.getCurrentOffset(); @@ -498,7 +497,7 @@ std::unique_ptr GenericParser::readStructure(Structure aStructure) { if(mCtx.mCfg.mSkipInvalidStruct) { - spdlog::debug("{}: Skipping invalid Structure {}", + mCtx.mLogger.debug("{}: Skipping invalid Structure {}", getMethodName(this, __func__), ::to_string(aStructure)); // Reset file position to the state before @@ -526,14 +525,14 @@ std::unique_ptr GenericParser::readStructure(Structure aStructure) const std::string msg = fmt::format("{}: Structure {} is unimplemented!", getMethodName(this, __func__), ::to_string(aStructure)); - spdlog::debug(msg); + mCtx.mLogger.debug(msg); if(!mCtx.mCfg.mSkipUnknownStruct) { throw std::runtime_error(msg); } - spdlog::debug("{}: Skipping unimplemented Structure {}", + mCtx.mLogger.debug("{}: Skipping unimplemented Structure {}", getMethodName(this, __func__), ::to_string(aStructure)); FutureDataLst localFutureDataLst{mCtx}; @@ -543,7 +542,7 @@ std::unique_ptr GenericParser::readStructure(Structure aStructure) localFutureDataLst.readRestOfStructure(); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), mCtx.mDs.getCurrentOffset())); return obj; } @@ -612,8 +611,7 @@ FileFormatVersion GenericParser::predictVersion(std::function -#include -#include - -#include - -#include "General.hpp" -#include "PageSettings.hpp" - - -void PageSettings::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - createDateTime = static_cast(ds.readUint32()); - modifyDateTime = static_cast(ds.readUint32()); - - spdlog::trace("createDateTime = {}", DateTimeToStr(createDateTime)); - spdlog::trace("modifyDateTime = {}", DateTimeToStr(modifyDateTime)); - - ds.printUnknownData(4, getMethodName(this, __func__) + ": 0"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 1"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 2"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 3"); - - width = ds.readUint32(); - height = ds.readUint32(); - - spdlog::trace("width = {}", width); - spdlog::trace("height = {}", height); - - pinToPin = ds.readUint32(); - - spdlog::trace("pinToPin = {}", pinToPin); - - ds.printUnknownData(2, getMethodName(this, __func__) + ": 4"); - - horizontalCount = ds.readUint16(); - verticalCount = ds.readUint16(); - - spdlog::trace("horizontalCount = {}", horizontalCount); - spdlog::trace("verticalCount = {}", verticalCount); - - ds.printUnknownData(2, getMethodName(this, __func__) + ": 5"); - - horizontalWidth = ds.readUint32(); - verticalWidth = ds.readUint32(); - - spdlog::trace("horizontalWidth = {}", horizontalWidth); - spdlog::trace("verticalWidth = {}", verticalWidth); - - ds.printUnknownData(4, getMethodName(this, __func__) + ": 6"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 7"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 8"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 9"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 10"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 11"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 12"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 13"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 14"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 15"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 16"); - ds.printUnknownData(4, getMethodName(this, __func__) + ": 17"); - - horizontalChar = ds.readUint32(); - - spdlog::trace("horizontalChar = {}", horizontalChar); - - ds.printUnknownData(4, getMethodName(this, __func__) + ": 18"); - - horizontalAscending = ds.readUint32(); - - spdlog::trace("horizontalAscending = {}", horizontalAscending); - - verticalChar = ds.readUint32(); - - spdlog::trace("verticalChar = {}", verticalChar); - - ds.printUnknownData(4, getMethodName(this, __func__) + ": 19"); - - verticalAscending = ds.readUint32(); - - spdlog::trace("verticalAscending = {}", verticalAscending); - - isMetric = ds.readUint32(); - borderDisplayed = ds.readUint32(); - borderPrinted = ds.readUint32(); - gridRefDisplayed = ds.readUint32(); - gridRefPrinted = ds.readUint32(); - titleblockDisplayed = ds.readUint32(); - titleblockPrinted = ds.readUint32(); - ansiGridRefs = ds.readUint32(); // @todo In the XML it's always 1, maybe a bug in OrCad? - - spdlog::trace("isMetric = {}", isMetric); - spdlog::trace("borderDisplayed = {}", borderDisplayed); - spdlog::trace("borderPrinted = {}", borderPrinted); - spdlog::trace("gridRefDisplayed = {}", gridRefDisplayed); - spdlog::trace("gridRefPrinted = {}", gridRefPrinted); - spdlog::trace("titleblockDisplayed = {}", titleblockDisplayed); - spdlog::trace("titleblockPrinted = {}", titleblockPrinted); - spdlog::trace("ansiGridRefs = {}", ansiGridRefs); - - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); +#include +#include +#include + +#include + +#include "General.hpp" +#include "PageSettings.hpp" + + +void PageSettings::read(FileFormatVersion /* aVersion */) +{ + auto& ds = mCtx.mDs; + + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + + createDateTime = static_cast(ds.readUint32()); + modifyDateTime = static_cast(ds.readUint32()); + + mCtx.mLogger.trace("createDateTime = {}", DateTimeToStr(createDateTime)); + mCtx.mLogger.trace("modifyDateTime = {}", DateTimeToStr(modifyDateTime)); + + ds.printUnknownData(4, getMethodName(this, __func__) + ": 0"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 1"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 2"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 3"); + + width = ds.readUint32(); + height = ds.readUint32(); + + mCtx.mLogger.trace("width = {}", width); + mCtx.mLogger.trace("height = {}", height); + + pinToPin = ds.readUint32(); + + mCtx.mLogger.trace("pinToPin = {}", pinToPin); + + ds.printUnknownData(2, getMethodName(this, __func__) + ": 4"); + + horizontalCount = ds.readUint16(); + verticalCount = ds.readUint16(); + + mCtx.mLogger.trace("horizontalCount = {}", horizontalCount); + mCtx.mLogger.trace("verticalCount = {}", verticalCount); + + ds.printUnknownData(2, getMethodName(this, __func__) + ": 5"); + + horizontalWidth = ds.readUint32(); + verticalWidth = ds.readUint32(); + + mCtx.mLogger.trace("horizontalWidth = {}", horizontalWidth); + mCtx.mLogger.trace("verticalWidth = {}", verticalWidth); + + ds.printUnknownData(4, getMethodName(this, __func__) + ": 6"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 7"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 8"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 9"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 10"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 11"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 12"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 13"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 14"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 15"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 16"); + ds.printUnknownData(4, getMethodName(this, __func__) + ": 17"); + + horizontalChar = ds.readUint32(); + + mCtx.mLogger.trace("horizontalChar = {}", horizontalChar); + + ds.printUnknownData(4, getMethodName(this, __func__) + ": 18"); + + horizontalAscending = ds.readUint32(); + + mCtx.mLogger.trace("horizontalAscending = {}", horizontalAscending); + + verticalChar = ds.readUint32(); + + mCtx.mLogger.trace("verticalChar = {}", verticalChar); + + ds.printUnknownData(4, getMethodName(this, __func__) + ": 19"); + + verticalAscending = ds.readUint32(); + + mCtx.mLogger.trace("verticalAscending = {}", verticalAscending); + + isMetric = ds.readUint32(); + borderDisplayed = ds.readUint32(); + borderPrinted = ds.readUint32(); + gridRefDisplayed = ds.readUint32(); + gridRefPrinted = ds.readUint32(); + titleblockDisplayed = ds.readUint32(); + titleblockPrinted = ds.readUint32(); + ansiGridRefs = ds.readUint32(); // @todo In the XML it's always 1, maybe a bug in OrCad? + + mCtx.mLogger.trace("isMetric = {}", isMetric); + mCtx.mLogger.trace("borderDisplayed = {}", borderDisplayed); + mCtx.mLogger.trace("borderPrinted = {}", borderPrinted); + mCtx.mLogger.trace("gridRefDisplayed = {}", gridRefDisplayed); + mCtx.mLogger.trace("gridRefPrinted = {}", gridRefPrinted); + mCtx.mLogger.trace("titleblockDisplayed = {}", titleblockDisplayed); + mCtx.mLogger.trace("titleblockPrinted = {}", titleblockPrinted); + mCtx.mLogger.trace("ansiGridRefs = {}", ansiGridRefs); + + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/PinShape.hpp b/src/PinShape.hpp index 0e19cbf..dc49df9 100644 --- a/src/PinShape.hpp +++ b/src/PinShape.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -126,7 +127,7 @@ static ShapeType ToShapeType(const PinShape& pinShape) [[maybe_unused]] -static PinShape ToPinShape(uint16_t val) +static PinShape ToPinShape(uint16_t val, std::optional aLogger = std::nullopt) { PinShape pinShape; @@ -149,14 +150,20 @@ static PinShape ToPinShape(uint16_t val) { const std::string msg = fmt::format("{}: PinShape bit {} is set but not known!", __func__, i); - spdlog::warn(msg); + if(aLogger.has_value()) + { + aLogger.value().warn(msg); + } continue; } else { const std::string msg = fmt::format("{}: PinShape bit {} is set but 0 was expected!", __func__, i); - spdlog::error(msg); + if(aLogger.has_value()) + { + aLogger.value().error(msg); + } throw std::runtime_error(msg); } } diff --git a/src/Primitives/Point.cpp b/src/Primitives/Point.cpp index 381e394..a8c4a06 100644 --- a/src/Primitives/Point.cpp +++ b/src/Primitives/Point.cpp @@ -12,11 +12,11 @@ void Point::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); y = ds.readUint16(); x = ds.readUint16(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimArc.cpp b/src/Primitives/PrimArc.cpp index f9e105c..a8f2f7d 100644 --- a/src/Primitives/PrimArc.cpp +++ b/src/Primitives/PrimArc.cpp @@ -33,7 +33,7 @@ void PrimArc::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const size_t startOffset = ds.getCurrentOffset(); @@ -77,6 +77,6 @@ void PrimArc::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimBezier.cpp b/src/Primitives/PrimBezier.cpp index 25746b7..b440060 100644 --- a/src/Primitives/PrimBezier.cpp +++ b/src/Primitives/PrimBezier.cpp @@ -35,7 +35,7 @@ void PrimBezier::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -57,7 +57,7 @@ void PrimBezier::read(FileFormatVersion aVersion) const uint16_t pointCount = ds.readUint16(); - spdlog::trace("pointCount = {}", pointCount); + mCtx.mLogger.trace("pointCount = {}", pointCount); if(pointCount < 4) { @@ -124,6 +124,6 @@ void PrimBezier::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimBitmap.cpp b/src/Primitives/PrimBitmap.cpp index 88ce46a..e6e88f9 100644 --- a/src/Primitives/PrimBitmap.cpp +++ b/src/Primitives/PrimBitmap.cpp @@ -26,7 +26,7 @@ void PrimBitmap::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const size_t startOffset = ds.getCurrentOffset(); @@ -37,28 +37,28 @@ void PrimBitmap::read(FileFormatVersion /* aVersion */) locX = ds.readInt32(); locY = ds.readInt32(); - spdlog::trace("locX = {}", locX); - spdlog::trace("locY = {}", locY); + mCtx.mLogger.trace("locX = {}", locX); + mCtx.mLogger.trace("locY = {}", locY); x2 = ds.readInt32(); y2 = ds.readInt32(); x1 = ds.readInt32(); y1 = ds.readInt32(); - spdlog::trace("x2 = {}", x2); - spdlog::trace("y2 = {}", y2); - spdlog::trace("x1 = {}", x1); - spdlog::trace("y1 = {}", y1); + mCtx.mLogger.trace("x2 = {}", x2); + mCtx.mLogger.trace("y2 = {}", y2); + mCtx.mLogger.trace("x1 = {}", x1); + mCtx.mLogger.trace("y1 = {}", y1); bmpWidth = ds.readUint32(); bmpHeight = ds.readUint32(); - spdlog::trace("bmpWidth = {}", bmpWidth); - spdlog::trace("bmpHeight = {}", bmpHeight); + mCtx.mLogger.trace("bmpWidth = {}", bmpWidth); + mCtx.mLogger.trace("bmpHeight = {}", bmpHeight); const uint32_t dataSize = ds.readUint32(); - spdlog::trace("dataSize = {}", dataSize); + mCtx.mLogger.trace("dataSize = {}", dataSize); rawImgData.clear(); rawImgData.reserve(dataSize); @@ -68,12 +68,12 @@ void PrimBitmap::read(FileFormatVersion /* aVersion */) rawImgData.push_back(ds.readUint8()); } - fs::path filename = mCtx.mExtractedCfbfPath / "data" / fmt::format("{}_img_{}.bmp", + fs::path filename = mCtx.mExtractedCfbfPath.parent_path() / "data" / fmt::format("{}_img_{}.bmp", mCtx.mInputStream.stem().string(), mCtx.mImgCtr); filename = writeImgToFile(filename); - spdlog::info("{}: Wrote bitmap file to {}", __func__, filename.string()); + mCtx.mLogger.info("{}: Wrote bitmap file to {}", __func__, filename.string()); ++mCtx.mImgCtr; @@ -89,13 +89,13 @@ void PrimBitmap::read(FileFormatVersion /* aVersion */) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } // Returns path to the written image file -static fs::path writeBmpFile(fs::path aFilePath, const std::vector& aRawImgData) +fs::path PrimBitmap::writeBmpFile(fs::path aFilePath, const std::vector& aRawImgData) const { aFilePath.replace_extension(".bmp"); @@ -107,7 +107,7 @@ static fs::path writeBmpFile(fs::path aFilePath, const std::vector& aRa const std::string msg = fmt::format("{}: Can not open file for writing: {}", __func__, aFilePath.string()); - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -134,7 +134,7 @@ static fs::path writeBmpFile(fs::path aFilePath, const std::vector& aRa img.write(reinterpret_cast(&header.reserved), sizeof(header.reserved)); img.write(reinterpret_cast(&header.offset), sizeof(header.offset)); - spdlog::debug("Writing header is done"); + mCtx.mLogger.debug("Writing header is done"); for(const auto& data : aRawImgData) { @@ -150,7 +150,7 @@ static fs::path writeBmpFile(fs::path aFilePath, const std::vector& aRa // aFilePath is the requested path to the image file, but the function will change the file // extension, depending on the corresponding file type that was found. // Returns path to the actually written image file -static fs::path writeNoBmpFile(fs::path aFilePath, const std::vector& aRawImgData) +fs::path PrimBitmap::writeDifferentImageFile(fs::path aFilePath, const std::vector& aRawImgData) const { // Discard the header for non BMP images. After that, they start // with a complete image, e.g. PNG or JPG @@ -204,7 +204,7 @@ static fs::path writeNoBmpFile(fs::path aFilePath, const std::vector& a else { aFilePath.replace_extension(".unknown"); - spdlog::warn("Unknown image file format"); + mCtx.mLogger.warn("Unknown image file format"); } fs::create_directories(aFilePath.parent_path()); @@ -215,7 +215,7 @@ static fs::path writeNoBmpFile(fs::path aFilePath, const std::vector& a const std::string msg = fmt::format("{}: Can not open file for writing: {}", __func__, aFilePath.string()); - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -229,7 +229,7 @@ static fs::path writeNoBmpFile(fs::path aFilePath, const std::vector& a // The images are not always bitmaps where we need to prepend its header // but its also possible that they are PNG, JPG and probably other formats // that have some header that needs to be trimmed away. -static bool isBmpImage(const std::vector& aRawImgData) +bool PrimBitmap::isBmpImage(const std::vector& aRawImgData) const { bool hasMagicId = false; @@ -259,15 +259,15 @@ fs::path PrimBitmap::writeImgToFile(fs::path aFilePath) const // we can simplify this logic by just checking the file format version. if(isBmpImage(rawImgData)) { - spdlog::info("{}: Detected BMP file", getMethodName(this, __func__)); + mCtx.mLogger.info("{}: Detected BMP file", getMethodName(this, __func__)); aFilePath = writeBmpFile(aFilePath, rawImgData); } else { - spdlog::info("{}: Detected some non BMP file", getMethodName(this, __func__)); + mCtx.mLogger.info("{}: Detected some non BMP file", getMethodName(this, __func__)); - aFilePath = writeNoBmpFile(aFilePath, rawImgData); + aFilePath = writeDifferentImageFile(aFilePath, rawImgData); } return aFilePath; diff --git a/src/Primitives/PrimBitmap.hpp b/src/Primitives/PrimBitmap.hpp index 97a2485..3d092a8 100644 --- a/src/Primitives/PrimBitmap.hpp +++ b/src/Primitives/PrimBitmap.hpp @@ -34,6 +34,10 @@ class PrimBitmap : public PrimBase aVisitor.visit(*this); } + fs::path writeBmpFile(fs::path aFilePath, const std::vector& aRawImgData) const; + fs::path writeDifferentImageFile(fs::path aFilePath, const std::vector& aRawImgData) const; + bool isBmpImage(const std::vector& aRawImgData) const; + fs::path writeImgToFile(fs::path aFilePath) const; int32_t locX; diff --git a/src/Primitives/PrimCommentText.cpp b/src/Primitives/PrimCommentText.cpp index de4dc1a..018b783 100644 --- a/src/Primitives/PrimCommentText.cpp +++ b/src/Primitives/PrimCommentText.cpp @@ -17,7 +17,7 @@ void PrimCommentText::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const size_t startOffset = ds.getCurrentOffset(); @@ -36,23 +36,23 @@ void PrimCommentText::read(FileFormatVersion /* aVersion */) locX = ds.readInt32(); locY = ds.readInt32(); - spdlog::trace("locX = {}", locX); - spdlog::trace("locY = {}", locY); + mCtx.mLogger.trace("locX = {}", locX); + mCtx.mLogger.trace("locY = {}", locY); x2 = ds.readInt32(); y2 = ds.readInt32(); x1 = ds.readInt32(); y1 = ds.readInt32(); - spdlog::trace("x2 = {}", x2); - spdlog::trace("y2 = {}", y2); - spdlog::trace("x1 = {}", x1); - spdlog::trace("y1 = {}", y1); + mCtx.mLogger.trace("x2 = {}", x2); + mCtx.mLogger.trace("y2 = {}", y2); + mCtx.mLogger.trace("x1 = {}", x1); + mCtx.mLogger.trace("y1 = {}", y1); // @todo Check if fontIdx with 4 byte fits. I.e. are the following 2 Byte all 0? textFontIdx = ds.readUint16(); - spdlog::trace("textFontIdx = {}", textFontIdx); + mCtx.mLogger.trace("textFontIdx = {}", textFontIdx); if(gLibrary != nullptr) { @@ -70,7 +70,7 @@ void PrimCommentText::read(FileFormatVersion /* aVersion */) name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); if(ds.getCurrentOffset() != startOffset + byteLength) { @@ -84,8 +84,8 @@ void PrimCommentText::read(FileFormatVersion /* aVersion */) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } diff --git a/src/Primitives/PrimEllipse.cpp b/src/Primitives/PrimEllipse.cpp index c8db140..ae810b6 100644 --- a/src/Primitives/PrimEllipse.cpp +++ b/src/Primitives/PrimEllipse.cpp @@ -43,7 +43,7 @@ void PrimEllipse::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const size_t startOffset = ds.getCurrentOffset(); @@ -89,6 +89,6 @@ void PrimEllipse::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimLine.cpp b/src/Primitives/PrimLine.cpp index 0fdf148..797cb2e 100644 --- a/src/Primitives/PrimLine.cpp +++ b/src/Primitives/PrimLine.cpp @@ -34,7 +34,7 @@ void PrimLine::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const size_t startOffset = ds.getCurrentOffset(); @@ -73,6 +73,6 @@ void PrimLine::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimPolygon.cpp b/src/Primitives/PrimPolygon.cpp index 2e7c046..61287c8 100644 --- a/src/Primitives/PrimPolygon.cpp +++ b/src/Primitives/PrimPolygon.cpp @@ -39,7 +39,7 @@ void PrimPolygon::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -73,7 +73,7 @@ void PrimPolygon::read(FileFormatVersion aVersion) const uint16_t pointCount = ds.readUint16(); - spdlog::trace("pointCount = {}", pointCount); + mCtx.mLogger.trace("pointCount = {}", pointCount); if(pointCount < 3u) { @@ -108,6 +108,6 @@ void PrimPolygon::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimPolyline.cpp b/src/Primitives/PrimPolyline.cpp index a96c944..fd2c73b 100644 --- a/src/Primitives/PrimPolyline.cpp +++ b/src/Primitives/PrimPolyline.cpp @@ -33,7 +33,7 @@ void PrimPolyline::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -55,7 +55,7 @@ void PrimPolyline::read(FileFormatVersion aVersion) const uint16_t pointCount = ds.readUint16(); - spdlog::trace("pointCount = {}", pointCount); + mCtx.mLogger.trace("pointCount = {}", pointCount); if(pointCount < 2) { @@ -89,6 +89,6 @@ void PrimPolyline::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimRect.cpp b/src/Primitives/PrimRect.cpp index 8b89c72..dd3805e 100644 --- a/src/Primitives/PrimRect.cpp +++ b/src/Primitives/PrimRect.cpp @@ -40,7 +40,7 @@ void PrimRect::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -88,6 +88,6 @@ void PrimRect::read(FileFormatVersion aVersion) parser.readPreamble(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Primitives/PrimSymbolVector.cpp b/src/Primitives/PrimSymbolVector.cpp index b215c65..d2eca19 100644 --- a/src/Primitives/PrimSymbolVector.cpp +++ b/src/Primitives/PrimSymbolVector.cpp @@ -18,7 +18,7 @@ void PrimSymbolVector::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const auto readSmallPrefixPrimitive = [&, this]() -> Primitive { @@ -40,7 +40,7 @@ void PrimSymbolVector::read(FileFormatVersion /* aVersion */) const uint16_t lenPrimitives = ds.readUint16(); - spdlog::trace("lenPrimitives = {}", lenPrimitives); + mCtx.mLogger.trace("lenPrimitives = {}", lenPrimitives); for(size_t i = 0u; i < lenPrimitives; ++i) { @@ -56,6 +56,6 @@ void PrimSymbolVector::read(FileFormatVersion /* aVersion */) // ds.printUnknownData(12, getMethodName(this, __func__) + ": 2"); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/RecordFactory.cpp b/src/RecordFactory.cpp index d22842d..7f5ef7a 100644 --- a/src/RecordFactory.cpp +++ b/src/RecordFactory.cpp @@ -120,7 +120,7 @@ std::unique_ptr RecordFactory::build(StreamContext& aCtx, Structure aStr { const std::string errMsg = fmt::format( "RecordFactory can not yet build {}", to_string(aStructure)); - spdlog::error(errMsg); + aCtx.mLogger.error(errMsg); } } @@ -146,7 +146,7 @@ std::unique_ptr RecordFactory::build(StreamContext& aCtx, Primitive aPri { const std::string errMsg = fmt::format( "RecordFactory can not yet build {}", to_string(aPrimitive)); - spdlog::error(errMsg); + aCtx.mLogger.error(errMsg); } } diff --git a/src/Stream.hpp b/src/Stream.hpp index b3a6e15..174ca79 100644 --- a/src/Stream.hpp +++ b/src/Stream.hpp @@ -27,14 +27,14 @@ class Stream : public Component void openFile() { - spdlog::info("Opening file: {}", mCtx.mInputStream.string()); + mCtx.mLogger.info("Opening file: {}", mCtx.mInputStream.string()); - spdlog::info("File contains {} byte.", fs::file_size(mCtx.mInputStream)); + mCtx.mLogger.info("File contains {} byte.", fs::file_size(mCtx.mInputStream)); } void closeFile() { - spdlog::info("Closing file: {}", mCtx.mInputStream.string()); + mCtx.mLogger.info("Closing file: {}", mCtx.mInputStream.string()); mCtx.mDs.close(); } diff --git a/src/StreamContext.hpp b/src/StreamContext.hpp index 0d1bf5d..9510dc7 100644 --- a/src/StreamContext.hpp +++ b/src/StreamContext.hpp @@ -11,9 +11,6 @@ #include #include -#include -#include - #include "ContainerContext.hpp" #include "DataStream.hpp" #include "General.hpp" @@ -31,13 +28,19 @@ class StreamContext : public ContainerContext public: StreamContext(const ContainerContext& aCtx, const fs::path& aInputStream) - : ContainerContext{aCtx}, mCfbfStreamLocation{mInputStream, mExtractedCfbfPath}, - mDs{aInputStream}, mMtx{} + : ContainerContext{aCtx}, mInputStream{aInputStream}, mCfbfStreamLocation{mInputStream, mExtractedCfbfPath}, + mDs{aInputStream, *this}, mMtx{} { - mInputStream = aInputStream; mImgCtr = 0U; mAttemptedParsing = false; mParsedSuccessfully = std::nullopt; + + // Create stream specific logger + const fs::path logPath{ + mExtractedCfbfPath.parent_path() / "logs" + / mInputCfbfFile.filename() + / mCfbfStreamLocation.get_relative_fs_path().concat(".log")}; + configureLogger(logPath); } fs::path mInputStream; //!< Input CFBF stream as file in the file system diff --git a/src/StreamFactory.cpp b/src/StreamFactory.cpp index bfbfee7..c0e41ad 100644 --- a/src/StreamFactory.cpp +++ b/src/StreamFactory.cpp @@ -35,7 +35,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p { auto streamLoc = CfbfStreamLocation{aInputStream, aCtx.mExtractedCfbfPath}; - spdlog::debug("Got stream location: {}", ::to_string(streamLoc)); + aCtx.mLogger.debug("Got stream location: {}", ::to_string(streamLoc)); const auto getErrMsg = [](const std::vector>& aPattern, const CfbfStreamLocation& aStreamLoc) { @@ -65,7 +65,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"BundleMapData"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -80,7 +80,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Cells", std::nullopt}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -95,7 +95,15 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "CISSchematicStore", "CISSchematicStream"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); + return std::unique_ptr{}; + } + + // Match `/CIS/VariantStore/BOM/BOMDataStream` + pattern = {"CIS", "VariantStore", "BOM", "BOMDataStream"}; + if(streamLoc.matches_pattern(pattern)) + { + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -103,7 +111,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "VariantStore", "BOM", std::nullopt, "BOMAmbugity"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -111,7 +119,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "VariantStore", "BOM", std::nullopt, "BOMPartData"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -119,7 +127,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "VariantStore", "BOM", std::nullopt, std::nullopt}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -127,7 +135,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "VariantStore", "Groups", "GroupsDataStream"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -135,7 +143,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "VariantStore", "Groups", std::nullopt, std::nullopt}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -143,7 +151,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"CIS", "VariantStore", "VariantNames"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -158,7 +166,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"ExportBlocks", std::nullopt}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -180,7 +188,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Graphics", std::nullopt}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -202,7 +210,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"LayoutReuse", "ReuseSchematics"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -238,7 +246,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Parts", std::nullopt}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -253,7 +261,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Symbols", "$Types$"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -261,7 +269,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Symbols", "ERC"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -269,7 +277,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p pattern = {"Symbols", "ERC_PHYSICAL"}; if(streamLoc.matches_pattern(pattern)) { - spdlog::warn(getErrMsg(pattern, streamLoc)); + aCtx.mLogger.warn(getErrMsg(pattern, streamLoc)); return std::unique_ptr{}; } @@ -320,7 +328,7 @@ std::unique_ptr StreamFactory::build(ContainerContext& aCtx, const fs::p ::to_string(streamLoc) ); - spdlog::warn(errMsg); + aCtx.mLogger.warn(errMsg); return std::unique_ptr{}; } \ No newline at end of file diff --git a/src/Streams/StreamAdminData.cpp b/src/Streams/StreamAdminData.cpp index a3e7762..2aff980 100644 --- a/src/Streams/StreamAdminData.cpp +++ b/src/Streams/StreamAdminData.cpp @@ -12,14 +12,14 @@ void StreamAdminData::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); uint8_t sth0 = ds.readUint8(); // @todo only those two values have been observed until now if(sth0 != 0 && sth0 != 1) { - spdlog::warn("{}: Found new value. Check it out!", getMethodName(this, __func__)); + mCtx.mLogger.warn("{}: Found new value. Check it out!", getMethodName(this, __func__)); } ds.assumeData({0x00, 0x00, 0x00, 0x00, 0x00}, @@ -30,6 +30,6 @@ void StreamAdminData::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamCache.cpp b/src/Streams/StreamCache.cpp index 48840b3..0acb818 100644 --- a/src/Streams/StreamCache.cpp +++ b/src/Streams/StreamCache.cpp @@ -15,7 +15,7 @@ void StreamCache::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); // Early out for empty caches if(parser.tryRead([&](){ ds.readBytes(10U); ds.sanitizeEoF(); })) @@ -28,15 +28,15 @@ void StreamCache::read(FileFormatVersion /* aVersion */) for(std::size_t i{0U}; !ds.isEoF(); ++i) { - spdlog::trace("iteration i = {}", i); + mCtx.mLogger.trace("iteration i = {}", i); const bool hasStrAfter8Byte = parser.tryRead([&](){ ds.readBytes(8U); ds.readStringLenZeroTerm(); }); const bool hasStrAfter2Byte = parser.tryRead([&](){ ds.readBytes(2U); ds.readStringLenZeroTerm(); }); const bool hasStrAfter0Byte = parser.tryRead([&](){ ds.readBytes(0U); ds.readStringLenZeroTerm(); }); - spdlog::trace("hasStrAfter8Byte = {}", hasStrAfter8Byte); - spdlog::trace("hasStrAfter2Byte = {}", hasStrAfter2Byte); - spdlog::trace("hasStrAfter0Byte = {}", hasStrAfter0Byte); + mCtx.mLogger.trace("hasStrAfter8Byte = {}", hasStrAfter8Byte); + mCtx.mLogger.trace("hasStrAfter2Byte = {}", hasStrAfter2Byte); + mCtx.mLogger.trace("hasStrAfter0Byte = {}", hasStrAfter0Byte); if(!hasStrAfter0Byte) { @@ -53,7 +53,7 @@ void StreamCache::read(FileFormatVersion /* aVersion */) const std::string name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); const auto ids = ds.peek(8U); const std::vector id0{ids.cbegin(), ids.cbegin() + 4U}; @@ -66,7 +66,7 @@ void StreamCache::read(FileFormatVersion /* aVersion */) { someVal = ds.readUint16(); - spdlog::trace("someVal = {}", someVal); + mCtx.mLogger.trace("someVal = {}", someVal); if(ds.isEoF()) { @@ -82,7 +82,7 @@ void StreamCache::read(FileFormatVersion /* aVersion */) const std::string someStr = ds.readStringLenZeroTerm(); - spdlog::trace("someStr[{}] = {}", i, someStr); + mCtx.mLogger.trace("someStr[{}] = {}", i, someStr); } while (someVal == 0x0U); if(ds.isEoF()) @@ -92,17 +92,17 @@ void StreamCache::read(FileFormatVersion /* aVersion */) } const uint32_t some_id0 = ds.readUint32(); - spdlog::trace("some_id0 = {}", some_id0); + mCtx.mLogger.trace("some_id0 = {}", some_id0); const uint32_t some_id1 = ds.readUint32(); - spdlog::trace("some_id1 = {}", some_id1); + mCtx.mLogger.trace("some_id1 = {}", some_id1); if(some_id0 != some_id1) { - spdlog::error("some_id0 ({}) != some_id1 ({})", some_id0, some_id1); + mCtx.mLogger.error("some_id0 ({}) != some_id1 ({})", some_id0, some_id1); } const Structure my_struct = ToStructure(ds.readUint16()); - spdlog::trace(::to_string(my_struct)); + mCtx.mLogger.trace(::to_string(my_struct)); parser.readStructure(); } @@ -113,6 +113,6 @@ void StreamCache::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamCellsDirectory.cpp b/src/Streams/StreamCellsDirectory.cpp index fa80f66..ec09364 100644 --- a/src/Streams/StreamCellsDirectory.cpp +++ b/src/Streams/StreamCellsDirectory.cpp @@ -13,7 +13,7 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -25,15 +25,15 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) item.name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", item.name); + mCtx.mLogger.trace("name = {}", item.name); item.componentType = ToComponentType(ds.readUint16()); - spdlog::trace("componentType = {}", ::to_string(item.componentType)); + mCtx.mLogger.trace("componentType = {}", ::to_string(item.componentType)); if(item.componentType != ComponentType::Cell) { - spdlog::warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); + mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); } // @todo This changes with the version of the file format, so maybe it contains @@ -43,7 +43,7 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I observed in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -57,12 +57,12 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); - spdlog::trace("timezone = {}", item.timezone); + mCtx.mLogger.trace("timezone = {}", item.timezone); ds.printUnknownData(2, fmt::format("item[{:>3}] - 1", i)); @@ -74,6 +74,6 @@ void StreamCellsDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamDsnStream.cpp b/src/Streams/StreamDsnStream.cpp index 5863fb4..3a593fa 100644 --- a/src/Streams/StreamDsnStream.cpp +++ b/src/Streams/StreamDsnStream.cpp @@ -18,7 +18,7 @@ void StreamDsnStream::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -42,6 +42,6 @@ void StreamDsnStream::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamERC.cpp b/src/Streams/StreamERC.cpp index ad2a023..1b247d5 100644 --- a/src/Streams/StreamERC.cpp +++ b/src/Streams/StreamERC.cpp @@ -14,7 +14,7 @@ void StreamERC::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); ercSymbol = dynamic_pointer_cast(parser.readStructure()); @@ -23,6 +23,6 @@ void StreamERC::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamExportBlocksDirectory.cpp b/src/Streams/StreamExportBlocksDirectory.cpp index 6708f10..e011613 100644 --- a/src/Streams/StreamExportBlocksDirectory.cpp +++ b/src/Streams/StreamExportBlocksDirectory.cpp @@ -12,7 +12,7 @@ void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -20,7 +20,7 @@ void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */) if(size > 0U) { - spdlog::warn("{}: Check it out. First time that we have some elements here!", + mCtx.mLogger.warn("{}: Check it out. First time that we have some elements here!", getMethodName(this, __func__)); } @@ -39,7 +39,7 @@ void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I obsereved in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -53,7 +53,7 @@ void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); @@ -68,6 +68,6 @@ void StreamExportBlocksDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamGraphicsDirectory.cpp b/src/Streams/StreamGraphicsDirectory.cpp index 32d7849..60b7aa5 100644 --- a/src/Streams/StreamGraphicsDirectory.cpp +++ b/src/Streams/StreamGraphicsDirectory.cpp @@ -13,7 +13,7 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -21,7 +21,7 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) if(size > 0U) { - // spdlog::warn("{} contains Graphic. Check it out!", mInputCfbfFile.string()); + // mCtx.mLogger.warn("{} contains Graphic. Check it out!", mInputCfbfFile.string()); } for(size_t i = 0u; i < size; ++i) @@ -34,7 +34,7 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) if(item.componentType != ComponentType::Graphic) { - spdlog::warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); + mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); } // @todo This changes with the version of the file format, so maybe it contains @@ -44,7 +44,7 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I obsereved in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -58,7 +58,7 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); @@ -73,6 +73,6 @@ void StreamGraphicsDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamHSObjects.cpp b/src/Streams/StreamHSObjects.cpp index 42b517a..077a832 100644 --- a/src/Streams/StreamHSObjects.cpp +++ b/src/Streams/StreamHSObjects.cpp @@ -12,7 +12,7 @@ void StreamHSObjects::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); ds.assumeData({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, fmt::format("{}: - 0", __func__)); ds.assumeData({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, fmt::format("{}: - 1", __func__)); @@ -22,6 +22,6 @@ void StreamHSObjects::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamHierarchy.cpp b/src/Streams/StreamHierarchy.cpp index 41837a2..ed75b5d 100644 --- a/src/Streams/StreamHierarchy.cpp +++ b/src/Streams/StreamHierarchy.cpp @@ -14,7 +14,7 @@ void StreamHierarchy::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -26,13 +26,13 @@ void StreamHierarchy::read(FileFormatVersion aVersion) const std::string schematicName = ds.readStringLenZeroTerm(); - spdlog::trace("schematicName = {}", schematicName); + mCtx.mLogger.trace("schematicName = {}", schematicName); ds.printUnknownData(9, getMethodName(this, __func__) + ": 1"); const uint16_t lenNetDbIdMappings = ds.readUint16(); - spdlog::trace("lenNetDbIdMappings = {}", lenNetDbIdMappings); + mCtx.mLogger.trace("lenNetDbIdMappings = {}", lenNetDbIdMappings); for(size_t i = 0u; i < lenNetDbIdMappings; ++i) { @@ -40,16 +40,16 @@ void StreamHierarchy::read(FileFormatVersion aVersion) const uint32_t dbId = ds.readUint32(); - spdlog::trace("dbId = {}", dbId); + mCtx.mLogger.trace("dbId = {}", dbId); const std::string name = ds.readStringLenZeroTerm(); // net name - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); } const uint16_t lenSthInHierarchy3 = ds.readUint16(); - spdlog::trace("lenSthInHierarchy3 = {}", lenSthInHierarchy3); + mCtx.mLogger.trace("lenSthInHierarchy3 = {}", lenSthInHierarchy3); for(size_t i = 0u; i < lenSthInHierarchy3; ++i) { @@ -60,7 +60,7 @@ void StreamHierarchy::read(FileFormatVersion aVersion) const uint32_t lenT0x5bs = ((int)aVersion & 0x01) ? ds.readUint32() : ds.readUint16(); - spdlog::trace("lenT0x5bs = {}", lenT0x5bs); + mCtx.mLogger.trace("lenT0x5bs = {}", lenT0x5bs); for(size_t i = 0u; i < lenT0x5bs; ++i) { @@ -76,7 +76,7 @@ void StreamHierarchy::read(FileFormatVersion aVersion) const uint32_t lenSthInHierarchy1 = ((int)aVersion & 0x08) ? ds.readUint32() : ds.readUint16(); - spdlog::trace("lenSthInHierarchy1 = {}", lenSthInHierarchy1); + mCtx.mLogger.trace("lenSthInHierarchy1 = {}", lenSthInHierarchy1); for(size_t i = 0u; i < lenSthInHierarchy1; ++i) { @@ -88,7 +88,7 @@ void StreamHierarchy::read(FileFormatVersion aVersion) const uint16_t lenSomeHierarchyBase = ds.readUint16(); - spdlog::trace("lenSomeHierarchyBase = {}", lenSomeHierarchyBase); + mCtx.mLogger.trace("lenSomeHierarchyBase = {}", lenSomeHierarchyBase); for(size_t i = 0u; i < lenSomeHierarchyBase; ++i) { @@ -105,6 +105,6 @@ void StreamHierarchy::read(FileFormatVersion aVersion) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamLibrary.cpp b/src/Streams/StreamLibrary.cpp index fbd8541..fae2e73 100644 --- a/src/Streams/StreamLibrary.cpp +++ b/src/Streams/StreamLibrary.cpp @@ -22,7 +22,7 @@ void StreamLibrary::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -45,14 +45,14 @@ void StreamLibrary::read(FileFormatVersion aVersion) // write_data_to_file(buffer, sizeof(buffer)); ds.padRest(startOffset, 32, false); - spdlog::trace("introduction = {}", introduction); + mCtx.mLogger.trace("introduction = {}", introduction); // I saw versions: // 2.0; 3.2; 3.3 const uint16_t versionMajor = ds.readUint16(); const uint16_t versionMinor = ds.readUint16(); - spdlog::trace("version = {}.{}", versionMajor, versionMinor); + mCtx.mLogger.trace("version = {}.{}", versionMajor, versionMinor); createDate = static_cast(ds.readUint32()); modifyDate = static_cast(ds.readUint32()); @@ -64,7 +64,7 @@ void StreamLibrary::read(FileFormatVersion aVersion) // is there some correlation? const uint16_t textFontLen = ds.readUint16(); - spdlog::trace("textFontLen = {}", textFontLen); + mCtx.mLogger.trace("textFontLen = {}", textFontLen); if(textFontLen == 0u) { @@ -80,13 +80,13 @@ void StreamLibrary::read(FileFormatVersion aVersion) const uint16_t someLen = ds.readUint16(); - spdlog::trace("someLen = {}", someLen); + mCtx.mLogger.trace("someLen = {}", someLen); for(int i = 0; i < someLen; ++i) { const uint16_t someData = ds.readUint16(); - spdlog::trace("someData [{}] = {}", i, someData); + mCtx.mLogger.trace("someData [{}] = {}", i, someData); } ds.printUnknownData(4, getMethodName(this, __func__) + ": 2.0"); @@ -100,7 +100,7 @@ void StreamLibrary::read(FileFormatVersion aVersion) { strLstPartField.push_back(ds.readStringLenZeroTerm()); - spdlog::trace("strLstPartField[{}] = {}", i, strLstPartField.back()); + mCtx.mLogger.trace("strLstPartField[{}] = {}", i, strLstPartField.back()); } pageSettings.read(); @@ -117,18 +117,18 @@ void StreamLibrary::read(FileFormatVersion aVersion) strLstLen = ds.readUint32(); } - spdlog::trace("strLstLen = {}", strLstLen); + mCtx.mLogger.trace("strLstLen = {}", strLstLen); for(size_t i = 0u; i < strLstLen; ++i) { strLst.push_back(ds.readStringLenZeroTerm()); - spdlog::trace("strLst[{}] = {}", i, strLst.back()); + mCtx.mLogger.trace("strLst[{}] = {}", i, strLst.back()); } const uint16_t aliasLstLen = ds.readUint16(); - spdlog::trace("aliasLstLen = {}", aliasLstLen); + mCtx.mLogger.trace("aliasLstLen = {}", aliasLstLen); for(size_t i = 0u; i < aliasLstLen; ++i) { @@ -136,14 +136,14 @@ void StreamLibrary::read(FileFormatVersion aVersion) const std::string package = ds.readStringLenZeroTerm(); partAliases.push_back(std::make_pair(alias, package)); - spdlog::trace("partAliases[{}] = (alias = {}, package = {})", i, alias, package); + mCtx.mLogger.trace("partAliases[{}] = (alias = {}, package = {})", i, alias, package); } if(mCtx.mFileType == FileType::Schematic) { ds.printUnknownData(8, getMethodName(this, __func__) + ": 5"); std::string schematicName = ds.readStringLenZeroTerm(); - spdlog::trace("schematicName = {}", schematicName); + mCtx.mLogger.trace("schematicName = {}", schematicName); } if(!ds.isEoF()) @@ -151,6 +151,6 @@ void StreamLibrary::read(FileFormatVersion aVersion) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamNetBundleMapData.cpp b/src/Streams/StreamNetBundleMapData.cpp index 1de4af2..e7675f6 100644 --- a/src/Streams/StreamNetBundleMapData.cpp +++ b/src/Streams/StreamNetBundleMapData.cpp @@ -15,20 +15,20 @@ void StreamNetBundleMapData::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); ds.printUnknownData(2, fmt::format("{}: 0", getMethodName(this, __func__))); uint16_t number_groups = ds.readUint16(); - spdlog::trace("number_groups = {}", number_groups); + mCtx.mLogger.trace("number_groups = {}", number_groups); for(size_t i = 0U; i < number_groups; ++i) { - spdlog::trace("[{}]:", i); + mCtx.mLogger.trace("[{}]:", i); std::string group_name = ds.readStringLenZeroTerm(); - spdlog::trace("group_name = {}:", group_name); + mCtx.mLogger.trace("group_name = {}:", group_name); // ---------------------------------------- @@ -53,12 +53,12 @@ void StreamNetBundleMapData::read(FileFormatVersion /* aVersion */) for(size_t j = 0U; j < number_group_elements; ++j) { std::string element_name = ds.readStringLenZeroTerm(); - spdlog::trace(" [{}]: element_name = {}", j, element_name); + mCtx.mLogger.trace(" [{}]: element_name = {}", j, element_name); // @todo 0x01 is probably a scalar wire // 0x02 is probably a bus uint16_t wire_type = ds.readUint16(); - spdlog::trace(" wire_type = {}", wire_type == 0x01 ? "Scalar" : wire_type == 0x02 ? "Bus" : "Unknown"); + mCtx.mLogger.trace(" wire_type = {}", wire_type == 0x01 ? "Scalar" : wire_type == 0x02 ? "Bus" : "Unknown"); } } @@ -67,6 +67,6 @@ void StreamNetBundleMapData::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamPackage.cpp b/src/Streams/StreamPackage.cpp index 7b095f6..f253ef3 100644 --- a/src/Streams/StreamPackage.cpp +++ b/src/Streams/StreamPackage.cpp @@ -14,11 +14,11 @@ void StreamPackage::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); const uint16_t lenProperties = ds.readUint16(); - spdlog::trace("lenProperties = {}", lenProperties); + mCtx.mLogger.trace("lenProperties = {}", lenProperties); for(size_t i = 0u; i < lenProperties; ++i) { @@ -26,7 +26,7 @@ void StreamPackage::read(FileFormatVersion /* aVersion */) const uint16_t lenPrimitives = ds.readUint16(); - spdlog::trace("lenPrimitives = {}", lenPrimitives); + mCtx.mLogger.trace("lenPrimitives = {}", lenPrimitives); for(size_t i = 0u; i < lenPrimitives; ++i) { @@ -41,6 +41,6 @@ void StreamPackage::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamPackagesDirectory.cpp b/src/Streams/StreamPackagesDirectory.cpp index e1f362c..4a7849b 100644 --- a/src/Streams/StreamPackagesDirectory.cpp +++ b/src/Streams/StreamPackagesDirectory.cpp @@ -12,7 +12,7 @@ void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -28,7 +28,7 @@ void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */) if(item.componentType != ComponentType::Package) { - spdlog::warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); + mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); } // @todo This changes with the version of the file format, so maybe it contains @@ -38,7 +38,7 @@ void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I obsereved in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -52,7 +52,7 @@ void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); @@ -67,6 +67,6 @@ void StreamPackagesDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamPage.cpp b/src/Streams/StreamPage.cpp index 428b6d4..e38d20a 100644 --- a/src/Streams/StreamPage.cpp +++ b/src/Streams/StreamPage.cpp @@ -15,7 +15,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -28,17 +28,17 @@ void StreamPage::read(FileFormatVersion /* aVersion */) name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); pageSize = ds.readStringLenZeroTerm(); - spdlog::trace("pageSize = {}", pageSize); + mCtx.mLogger.trace("pageSize = {}", pageSize); pageSettings.read(); const uint16_t lenTitleBlocks = ds.readUint16(); - spdlog::trace("lenTitleBlocks = {}", lenTitleBlocks); + mCtx.mLogger.trace("lenTitleBlocks = {}", lenTitleBlocks); for(size_t i = 0u; i < lenTitleBlocks; ++i) { @@ -47,7 +47,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenT0x34s = ds.readUint16(); - spdlog::trace("lenT0x34s = {}", lenT0x34s); + mCtx.mLogger.trace("lenT0x34s = {}", lenT0x34s); for(size_t i = 0u; i < lenT0x34s; ++i) { @@ -56,7 +56,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenT0x35s = ds.readUint16(); - spdlog::trace("lenT0x35s = {}", lenT0x35s); + mCtx.mLogger.trace("lenT0x35s = {}", lenT0x35s); for(size_t i = 0u; i < lenT0x35s; ++i) { @@ -65,7 +65,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenB = ds.readUint16(); - spdlog::trace("lenB = {}", lenB); + mCtx.mLogger.trace("lenB = {}", lenB); for(size_t i = 0; i < lenB; ++i) { @@ -73,13 +73,13 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const std::string net = ds.readStringLenZeroTerm(); const uint32_t id = ds.readUint32(); - spdlog::trace("net = {}", net); - spdlog::trace("id = {}", id); + mCtx.mLogger.trace("net = {}", net); + mCtx.mLogger.trace("id = {}", id); } const uint16_t lenWires = ds.readUint16(); - spdlog::trace("lenWires = {}", lenWires); + mCtx.mLogger.trace("lenWires = {}", lenWires); for(size_t i = 0u; i < lenWires; ++i) { @@ -88,7 +88,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenPartInsts = ds.readUint16(); - spdlog::trace("lenPartInsts = {}", lenPartInsts); + mCtx.mLogger.trace("lenPartInsts = {}", lenPartInsts); for(size_t i = 0u; i < lenPartInsts; ++i) { @@ -97,7 +97,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenPorts = ds.readUint16(); - spdlog::trace("lenPorts = {}", lenPorts); + mCtx.mLogger.trace("lenPorts = {}", lenPorts); for(size_t i = 0u; i < lenPorts; ++i) { @@ -106,7 +106,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenGlobals = ds.readUint16(); - spdlog::trace("lenGlobals = {}", lenGlobals); + mCtx.mLogger.trace("lenGlobals = {}", lenGlobals); for(size_t i = 0u; i < lenGlobals; ++i) { @@ -117,7 +117,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenOffPageConnectors = ds.readUint16(); - spdlog::trace("lenOffPageConnectors = {}", lenOffPageConnectors); + mCtx.mLogger.trace("lenOffPageConnectors = {}", lenOffPageConnectors); for(size_t i = 0u; i < lenOffPageConnectors; ++i) { @@ -128,7 +128,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenERCSymbolInsts = ds.readUint16(); - spdlog::trace("lenERCSymbolInsts = {}", lenERCSymbolInsts); + mCtx.mLogger.trace("lenERCSymbolInsts = {}", lenERCSymbolInsts); for(size_t i = 0u; i < lenERCSymbolInsts; ++i) { @@ -137,7 +137,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenBusEntries = ds.readUint16(); - spdlog::trace("lenBusEntries = {}", lenBusEntries); + mCtx.mLogger.trace("lenBusEntries = {}", lenBusEntries); for(size_t i = 0u; i < lenBusEntries; ++i) { @@ -146,7 +146,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t lenGraphicInsts = ds.readUint16(); - spdlog::trace("lenGraphicInsts = {}", lenGraphicInsts); + mCtx.mLogger.trace("lenGraphicInsts = {}", lenGraphicInsts); for(size_t i = 0u; i < lenGraphicInsts; ++i) { @@ -155,7 +155,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const uint16_t len10 = ds.readUint16(); - spdlog::trace("len10 = {}", len10); + mCtx.mLogger.trace("len10 = {}", len10); for(size_t i = 0u; i < len10; ++i) { @@ -163,13 +163,13 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const auto s = parser.readStructure(); if(s) { - spdlog::debug("VERIFYING Page Structure10 is {}", NAMEOF_TYPE_RTTI(*s)); + mCtx.mLogger.debug("VERIFYING Page Structure10 is {}", NAMEOF_TYPE_RTTI(*s)); } } const uint16_t len11 = ds.readUint16(); - spdlog::trace("len11 = {}", len11); + mCtx.mLogger.trace("len11 = {}", len11); for(size_t i = 0u; i < len11; ++i) { @@ -177,7 +177,7 @@ void StreamPage::read(FileFormatVersion /* aVersion */) const auto s = parser.readStructure(); if(s) { - spdlog::debug("VERIFYING Page Structure11 is {}", NAMEOF_TYPE_RTTI(*s)); + mCtx.mLogger.debug("VERIFYING Page Structure11 is {}", NAMEOF_TYPE_RTTI(*s)); } } @@ -190,6 +190,6 @@ void StreamPage::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamPartsDirectory.cpp b/src/Streams/StreamPartsDirectory.cpp index 06f7d0b..aa4002a 100644 --- a/src/Streams/StreamPartsDirectory.cpp +++ b/src/Streams/StreamPartsDirectory.cpp @@ -13,7 +13,7 @@ void StreamPartsDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -29,7 +29,7 @@ void StreamPartsDirectory::read(FileFormatVersion /* aVersion */) if(item.componentType != ComponentType::Part) { - spdlog::warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); + mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); } // @todo This changes with the version of the file format, so maybe it contains @@ -39,7 +39,7 @@ void StreamPartsDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I obsereved in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -53,7 +53,7 @@ void StreamPartsDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); @@ -68,6 +68,6 @@ void StreamPartsDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamSchematic.cpp b/src/Streams/StreamSchematic.cpp index 48bab78..dcb3d02 100644 --- a/src/Streams/StreamSchematic.cpp +++ b/src/Streams/StreamSchematic.cpp @@ -14,7 +14,7 @@ void StreamSchematic::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -31,23 +31,23 @@ void StreamSchematic::read(FileFormatVersion /* aVersion */) const std::string schematic_name = ds.readStringLenZeroTerm(); - spdlog::trace("schematic_name = {}", schematic_name); + mCtx.mLogger.trace("schematic_name = {}", schematic_name); ds.printUnknownData(4, getMethodName(this, __func__) + ": 1"); const uint16_t schematicPages = ds.readUint16(); - spdlog::trace("schematicPages = {}", schematicPages); + mCtx.mLogger.trace("schematicPages = {}", schematicPages); for(size_t i = 0u; i < schematicPages; ++i) { const std::string page_name = ds.readStringLenZeroTerm(); - spdlog::trace("page_name = {}", page_name); + mCtx.mLogger.trace("page_name = {}", page_name); } const uint16_t len = ds.readUint16(); - spdlog::trace("len = {}", len); + mCtx.mLogger.trace("len = {}", len); for(size_t i = 0u; i < len; ++i) { @@ -56,7 +56,7 @@ void StreamSchematic::read(FileFormatVersion /* aVersion */) const uint16_t len2 = ds.readUint16(); - spdlog::trace("len2 = {}", len2); + mCtx.mLogger.trace("len2 = {}", len2); for(size_t i = 0u; i < len2; ++i) { @@ -70,6 +70,6 @@ void StreamSchematic::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamSymbol.cpp b/src/Streams/StreamSymbol.cpp index ff44b93..30ed41e 100644 --- a/src/Streams/StreamSymbol.cpp +++ b/src/Streams/StreamSymbol.cpp @@ -14,7 +14,7 @@ void StreamSymbol::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); symbol = dynamic_pointer_cast(parser.readStructure()); @@ -23,6 +23,6 @@ void StreamSymbol::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamSymbolsDirectory.cpp b/src/Streams/StreamSymbolsDirectory.cpp index e47346a..525cd34 100644 --- a/src/Streams/StreamSymbolsDirectory.cpp +++ b/src/Streams/StreamSymbolsDirectory.cpp @@ -14,7 +14,7 @@ void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -40,7 +40,7 @@ void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */) const auto result_it = std::find(expected_types.cbegin(), expected_types.cend(), item.componentType); if(result_it == expected_types.cend()) { - spdlog::warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); + mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); } // @todo This changes with the version of the file format, so maybe it contains @@ -50,7 +50,7 @@ void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I obsereved in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -64,7 +64,7 @@ void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); @@ -79,6 +79,6 @@ void StreamSymbolsDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamType.cpp b/src/Streams/StreamType.cpp index 8f73b32..690777e 100644 --- a/src/Streams/StreamType.cpp +++ b/src/Streams/StreamType.cpp @@ -12,7 +12,7 @@ void StreamType::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); // File can be completely empty (size of 0 Byte) while(!ds.isEoF()) @@ -30,6 +30,6 @@ void StreamType::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Streams/StreamViewsDirectory.cpp b/src/Streams/StreamViewsDirectory.cpp index 303a883..06c27b2 100644 --- a/src/Streams/StreamViewsDirectory.cpp +++ b/src/Streams/StreamViewsDirectory.cpp @@ -13,7 +13,7 @@ void StreamViewsDirectory::read(FileFormatVersion /* aVersion */) { auto& ds = mCtx.mDs; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); lastModifiedDate = static_cast(ds.readUint32()); @@ -29,7 +29,7 @@ void StreamViewsDirectory::read(FileFormatVersion /* aVersion */) if(item.componentType != ComponentType::View) { - spdlog::warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); + mCtx.mLogger.warn("{}: Unexpected ComponentType `{}`", __func__, ::to_string(item.componentType)); } // @todo This changes with the version of the file format, so maybe it contains @@ -39,7 +39,7 @@ void StreamViewsDirectory::read(FileFormatVersion /* aVersion */) // @todo Just a guess that this is the version but's highly likely item.fileFormatVersion = ds.readUint16(); - spdlog::trace("fileFormatVersion = {}", item.fileFormatVersion); + mCtx.mLogger.trace("fileFormatVersion = {}", item.fileFormatVersion); // Known versions that I obsereved in different files // 471 in 17.4-2019 S012 (3898062) [10/18/202] @@ -53,7 +53,7 @@ void StreamViewsDirectory::read(FileFormatVersion /* aVersion */) if(!std::any_of(knownFileVersions.begin(), knownFileVersions.end(), [&](unsigned version){ return version == item.fileFormatVersion; })) { - spdlog::warn("Unexpected File Version {}", item.fileFormatVersion); + mCtx.mLogger.warn("Unexpected File Version {}", item.fileFormatVersion); } item.timezone = ds.readInt16(); @@ -68,6 +68,6 @@ void StreamViewsDirectory::read(FileFormatVersion /* aVersion */) throw std::runtime_error("Expected EoF but did not reach it!"); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::info(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.info(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructAlias.cpp b/src/Structures/StructAlias.cpp index eb613bf..30afc7d 100644 --- a/src/Structures/StructAlias.cpp +++ b/src/Structures/StructAlias.cpp @@ -16,7 +16,7 @@ void StructAlias::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -29,29 +29,29 @@ void StructAlias::read(FileFormatVersion /* aVersion */) locX = ds.readInt32(); locY = ds.readInt32(); - spdlog::trace("locX = {}", locX); - spdlog::trace("locY = {}", locY); + mCtx.mLogger.trace("locX = {}", locX); + mCtx.mLogger.trace("locY = {}", locY); color = ToColor(ds.readUint32()); - spdlog::trace("color = {}", ::to_string(color)); + mCtx.mLogger.trace("color = {}", ::to_string(color)); rotation = ToRotation(ds.readUint32()); // @todo Why is it 4 byte? Probably increase Rotation size - spdlog::trace("rotation = {}", ::to_string(rotation)); + mCtx.mLogger.trace("rotation = {}", ::to_string(rotation)); uint32_t textFontIdx = ds.readUint32(); - spdlog::trace("Alias fontIdx = {}", textFontIdx); + mCtx.mLogger.trace("Alias fontIdx = {}", textFontIdx); name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); localFutureLst.checkpoint(); localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructBookMarkSymbolInst.cpp b/src/Structures/StructBookMarkSymbolInst.cpp index 7a0f1e5..ab3aa71 100644 --- a/src/Structures/StructBookMarkSymbolInst.cpp +++ b/src/Structures/StructBookMarkSymbolInst.cpp @@ -16,7 +16,7 @@ void StructBookMarkSymbolInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -26,6 +26,6 @@ void StructBookMarkSymbolInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructBusEntry.cpp b/src/Structures/StructBusEntry.cpp index f0bd989..5a502b0 100644 --- a/src/Structures/StructBusEntry.cpp +++ b/src/Structures/StructBusEntry.cpp @@ -16,7 +16,7 @@ void StructBusEntry::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -28,19 +28,19 @@ void StructBusEntry::read(FileFormatVersion /* aVersion */) color = ToColor(ds.readUint32()); - spdlog::trace("color = {}", ::to_string(color)); + mCtx.mLogger.trace("color = {}", ::to_string(color)); startX = ds.readInt32(); startY = ds.readInt32(); - spdlog::trace("startX = {}", startX); - spdlog::trace("startY = {}", startY); + mCtx.mLogger.trace("startX = {}", startX); + mCtx.mLogger.trace("startY = {}", startY); endX = ds.readInt32(); endY = ds.readInt32(); - spdlog::trace("endX = {}", endX); - spdlog::trace("endY = {}", endY); + mCtx.mLogger.trace("endX = {}", endX); + mCtx.mLogger.trace("endY = {}", endY); ds.printUnknownData(8, getMethodName(this, __func__) + ": 0"); @@ -48,6 +48,6 @@ void StructBusEntry::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructERCSymbol.cpp b/src/Structures/StructERCSymbol.cpp index 65e5923..1b94642 100644 --- a/src/Structures/StructERCSymbol.cpp +++ b/src/Structures/StructERCSymbol.cpp @@ -17,7 +17,7 @@ void StructERCSymbol::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -46,6 +46,6 @@ void StructERCSymbol::read(FileFormatVersion aVersion) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructERCSymbolInst.cpp b/src/Structures/StructERCSymbolInst.cpp index 633e750..df984a3 100644 --- a/src/Structures/StructERCSymbolInst.cpp +++ b/src/Structures/StructERCSymbolInst.cpp @@ -16,7 +16,7 @@ void StructERCSymbolInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -28,14 +28,14 @@ void StructERCSymbolInst::read(FileFormatVersion /* aVersion */) s1 = ds.readStringLenZeroTerm(); s2 = ds.readStringLenZeroTerm(); - spdlog::trace("s0 = {}", s0); - spdlog::trace("s1 = {}", s1); - spdlog::trace("s2 = {}", s2); + mCtx.mLogger.trace("s0 = {}", s0); + mCtx.mLogger.trace("s1 = {}", s1); + mCtx.mLogger.trace("s2 = {}", s2); localFutureLst.checkpoint(); localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGeneralProperties.cpp b/src/Structures/StructGeneralProperties.cpp index 070cbdb..0deac88 100644 --- a/src/Structures/StructGeneralProperties.cpp +++ b/src/Structures/StructGeneralProperties.cpp @@ -1,62 +1,62 @@ -#include -#include -#include - -#include -#include - -#include "Enums/LineStyle.hpp" -#include "Enums/LineWidth.hpp" -#include "FutureData.hpp" -#include "General.hpp" -#include "Structures/StructGeneralProperties.hpp" - - -void StructGeneralProperties::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - implementationPath = ds.readStringLenZeroTerm(); - - spdlog::trace("implementationPath = {}", implementationPath); - - implementation = ds.readStringLenZeroTerm(); - - spdlog::trace("implementation = {}", implementation); - - refDes = ds.readStringLenZeroTerm(); - - spdlog::trace("refDes = {}", refDes); - - partValue = ds.readStringLenZeroTerm(); - - spdlog::trace("partValue = {}", partValue); - - const uint8_t properties = ds.readUint8(); - - spdlog::trace("properties = {}", properties); - - // Expect that upper bits are unused => 00xx xxxxb - if((properties & 0xc0) != 0x00) - { - throw std::runtime_error(fmt::format("Expected 00xx xxxxb but got 0x{:02x}", - properties & 0xc0)); - } - - const uint8_t pinProperties = properties & 0x07; // Get bits 2 down to 0 - const uint8_t implementationType = (properties >> 3) & 0x07; // Get bits 5 down to 3 - - pinNameVisible = static_cast((pinProperties & 0x01) >> 0); // Bit 0 - pinNameRotate = static_cast((pinProperties & 0x02) >> 1); // Bit 1 - pinNumberVisible = !static_cast((pinProperties & 0x04) >> 2); // Bit 2 - Note that this bit is inverted - - this->implementationType = ToImplementationType(implementationType); - - // @todo Maybe merge with bit field above? - ds.assumeData({0}, getMethodName(this, __func__) + ": 0"); - - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); +#include +#include +#include + +#include +#include + +#include "Enums/LineStyle.hpp" +#include "Enums/LineWidth.hpp" +#include "FutureData.hpp" +#include "General.hpp" +#include "Structures/StructGeneralProperties.hpp" + + +void StructGeneralProperties::read(FileFormatVersion /* aVersion */) +{ + auto& ds = mCtx.mDs; + + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + + implementationPath = ds.readStringLenZeroTerm(); + + mCtx.mLogger.trace("implementationPath = {}", implementationPath); + + implementation = ds.readStringLenZeroTerm(); + + mCtx.mLogger.trace("implementation = {}", implementation); + + refDes = ds.readStringLenZeroTerm(); + + mCtx.mLogger.trace("refDes = {}", refDes); + + partValue = ds.readStringLenZeroTerm(); + + mCtx.mLogger.trace("partValue = {}", partValue); + + const uint8_t properties = ds.readUint8(); + + mCtx.mLogger.trace("properties = {}", properties); + + // Expect that upper bits are unused => 00xx xxxxb + if((properties & 0xc0) != 0x00) + { + throw std::runtime_error(fmt::format("Expected 00xx xxxxb but got 0x{:02x}", + properties & 0xc0)); + } + + const uint8_t pinProperties = properties & 0x07; // Get bits 2 down to 0 + const uint8_t implementationType = (properties >> 3) & 0x07; // Get bits 5 down to 3 + + pinNameVisible = static_cast((pinProperties & 0x01) >> 0); // Bit 0 + pinNameRotate = static_cast((pinProperties & 0x02) >> 1); // Bit 1 + pinNumberVisible = !static_cast((pinProperties & 0x04) >> 2); // Bit 2 - Note that this bit is inverted + + this->implementationType = ToImplementationType(implementationType); + + // @todo Maybe merge with bit field above? + ds.assumeData({0}, getMethodName(this, __func__) + ": 0"); + + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGlobal.cpp b/src/Structures/StructGlobal.cpp index 92602f6..761163b 100644 --- a/src/Structures/StructGlobal.cpp +++ b/src/Structures/StructGlobal.cpp @@ -16,7 +16,7 @@ void StructGlobal::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -26,6 +26,6 @@ void StructGlobal::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGlobalSymbol.cpp b/src/Structures/StructGlobalSymbol.cpp index 73ff69b..8d3f830 100644 --- a/src/Structures/StructGlobalSymbol.cpp +++ b/src/Structures/StructGlobalSymbol.cpp @@ -15,7 +15,7 @@ void StructGlobalSymbol::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -29,7 +29,7 @@ void StructGlobalSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolPins = ds.readUint16(); - spdlog::trace("lenSymbolPins = {}", lenSymbolPins); + mCtx.mLogger.trace("lenSymbolPins = {}", lenSymbolPins); for(size_t i = 0u; i < lenSymbolPins; ++i) { @@ -38,7 +38,7 @@ void StructGlobalSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0u; i < lenSymbolDisplayProps; ++i) { @@ -49,6 +49,6 @@ void StructGlobalSymbol::read(FileFormatVersion aVersion) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicArcInst.cpp b/src/Structures/StructGraphicArcInst.cpp index 5b37105..72298a8 100644 --- a/src/Structures/StructGraphicArcInst.cpp +++ b/src/Structures/StructGraphicArcInst.cpp @@ -15,7 +15,7 @@ void StructGraphicArcInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicArcInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicBezierInst.cpp b/src/Structures/StructGraphicBezierInst.cpp index def399f..d8ce6f2 100644 --- a/src/Structures/StructGraphicBezierInst.cpp +++ b/src/Structures/StructGraphicBezierInst.cpp @@ -15,7 +15,7 @@ void StructGraphicBezierInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicBezierInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicBitMapInst.cpp b/src/Structures/StructGraphicBitMapInst.cpp index 7434221..5da3770 100644 --- a/src/Structures/StructGraphicBitMapInst.cpp +++ b/src/Structures/StructGraphicBitMapInst.cpp @@ -15,7 +15,7 @@ void StructGraphicBitMapInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicBitMapInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicBoxInst.cpp b/src/Structures/StructGraphicBoxInst.cpp index b226c15..34df0be 100644 --- a/src/Structures/StructGraphicBoxInst.cpp +++ b/src/Structures/StructGraphicBoxInst.cpp @@ -16,7 +16,7 @@ void StructGraphicBoxInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -26,6 +26,6 @@ void StructGraphicBoxInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicCommentTextInst.cpp b/src/Structures/StructGraphicCommentTextInst.cpp index de21f06..94aa1bb 100644 --- a/src/Structures/StructGraphicCommentTextInst.cpp +++ b/src/Structures/StructGraphicCommentTextInst.cpp @@ -15,7 +15,7 @@ void StructGraphicCommentTextInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicCommentTextInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicEllipseInst.cpp b/src/Structures/StructGraphicEllipseInst.cpp index 2930a80..d886150 100644 --- a/src/Structures/StructGraphicEllipseInst.cpp +++ b/src/Structures/StructGraphicEllipseInst.cpp @@ -15,7 +15,7 @@ void StructGraphicEllipseInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicEllipseInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicInst.cpp b/src/Structures/StructGraphicInst.cpp index c5668ae..392f23e 100644 --- a/src/Structures/StructGraphicInst.cpp +++ b/src/Structures/StructGraphicInst.cpp @@ -23,33 +23,33 @@ void StructGraphicInst::read(FutureDataLst& mLocalFutureLst, FileFormatVersion / name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); dbId = ds.readUint32(); - spdlog::trace("dbId = {}", dbId); + mCtx.mLogger.trace("dbId = {}", dbId); locY = ds.readInt16(); locX = ds.readInt16(); - spdlog::trace("locX = {}", locX); - spdlog::trace("locY = {}", locY); + mCtx.mLogger.trace("locX = {}", locX); + mCtx.mLogger.trace("locY = {}", locY); y2 = ds.readInt16(); x2 = ds.readInt16(); - spdlog::trace("y2 = {}", y2); - spdlog::trace("x2 = {}", x2); + mCtx.mLogger.trace("y2 = {}", y2); + mCtx.mLogger.trace("x2 = {}", x2); x1 = ds.readInt16(); y1 = ds.readInt16(); - spdlog::trace("x1 = {}", x1); - spdlog::trace("y1 = {}", y1); + mCtx.mLogger.trace("x1 = {}", x1); + mCtx.mLogger.trace("y1 = {}", y1); color = ToColor(ds.readUint8()); - spdlog::trace("color = {}", ::to_string(color)); + mCtx.mLogger.trace("color = {}", ::to_string(color)); ds.printUnknownData(1, getMethodName(this, __func__) + ": StructGraphicInst - 1"); ds.printUnknownData(1, getMethodName(this, __func__) + ": StructGraphicInst - 2"); // @todo Probably structure ID of current structure @@ -57,7 +57,7 @@ void StructGraphicInst::read(FutureDataLst& mLocalFutureLst, FileFormatVersion / const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0; i < lenSymbolDisplayProps; ++i) { @@ -71,7 +71,7 @@ void StructGraphicInst::read(FutureDataLst& mLocalFutureLst, FileFormatVersion / // StructPort -> StructPortSymbol const uint8_t unknownFlag = ds.readUint8(); - spdlog::trace("unknownFlag = {}", unknownFlag); + mCtx.mLogger.trace("unknownFlag = {}", unknownFlag); // @todo Add some sanity check switch(unknownFlag) diff --git a/src/Structures/StructGraphicLineInst.cpp b/src/Structures/StructGraphicLineInst.cpp index f18c465..b8ae64c 100644 --- a/src/Structures/StructGraphicLineInst.cpp +++ b/src/Structures/StructGraphicLineInst.cpp @@ -15,7 +15,7 @@ void StructGraphicLineInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicLineInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicOleEmbedInst.cpp b/src/Structures/StructGraphicOleEmbedInst.cpp index b7f0ee5..ad82475 100644 --- a/src/Structures/StructGraphicOleEmbedInst.cpp +++ b/src/Structures/StructGraphicOleEmbedInst.cpp @@ -15,7 +15,7 @@ void StructGraphicOleEmbedInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicOleEmbedInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicPolygonInst.cpp b/src/Structures/StructGraphicPolygonInst.cpp index 7e02b2a..25e3e80 100644 --- a/src/Structures/StructGraphicPolygonInst.cpp +++ b/src/Structures/StructGraphicPolygonInst.cpp @@ -15,7 +15,7 @@ void StructGraphicPolygonInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicPolygonInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructGraphicPolylineInst.cpp b/src/Structures/StructGraphicPolylineInst.cpp index 3a5af5b..d630928 100644 --- a/src/Structures/StructGraphicPolylineInst.cpp +++ b/src/Structures/StructGraphicPolylineInst.cpp @@ -15,7 +15,7 @@ void StructGraphicPolylineInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructGraphicPolylineInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructHierarchicSymbol.cpp b/src/Structures/StructHierarchicSymbol.cpp index b375be6..80a453d 100644 --- a/src/Structures/StructHierarchicSymbol.cpp +++ b/src/Structures/StructHierarchicSymbol.cpp @@ -1,23 +1,23 @@ -#include -#include -#include - -#include - -#include "General.hpp" -#include "Structures/StructHierarchicSymbol.hpp" -#include "Structures/StructPrimitives.hpp" - - -void StructHierarchicSymbol::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - StructPrimitives primitives{mCtx}; - primitives.read(); - - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); +#include +#include +#include + +#include + +#include "General.hpp" +#include "Structures/StructHierarchicSymbol.hpp" +#include "Structures/StructPrimitives.hpp" + + +void StructHierarchicSymbol::read(FileFormatVersion /* aVersion */) +{ + auto& ds = mCtx.mDs; + + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + + StructPrimitives primitives{mCtx}; + primitives.read(); + + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructNetDbIdMapping.cpp b/src/Structures/StructNetDbIdMapping.cpp index f113297..dbea16b 100644 --- a/src/Structures/StructNetDbIdMapping.cpp +++ b/src/Structures/StructNetDbIdMapping.cpp @@ -15,7 +15,7 @@ void StructNetDbIdMapping::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -27,6 +27,6 @@ void StructNetDbIdMapping::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructOffPageConnector.cpp b/src/Structures/StructOffPageConnector.cpp index 14eb877..2295df2 100644 --- a/src/Structures/StructOffPageConnector.cpp +++ b/src/Structures/StructOffPageConnector.cpp @@ -15,7 +15,7 @@ void StructOffPageConnector::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -25,6 +25,6 @@ void StructOffPageConnector::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructOffPageSymbol.cpp b/src/Structures/StructOffPageSymbol.cpp index 0c7dcc2..1b78953 100644 --- a/src/Structures/StructOffPageSymbol.cpp +++ b/src/Structures/StructOffPageSymbol.cpp @@ -15,7 +15,7 @@ void StructOffPageSymbol::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -29,7 +29,7 @@ void StructOffPageSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolPins = ds.readUint16(); - spdlog::trace("lenSymbolPins = {}", lenSymbolPins); + mCtx.mLogger.trace("lenSymbolPins = {}", lenSymbolPins); for(size_t i = 0u; i < lenSymbolPins; ++i) { @@ -38,7 +38,7 @@ void StructOffPageSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0u; i < lenSymbolDisplayProps; ++i) { @@ -49,6 +49,6 @@ void StructOffPageSymbol::read(FileFormatVersion aVersion) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructPartInst.cpp b/src/Structures/StructPartInst.cpp index fa67dd5..72a57d7 100644 --- a/src/Structures/StructPartInst.cpp +++ b/src/Structures/StructPartInst.cpp @@ -20,7 +20,7 @@ void StructPartInst::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -34,25 +34,25 @@ void StructPartInst::read(FileFormatVersion /* aVersion */) const std::string pkgName = ds.readStringLenZeroTerm(); - spdlog::trace("pkgName = {}", pkgName); + mCtx.mLogger.trace("pkgName = {}", pkgName); const uint32_t dbId = ds.readUint32(); - spdlog::trace("dbId = {}", dbId); + mCtx.mLogger.trace("dbId = {}", dbId); ds.printUnknownData(8, getMethodName(this, __func__) + ": 1"); const int16_t locX = ds.readInt16(); const int16_t locY = ds.readInt16(); - spdlog::trace("locX = {}", locX); - spdlog::trace("locY = {}", locY); + mCtx.mLogger.trace("locX = {}", locX); + mCtx.mLogger.trace("locY = {}", locY); ds.printUnknownData(4, getMethodName(this, __func__) + ": 2"); const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0; i < lenSymbolDisplayProps; ++i) { @@ -65,13 +65,13 @@ void StructPartInst::read(FileFormatVersion /* aVersion */) const std::string reference = ds.readStringLenZeroTerm(); - spdlog::trace("reference = {}", reference); + mCtx.mLogger.trace("reference = {}", reference); ds.printUnknownData(14, getMethodName(this, __func__) + ": 4"); const uint16_t lenT0x10s = ds.readUint16(); - spdlog::trace("lenT0x10s = {}", lenT0x10s); + mCtx.mLogger.trace("lenT0x10s = {}", lenT0x10s); for(size_t i = 0u; i < lenT0x10s; ++i) { @@ -82,7 +82,7 @@ void StructPartInst::read(FileFormatVersion /* aVersion */) const std::string sth1 = ds.readStringLenZeroTerm(); // @todo needs verification - spdlog::trace("sth1 = {}", sth1); + mCtx.mLogger.trace("sth1 = {}", sth1); ds.printUnknownData(2, getMethodName(this, __func__) + ": 5"); @@ -90,6 +90,6 @@ void StructPartInst::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructPinIdxMapping.cpp b/src/Structures/StructPinIdxMapping.cpp index 46b107e..aabb97a 100644 --- a/src/Structures/StructPinIdxMapping.cpp +++ b/src/Structures/StructPinIdxMapping.cpp @@ -18,7 +18,7 @@ void StructPinIdxMapping::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -33,7 +33,7 @@ void StructPinIdxMapping::read(FileFormatVersion /* aVersion */) const uint16_t pinCount = ds.readUint16(); - spdlog::trace("pinCount = {}", pinCount); + mCtx.mLogger.trace("pinCount = {}", pinCount); // @todo Add to kaitai file i = 'Order' of pin // See OrCAD: 'Pin Properties' -> 'Order' @@ -54,7 +54,7 @@ void StructPinIdxMapping::read(FileFormatVersion /* aVersion */) { const int16_t strLen = ds.readInt16(); - spdlog::trace("strLen = {}", strLen); + mCtx.mLogger.trace("strLen = {}", strLen); continue; } @@ -72,17 +72,17 @@ void StructPinIdxMapping::read(FileFormatVersion /* aVersion */) // @note The special case of value 127 that represents an empty group pinGroup.push_back(bitMapPinGrpCfg & 0x7f); - spdlog::trace("pinIgnore = {}", pinIgnore.back()); + mCtx.mLogger.trace("pinIgnore = {}", pinIgnore.back()); const std::string strPinGroup = (pinGroup.back() != 127U) ? std::to_string(pinGroup.back()) : std::string{}; - spdlog::trace("pinGroup = {:>3}", strPinGroup); + mCtx.mLogger.trace("pinGroup = {:>3}", strPinGroup); } localFutureLst.checkpoint(); localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructPinShapeSymbol.cpp b/src/Structures/StructPinShapeSymbol.cpp index 9f05b5e..ed38c1c 100644 --- a/src/Structures/StructPinShapeSymbol.cpp +++ b/src/Structures/StructPinShapeSymbol.cpp @@ -16,7 +16,7 @@ void StructPinShapeSymbol::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -30,7 +30,7 @@ void StructPinShapeSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolPins = ds.readUint16(); - spdlog::trace("lenSymbolPins = {}", lenSymbolPins); + mCtx.mLogger.trace("lenSymbolPins = {}", lenSymbolPins); for(size_t i = 0u; i < lenSymbolPins; ++i) { @@ -39,7 +39,7 @@ void StructPinShapeSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0u; i < lenSymbolDisplayProps; ++i) { @@ -50,6 +50,6 @@ void StructPinShapeSymbol::read(FileFormatVersion aVersion) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructPort.cpp b/src/Structures/StructPort.cpp index b8daa13..9e4868e 100644 --- a/src/Structures/StructPort.cpp +++ b/src/Structures/StructPort.cpp @@ -15,7 +15,7 @@ void StructPort::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -29,6 +29,6 @@ void StructPort::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructPrimitives.cpp b/src/Structures/StructPrimitives.cpp index 6f2b2a3..8ed6efa 100644 --- a/src/Structures/StructPrimitives.cpp +++ b/src/Structures/StructPrimitives.cpp @@ -19,7 +19,7 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -31,11 +31,11 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); const std::string someStr791411 = ds.readStringLenZeroTerm(); - spdlog::trace("someStr791411 = {}", someStr791411); + mCtx.mLogger.trace("someStr791411 = {}", someStr791411); localFutureLst.checkpoint(); @@ -45,7 +45,7 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) const size_t nextCheckpointPos = localFutureLst.getNextCheckpointPos().value_or(0U); - spdlog::trace("len0 = {}", len0); + mCtx.mLogger.trace("len0 = {}", len0); for(size_t i = 0u; i < len0; ++i) { @@ -99,7 +99,7 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) const uint16_t lenSymbolPins = ds.readUint16(); - spdlog::trace("lenSymbolPins = {}", lenSymbolPins); + mCtx.mLogger.trace("lenSymbolPins = {}", lenSymbolPins); for(size_t i = 0u; i < lenSymbolPins; ++i) { @@ -122,7 +122,7 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0u; i < lenSymbolDisplayProps; ++i) { @@ -133,7 +133,7 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) if(!localFutureLst.empty()) { - spdlog::debug("Checking {} vs {}", localFutureLst.cbegin()->getStopOffset(), ds.getCurrentOffset()); + mCtx.mLogger.debug("Checking {} vs {}", localFutureLst.cbegin()->getStopOffset(), ds.getCurrentOffset()); if(localFutureLst.cbegin()->getStopOffset() > ds.getCurrentOffset()) { parser.readPreamble(); @@ -141,7 +141,7 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) for(std::size_t i{0U}; i < std::size_t{4U}; ++i) { const std::string s = ds.readStringLenZeroTerm(); - spdlog::trace("s[{}] = {}", i, s); + mCtx.mLogger.trace("s[{}] = {}", i, s); } if(localFutureLst.cbegin()->getStopOffset() > ds.getCurrentOffset()) @@ -155,6 +155,6 @@ void StructPrimitives::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructProperties.cpp b/src/Structures/StructProperties.cpp index 9090cca..6ef5d10 100644 --- a/src/Structures/StructProperties.cpp +++ b/src/Structures/StructProperties.cpp @@ -19,7 +19,7 @@ void StructProperties::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -31,11 +31,11 @@ void StructProperties::read(FileFormatVersion /* aVersion */) ref = ds.readStringLenZeroTerm(); - spdlog::trace("ref = {}", ref); + mCtx.mLogger.trace("ref = {}", ref); const std::string some_str = ds.readStringLenZeroTerm(); - spdlog::trace("some_str = {}", some_str); + mCtx.mLogger.trace("some_str = {}", some_str); localFutureLst.checkpoint(); @@ -45,7 +45,7 @@ void StructProperties::read(FileFormatVersion /* aVersion */) // 2 with (.Normal and .Convert) // @todo Add to obj - spdlog::trace("viewNumber = {}", viewNumber); + mCtx.mLogger.trace("viewNumber = {}", viewNumber); if(viewNumber == 1U) // Contains ".Normal" { @@ -58,15 +58,15 @@ void StructProperties::read(FileFormatVersion /* aVersion */) convertName = ds.readStringLenZeroTerm(); } - spdlog::trace("normalName = {}", normalName); - spdlog::trace("convertName = {}", convertName); + mCtx.mLogger.trace("normalName = {}", normalName); + mCtx.mLogger.trace("convertName = {}", convertName); if(viewNumber != 1U && viewNumber != 2U) { const std::string msg = fmt::format("viewNumber = {} but expected it to be 1 or 2!", viewNumber); - spdlog::error(msg); + mCtx.mLogger.error(msg); throw std::runtime_error(msg); } @@ -74,6 +74,6 @@ void StructProperties::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructSthInHierarchy1.cpp b/src/Structures/StructSthInHierarchy1.cpp index a45d8a5..4824cfc 100644 --- a/src/Structures/StructSthInHierarchy1.cpp +++ b/src/Structures/StructSthInHierarchy1.cpp @@ -15,7 +15,7 @@ void StructSthInHierarchy1::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -27,6 +27,6 @@ void StructSthInHierarchy1::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructSthInHierarchy2.cpp b/src/Structures/StructSthInHierarchy2.cpp index 6c07480..123b2b3 100644 --- a/src/Structures/StructSthInHierarchy2.cpp +++ b/src/Structures/StructSthInHierarchy2.cpp @@ -15,7 +15,7 @@ void StructSthInHierarchy2::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -27,6 +27,6 @@ void StructSthInHierarchy2::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructSthInHierarchy3.cpp b/src/Structures/StructSthInHierarchy3.cpp index e333fb6..e174455 100644 --- a/src/Structures/StructSthInHierarchy3.cpp +++ b/src/Structures/StructSthInHierarchy3.cpp @@ -15,7 +15,7 @@ void StructSthInHierarchy3::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -27,6 +27,6 @@ void StructSthInHierarchy3::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructSthInPages0.cpp b/src/Structures/StructSthInPages0.cpp index 0259ff6..f87690b 100644 --- a/src/Structures/StructSthInPages0.cpp +++ b/src/Structures/StructSthInPages0.cpp @@ -18,7 +18,7 @@ void StructSthInPages0::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -32,8 +32,8 @@ void StructSthInPages0::read(FileFormatVersion aVersion) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } @@ -42,25 +42,25 @@ void StructSthInPages0::read_raw(FileFormatVersion /* aVersion */, FutureDataLst auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); someStr0 = ds.readStringLenZeroTerm(); - spdlog::trace("someStr0 = {}", someStr0); + mCtx.mLogger.trace("someStr0 = {}", someStr0); aLocalFutureLst.checkpoint(); color = ToColor(ds.readUint32()); - spdlog::trace("color = {}", ::to_string(color)); + mCtx.mLogger.trace("color = {}", ::to_string(color)); const uint16_t lenPrimitives = ds.readUint16(); - spdlog::trace("lenPrimitives = {}", lenPrimitives); + mCtx.mLogger.trace("lenPrimitives = {}", lenPrimitives); for(size_t i = 0u; i < lenPrimitives; ++i) { @@ -97,22 +97,22 @@ void StructSthInPages0::read_raw(FileFormatVersion /* aVersion */, FutureDataLst // @todo Looks like it has one of {0, 8, 16 , 20} Byte in size // 16 Byte could be the coordinates with 4 byte each value // 20 Byte could be the 4 Byte coordinates with with some additional value - spdlog::trace("Calculating {} - {} == 8", aLocalFutureLst.cbegin()->getStopOffset(), ds.getCurrentOffset()); + mCtx.mLogger.trace("Calculating {} - {} == 8", aLocalFutureLst.cbegin()->getStopOffset(), ds.getCurrentOffset()); if(aLocalFutureLst.getNextCheckpointPos().value_or(0U) - ds.getCurrentOffset() == std::size_t{8U}) { - spdlog::trace("Probably coordinates"); + mCtx.mLogger.trace("Probably coordinates"); const int16_t x1 = ds.readInt16(); - spdlog::trace("x1 = {}", x1); + mCtx.mLogger.trace("x1 = {}", x1); const int16_t y1 = ds.readInt16(); - spdlog::trace("y1 = {}", y1); + mCtx.mLogger.trace("y1 = {}", y1); const int16_t x2 = ds.readInt16(); - spdlog::trace("x2 = {}", x2); + mCtx.mLogger.trace("x2 = {}", x2); const int16_t y2 = ds.readInt16(); - spdlog::trace("y2 = {}", y2); + mCtx.mLogger.trace("y2 = {}", y2); } else { @@ -121,5 +121,5 @@ void StructSthInPages0::read_raw(FileFormatVersion /* aVersion */, FutureDataLst aLocalFutureLst.checkpoint(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); } \ No newline at end of file diff --git a/src/Structures/StructSymbolBBox.cpp b/src/Structures/StructSymbolBBox.cpp index 3a2500a..8147f34 100644 --- a/src/Structures/StructSymbolBBox.cpp +++ b/src/Structures/StructSymbolBBox.cpp @@ -1,31 +1,31 @@ -#include -#include -#include - -#include -#include - -#include "General.hpp" -#include "Structures/StructSymbolBBox.hpp" - - -// @todo is probably trailing data and not a struct object! -void StructSymbolBBox::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - x1 = ds.readInt16(); - y1 = ds.readInt16(); - x2 = ds.readInt16(); - y2 = ds.readInt16(); - - // @todo not sure weather this belongs to the structure or should be outside of it - ds.printUnknownData(4, fmt::format("{}: 0", getMethodName(this, __func__))); - - // localFutureLst.readRestOfStructure(); - - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); +#include +#include +#include + +#include +#include + +#include "General.hpp" +#include "Structures/StructSymbolBBox.hpp" + + +// @todo is probably trailing data and not a struct object! +void StructSymbolBBox::read(FileFormatVersion /* aVersion */) +{ + auto& ds = mCtx.mDs; + + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + + x1 = ds.readInt16(); + y1 = ds.readInt16(); + x2 = ds.readInt16(); + y2 = ds.readInt16(); + + // @todo not sure weather this belongs to the structure or should be outside of it + ds.printUnknownData(4, fmt::format("{}: 0", getMethodName(this, __func__))); + + // localFutureLst.readRestOfStructure(); + + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructSymbolDisplayProp.cpp b/src/Structures/StructSymbolDisplayProp.cpp index 59f077f..1055d5b 100644 --- a/src/Structures/StructSymbolDisplayProp.cpp +++ b/src/Structures/StructSymbolDisplayProp.cpp @@ -16,7 +16,7 @@ void StructSymbolDisplayProp::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -35,7 +35,7 @@ void StructSymbolDisplayProp::read(FileFormatVersion /* aVersion */) { if(gLibrary->library) { - spdlog::trace("strLst Item = {}", gLibrary->library->strLst.at(nameIdx)); + mCtx.mLogger.trace("strLst Item = {}", gLibrary->library->strLst.at(nameIdx)); } } @@ -73,7 +73,7 @@ void StructSymbolDisplayProp::read(FileFormatVersion /* aVersion */) const std::string msg = fmt::format("{}: textFontIdx is out of range! Expected {} < {}!", __func__, textFontIdx, gLibrary->library->textFonts.size()); - spdlog::warn(msg); + mCtx.mLogger.warn(msg); // throw std::out_of_range(msg); } } @@ -98,6 +98,6 @@ void StructSymbolDisplayProp::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructSymbolPin.cpp b/src/Structures/StructSymbolPin.cpp index 290eb71..ae2e6e9 100644 --- a/src/Structures/StructSymbolPin.cpp +++ b/src/Structures/StructSymbolPin.cpp @@ -20,7 +20,7 @@ void StructSymbolPin::read(FileFormatVersion /* aVersion */) GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -37,7 +37,7 @@ void StructSymbolPin::read(FileFormatVersion /* aVersion */) hotptX = ds.readInt32(); hotptY = ds.readInt32(); - pinShape = ToPinShape(ds.readUint16()); + pinShape = ToPinShape(ds.readUint16(), mCtx.mLogger); ds.printUnknownData(2, getMethodName(this, __func__) + ": 0"); @@ -47,7 +47,7 @@ void StructSymbolPin::read(FileFormatVersion /* aVersion */) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0; i < lenSymbolDisplayProps; ++i) { @@ -58,6 +58,6 @@ void StructSymbolPin::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructT0x10.cpp b/src/Structures/StructT0x10.cpp index aa9fad1..19cf726 100644 --- a/src/Structures/StructT0x10.cpp +++ b/src/Structures/StructT0x10.cpp @@ -16,7 +16,7 @@ void StructT0x10::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -28,25 +28,25 @@ void StructT0x10::read(FileFormatVersion /* aVersion */) const uint16_t sth = ds.readUint16(); - spdlog::trace("sth = {}", sth); + mCtx.mLogger.trace("sth = {}", sth); const int16_t pointX = ds.readInt16(); const int16_t pointY = ds.readInt16(); - spdlog::trace("pointX = {}", pointX); - spdlog::trace("pointY = {}", pointY); + mCtx.mLogger.trace("pointX = {}", pointX); + mCtx.mLogger.trace("pointY = {}", pointY); const uint32_t maybeId = ds.readUint32(); - spdlog::trace("maybeId = {}", maybeId); + mCtx.mLogger.trace("maybeId = {}", maybeId); const uint32_t unkownInt = ds.readUint32(); - spdlog::trace("unkownInt = {}", unkownInt); + mCtx.mLogger.trace("unkownInt = {}", unkownInt); const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0; i < lenSymbolDisplayProps; ++i) { @@ -57,6 +57,6 @@ void StructT0x10::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructT0x1f.cpp b/src/Structures/StructT0x1f.cpp index e559e84..f3f1904 100644 --- a/src/Structures/StructT0x1f.cpp +++ b/src/Structures/StructT0x1f.cpp @@ -19,7 +19,7 @@ void StructT0x1f::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -31,25 +31,25 @@ void StructT0x1f::read(FileFormatVersion /* aVersion */) name = ds.readStringLenZeroTerm(); - spdlog::trace("name = {}", name); + mCtx.mLogger.trace("name = {}", name); std::string unknownStr0 = ds.readStringLenZeroTerm(); // @todo figure out - spdlog::trace("{}: unknownStr0 = {}", __func__, unknownStr0); + mCtx.mLogger.trace("{}: unknownStr0 = {}", __func__, unknownStr0); localFutureLst.checkpoint(); refDes = ds.readStringLenZeroTerm(); - spdlog::trace("refDes = {}", refDes); + mCtx.mLogger.trace("refDes = {}", refDes); std::string unknownStr1 = ds.readStringLenZeroTerm(); // @todo figure out - spdlog::trace("{}: unknownStr1 = {}", __func__, unknownStr1); + mCtx.mLogger.trace("{}: unknownStr1 = {}", __func__, unknownStr1); pcbFootprint = ds.readStringLenZeroTerm(); const uint16_t lenPinIdxMappings = ds.readUint16(); - spdlog::trace("lenPinIdxMappings = {}", lenPinIdxMappings); + mCtx.mLogger.trace("lenPinIdxMappings = {}", lenPinIdxMappings); for(size_t i = 0u; i < lenPinIdxMappings; ++i) { @@ -60,6 +60,6 @@ void StructT0x1f::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructT0x34.cpp b/src/Structures/StructT0x34.cpp index ef517fc..21b70c5 100644 --- a/src/Structures/StructT0x34.cpp +++ b/src/Structures/StructT0x34.cpp @@ -1,59 +1,59 @@ -#include -#include -#include - -#include - -#include "Enums/Structure.hpp" -#include "General.hpp" -#include "Structures/StructT0x34.hpp" - - -void StructT0x34::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - // @todo Try to activate this part - // FutureDataLst localFutureLst{mCtx}; - - // ds.auto_read_prefixes(Structure::T0x34, localFutureLst); - - // ds.readPreamble(); - - // @todo Looks like Primitive types! - // 0 Byte = structure id - // 1 - 4 Byte = struct len - // 5 - 8 Byte = zero vector - ds.printUnknownData(9, getMethodName(this, __func__) + ": 0"); - - id = ds.readUint32(); - - spdlog::trace("id = {}", id); - - const std::string unknownStr = ds.readStringLenZeroTerm(); - - spdlog::trace("unknownStr = {}", unknownStr); - - const uint32_t unknownInt = ds.readUint32(); - - spdlog::trace("unknownInt = {}", unknownInt); - - color = ToColor(ds.readUint32()); - - spdlog::trace("color = {}", ::to_string(color)); - - lineStyle = ToLineStyle(ds.readUint32()); - - spdlog::trace("lineStyle = {}", ::to_string(lineStyle)); - - lineWidth = ToLineWidth(ds.readUint32()); - - spdlog::trace("lineWidth = {}", ::to_string(lineWidth)); - - // localFutureLst.readRestOfStructure(); - - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); +#include +#include +#include + +#include + +#include "Enums/Structure.hpp" +#include "General.hpp" +#include "Structures/StructT0x34.hpp" + + +void StructT0x34::read(FileFormatVersion /* aVersion */) +{ + auto& ds = mCtx.mDs; + + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + + // @todo Try to activate this part + // FutureDataLst localFutureLst{mCtx}; + + // ds.auto_read_prefixes(Structure::T0x34, localFutureLst); + + // ds.readPreamble(); + + // @todo Looks like Primitive types! + // 0 Byte = structure id + // 1 - 4 Byte = struct len + // 5 - 8 Byte = zero vector + ds.printUnknownData(9, getMethodName(this, __func__) + ": 0"); + + id = ds.readUint32(); + + mCtx.mLogger.trace("id = {}", id); + + const std::string unknownStr = ds.readStringLenZeroTerm(); + + mCtx.mLogger.trace("unknownStr = {}", unknownStr); + + const uint32_t unknownInt = ds.readUint32(); + + mCtx.mLogger.trace("unknownInt = {}", unknownInt); + + color = ToColor(ds.readUint32()); + + mCtx.mLogger.trace("color = {}", ::to_string(color)); + + lineStyle = ToLineStyle(ds.readUint32()); + + mCtx.mLogger.trace("lineStyle = {}", ::to_string(lineStyle)); + + lineWidth = ToLineWidth(ds.readUint32()); + + mCtx.mLogger.trace("lineWidth = {}", ::to_string(lineWidth)); + + // localFutureLst.readRestOfStructure(); + + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructT0x35.cpp b/src/Structures/StructT0x35.cpp index fdc9f8c..cecf5ea 100644 --- a/src/Structures/StructT0x35.cpp +++ b/src/Structures/StructT0x35.cpp @@ -1,69 +1,69 @@ -#include -#include -#include - -#include - -#include "Enums/Structure.hpp" -#include "General.hpp" -#include "Structures/StructT0x35.hpp" - - -void StructT0x35::read(FileFormatVersion /* aVersion */) -{ - auto& ds = mCtx.mDs; - - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - - // @todo Try to activate this part - // FutureDataLst localFutureLst{mCtx}; - - // ds.auto_read_prefixes(Structure::T0x35, localFutureLst); - - // ds.readPreamble(); - - // @todo Looks like Primitive types! - // 0 Byte = structure id - // 1 - 4 Byte = struct len - // 5 - 8 Byte = zero vector - ds.printUnknownData(9, fmt::format("{}: 0", getMethodName(this, __func__))); - - id = ds.readUint32(); - - spdlog::trace("id = {}", id); - - std::string unknownStr = ds.readStringLenZeroTerm(); - - spdlog::trace("unknownStr = {}", unknownStr); - - uint32_t unknownInt = ds.readUint32(); - - spdlog::trace("unknownInt = {}", unknownInt); - - color = ToColor(ds.readUint32()); - - spdlog::trace("color = {}", ::to_string(color)); - - lineStyle = ToLineStyle(ds.readUint32()); - - spdlog::trace("lineStyle = {}", ::to_string(lineStyle)); - - lineWidth = ToLineWidth(ds.readUint32()); - - spdlog::trace("lineWidth = {}", ::to_string(lineWidth)); - - const uint32_t len0 = ds.readUint16(); - - spdlog::trace("len0 = {}", len0); - - for(size_t i = 0; i < len0; ++i) - { - ds.printUnknownData(4, fmt::format("{}: 1 - {}", - getMethodName(this, __func__), i)); - } - - // localFutureLst.readRestOfStructure(); - - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); +#include +#include +#include + +#include + +#include "Enums/Structure.hpp" +#include "General.hpp" +#include "Structures/StructT0x35.hpp" + + +void StructT0x35::read(FileFormatVersion /* aVersion */) +{ + auto& ds = mCtx.mDs; + + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + + // @todo Try to activate this part + // FutureDataLst localFutureLst{mCtx}; + + // ds.auto_read_prefixes(Structure::T0x35, localFutureLst); + + // ds.readPreamble(); + + // @todo Looks like Primitive types! + // 0 Byte = structure id + // 1 - 4 Byte = struct len + // 5 - 8 Byte = zero vector + ds.printUnknownData(9, fmt::format("{}: 0", getMethodName(this, __func__))); + + id = ds.readUint32(); + + mCtx.mLogger.trace("id = {}", id); + + std::string unknownStr = ds.readStringLenZeroTerm(); + + mCtx.mLogger.trace("unknownStr = {}", unknownStr); + + uint32_t unknownInt = ds.readUint32(); + + mCtx.mLogger.trace("unknownInt = {}", unknownInt); + + color = ToColor(ds.readUint32()); + + mCtx.mLogger.trace("color = {}", ::to_string(color)); + + lineStyle = ToLineStyle(ds.readUint32()); + + mCtx.mLogger.trace("lineStyle = {}", ::to_string(lineStyle)); + + lineWidth = ToLineWidth(ds.readUint32()); + + mCtx.mLogger.trace("lineWidth = {}", ::to_string(lineWidth)); + + const uint32_t len0 = ds.readUint16(); + + mCtx.mLogger.trace("len0 = {}", len0); + + for(size_t i = 0; i < len0; ++i) + { + ds.printUnknownData(4, fmt::format("{}: 1 - {}", + getMethodName(this, __func__), i)); + } + + // localFutureLst.readRestOfStructure(); + + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructT0x45.cpp b/src/Structures/StructT0x45.cpp index f2c54b1..9fd4f8b 100644 --- a/src/Structures/StructT0x45.cpp +++ b/src/Structures/StructT0x45.cpp @@ -15,7 +15,7 @@ void StructT0x45::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -27,6 +27,6 @@ void StructT0x45::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructT0x5b.cpp b/src/Structures/StructT0x5b.cpp index 63798c3..f20f627 100644 --- a/src/Structures/StructT0x5b.cpp +++ b/src/Structures/StructT0x5b.cpp @@ -15,7 +15,7 @@ void StructT0x5b::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -27,6 +27,6 @@ void StructT0x5b::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructTitleBlock.cpp b/src/Structures/StructTitleBlock.cpp index 7f3b33c..60dd2bb 100644 --- a/src/Structures/StructTitleBlock.cpp +++ b/src/Structures/StructTitleBlock.cpp @@ -15,7 +15,7 @@ void StructTitleBlock::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -29,6 +29,6 @@ void StructTitleBlock::read(FileFormatVersion /* aVersion */) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructTitleBlockSymbol.cpp b/src/Structures/StructTitleBlockSymbol.cpp index a412312..d9a5e46 100644 --- a/src/Structures/StructTitleBlockSymbol.cpp +++ b/src/Structures/StructTitleBlockSymbol.cpp @@ -15,7 +15,7 @@ void StructTitleBlockSymbol::read(FileFormatVersion aVersion) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); if(aVersion == FileFormatVersion::Unknown) { @@ -35,7 +35,7 @@ void StructTitleBlockSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolPins = ds.readUint16(); - spdlog::trace("lenSymbolPins = {}", lenSymbolPins); + mCtx.mLogger.trace("lenSymbolPins = {}", lenSymbolPins); for(size_t i = 0u; i < lenSymbolPins; ++i) { @@ -44,7 +44,7 @@ void StructTitleBlockSymbol::read(FileFormatVersion aVersion) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0u; i < lenSymbolDisplayProps; ++i) { @@ -55,6 +55,6 @@ void StructTitleBlockSymbol::read(FileFormatVersion aVersion) localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Structures/StructWire.cpp b/src/Structures/StructWire.cpp index 737b8af..949b892 100644 --- a/src/Structures/StructWire.cpp +++ b/src/Structures/StructWire.cpp @@ -16,7 +16,7 @@ void StructWire::read(FileFormatVersion /* aVersion */) auto& ds = mCtx.mDs; GenericParser parser{mCtx}; - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), ds.getCurrentOffset())); FutureDataLst localFutureLst{mCtx}; @@ -32,29 +32,29 @@ void StructWire::read(FileFormatVersion /* aVersion */) id = ds.readUint32(); - spdlog::trace("id = {}", id); + mCtx.mLogger.trace("id = {}", id); color = ToColor(ds.readUint32()); - spdlog::trace("color = {}", ::to_string(color)); + mCtx.mLogger.trace("color = {}", ::to_string(color)); startX = ds.readInt32(); startY = ds.readInt32(); - spdlog::trace("startX = {}", startX); - spdlog::trace("startY = {}", startY); + mCtx.mLogger.trace("startX = {}", startX); + mCtx.mLogger.trace("startY = {}", startY); endX = ds.readInt32(); endY = ds.readInt32(); - spdlog::trace("endX = {}", endX); - spdlog::trace("endY = {}", endY); + mCtx.mLogger.trace("endX = {}", endX); + mCtx.mLogger.trace("endY = {}", endY); ds.printUnknownData(1, fmt::format("{}: 1", getMethodName(this, __func__))); const uint16_t lenAliases = ds.readUint16(); - spdlog::trace("lenAliases = {}", lenAliases); + mCtx.mLogger.trace("lenAliases = {}", lenAliases); for(size_t i = 0; i < lenAliases; ++i) { @@ -63,7 +63,7 @@ void StructWire::read(FileFormatVersion /* aVersion */) const uint16_t lenSymbolDisplayProps = ds.readUint16(); - spdlog::trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); + mCtx.mLogger.trace("lenSymbolDisplayProps = {}", lenSymbolDisplayProps); for(size_t i = 0; i < lenSymbolDisplayProps; ++i) { @@ -72,16 +72,16 @@ void StructWire::read(FileFormatVersion /* aVersion */) lineWidth = ToLineWidth(ds.readUint32()); - spdlog::trace("lineWidth = {}", ::to_string(lineWidth)); + mCtx.mLogger.trace("lineWidth = {}", ::to_string(lineWidth)); lineStyle = ToLineStyle(ds.readUint32()); - spdlog::trace("lineStyle = {}", ::to_string(lineStyle)); + mCtx.mLogger.trace("lineStyle = {}", ::to_string(lineStyle)); localFutureLst.checkpoint(); localFutureLst.sanitizeCheckpoints(); - spdlog::debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); - spdlog::trace(to_string()); + mCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), ds.getCurrentOffset())); + mCtx.mLogger.trace(to_string()); } \ No newline at end of file diff --git a/src/Win32/LOGFONTA.hpp b/src/Win32/LOGFONTA.hpp index 851cb32..08335da 100644 --- a/src/Win32/LOGFONTA.hpp +++ b/src/Win32/LOGFONTA.hpp @@ -27,7 +27,7 @@ class tagLOGFONTA void read(StreamContext& aCtx) { - spdlog::debug(getOpeningMsg(getMethodName(this, __func__), aCtx.mDs.getCurrentOffset())); + aCtx.mLogger.debug(getOpeningMsg(getMethodName(this, __func__), aCtx.mDs.getCurrentOffset())); const auto buffer = aCtx.mDs.readBytes(sizeof(*this)); @@ -48,8 +48,8 @@ class tagLOGFONTA throw std::runtime_error(fmt::format("lfQuality <= 6 must hold but lfQuality = {}", lfQuality)); } - spdlog::debug(getClosingMsg(getMethodName(this, __func__), aCtx.mDs.getCurrentOffset())); - spdlog::trace(to_string()); + aCtx.mLogger.debug(getClosingMsg(getMethodName(this, __func__), aCtx.mDs.getCurrentOffset())); + aCtx.mLogger.trace(to_string()); } void accept(Visitor& aVisitor) const diff --git a/src/XmlExporter.cpp b/src/XmlExporter.cpp index 9888525..58c8910 100644 --- a/src/XmlExporter.cpp +++ b/src/XmlExporter.cpp @@ -456,7 +456,8 @@ void XmlExporter::visit(const StructT0x1f& aObj) for(size_t i = 0U; i < aObj.pinIdxMappings.size(); ++i) { - assert(aObj.pinIdxMappings.at(i)->pinMap.size() == aObj.pinIdxMappings.at(i)->pinIgnore.size() == aObj.pinIdxMappings.at(i)->pinGroup.size()); + assert(aObj.pinIdxMappings.at(i)->pinMap.size() == aObj.pinIdxMappings.at(i)->pinIgnore.size()); + assert(aObj.pinIdxMappings.at(i)->pinMap.size() == aObj.pinIdxMappings.at(i)->pinGroup.size()); for(size_t position = 0U; position < aObj.pinIdxMappings.at(i)->pinMap.size(); ++position) { diff --git a/test/src/Helper.hpp b/test/src/Helper.hpp index 0695ba6..40c252e 100644 --- a/test/src/Helper.hpp +++ b/test/src/Helper.hpp @@ -2,6 +2,8 @@ #define HELPER_HPP +#include +#include #include #include #include @@ -16,6 +18,8 @@ namespace fs = std::filesystem; +using namespace std::chrono_literals; + [[maybe_unused]] inline ParserConfig get_parser_config() @@ -63,15 +67,35 @@ inline void check_error_count(const fs::path& aFilePath, size_t aActualErrCnt, s std::clog << msg; } - const fs::path logPath = fs::current_path() / "test_err_cnt.log"; + const fs::path errCntFilePath = fs::current_path() / "test_err_cnt.log"; + fs::path lockFilePath = errCntFilePath; + lockFilePath += std::string{".lock"}; + + // Ensure that we acquire the test_err_cnt.log.lock file before writing + // to test_err_cnt.log to ensure syncronization across multiple processes + // that want to write to this file. + while(true) + { + std::FILE* lockFile = std::fopen(lockFilePath.c_str(), "ax"); + + if(nullptr != lockFile) + { + std::ofstream errCntFile; - std::ofstream logFile; + errCntFile.open(errCntFilePath, std::ios_base::app); - logFile.open(logPath, std::ios_base::app); + errCntFile << msg; - logFile << msg; + errCntFile.close(); - logFile.close(); + std::fclose(lockFile); + fs::remove(lockFilePath); + + break; + } + + std::this_thread::sleep_for(25ms); + } }