From 201c815c13c177d512b1879a2847ce427af64f72 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 18 Jul 2025 15:15:06 +0200 Subject: [PATCH 1/7] Logger prototype --- CMakeLists.txt | 2 + code/Common/Logger.cpp | 296 +++++++++++++++++++++++++++ include/cppcore/Common/Logger.h | 226 ++++++++++++++++++++ include/cppcore/Common/TStringBase.h | 60 ++++-- 4 files changed, 569 insertions(+), 15 deletions(-) create mode 100644 code/Common/Logger.cpp create mode 100644 include/cppcore/Common/Logger.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a1453f..9ccc8aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,8 @@ SET(cppcore_src SET(cppcore_common_src include/cppcore/Common/Hash.h + include/cppcore/Common/Logger.h + code/Common/Logger.cpp include/cppcore/Common/TStringBase.h include/cppcore/Common/TStringView.h include/cppcore/Common/Variant.h diff --git a/code/Common/Logger.cpp b/code/Common/Logger.cpp new file mode 100644 index 0000000..519581f --- /dev/null +++ b/code/Common/Logger.cpp @@ -0,0 +1,296 @@ +#include +#include +#include +#include +#include +#include + +namespace cppcore { + +static constexpr char Line[] = + "===================================================================================================="; + +static void appendDomain(const String &domain, String &logMsg) { + if (!domain.isEmpty()) { + logMsg += '('; + logMsg += domain; + logMsg += ')'; + } +} + +static ::std::string stripFilename(const ::std::string &filename) { + if (filename.empty()) { + return filename; + } + + ::std::string::size_type pos = filename.find_last_of("/"); + if (pos == ::std::string::npos) { + return filename; + } + const ::std::string strippedName = filename.substr(pos + 1, filename.size() - pos - 1); + + return strippedName; +} + +static void addTraceInfo(const String &file, int line, String &msg) { + if (Logger::getInstance()->getVerboseMode() == Logger::VerboseMode::Trace) { + msg += String(" (", 2); + std::string stripped = stripFilename(file.c_str()); + msg += String(stripped.c_str(), stripped.size()); + msg += String(", ", 2); + std::stringstream ss; + ss << line; + std::string lineno = ss.str(); + msg += String(lineno.c_str(), lineno.size()); + msg += ')'; + } +} + +void AbstractLogStream::activate() { + mIsActive = true; +} + +void AbstractLogStream::desactivate() { + mIsActive = false; +} + +bool AbstractLogStream::isActive() const { + return mIsActive; +} + +Logger *Logger::sLogger = nullptr; + +Logger *Logger::create() { + if (nullptr == sLogger) { + sLogger = new Logger; + } + + return sLogger; +} + +Logger *Logger::getInstance() { + if (nullptr == sLogger) { + static_cast(create()); + } + + return sLogger; +} + +void Logger::kill() { + if (sLogger) { + delete sLogger; + sLogger = nullptr; + } +} + +void Logger::setVerboseMode(VerboseMode sev) { + mVerboseMode = sev; +} + +Logger::VerboseMode Logger::getVerboseMode() const { + return mVerboseMode; +} + +void Logger::trace(const String &domain, const String &msg) { + if (getVerboseMode() == VerboseMode::Trace) { + String logMsg; + logMsg += String("Trace: ", 6); + logMsg += msg; + appendDomain(domain, logMsg); + + print(logMsg); + } +} + +void Logger::debug(const String &domain, const String &msg) { + if (getVerboseMode() == VerboseMode::Debug || getVerboseMode() == VerboseMode::Trace) { + String logMsg; + logMsg += String("Dbg: ", 6); + logMsg += msg; + appendDomain(domain, logMsg); + + print(logMsg); + } +} + +void Logger::info(const String &domain, const String &msg) { + if (getVerboseMode() == VerboseMode::Normal || getVerboseMode() == VerboseMode::Verbose || getVerboseMode() == VerboseMode::Debug || getVerboseMode() == VerboseMode::Trace) { + String logMsg; + + logMsg += String("Info: ", 6); + logMsg += msg; + + appendDomain(domain, logMsg); + + print(logMsg); + } +} + +void Logger::print(const String &msg, PrintMode mode) { + if (msg.isEmpty()) { + return; + } + + if (msg.size() > 8) { + if (msg[6] == '<' && msg[7] == '=') { + mIntention -= 2; + } + } + + String logMsg; + if (0 != mIntention) { + for (uint32_t i = 0; i < mIntention; i++) { + logMsg += ' '; + } + } + + logMsg += msg; + if (PrintMode::WithDateTime == mode) { + logMsg += String(" (", 2); + logMsg += this->getDateTime(); + logMsg += ')'; + } + + logMsg += String(" \n", 2); + for (size_t i = 0; i < mLogStreams.size(); ++i) { + AbstractLogStream *stream = mLogStreams[i]; + if (stream != nullptr) { + stream->write(logMsg); + } + } + + if (msg.size() > 8) { + if (msg[6] == '=' && msg[7] == '>') { + mIntention += 2; + } + } +} + +void Logger::warn(const String &domain, const String &msg) { + String logMsg; + logMsg += String("Warn: ", 6); + logMsg += msg; + appendDomain(domain, logMsg); + + print(logMsg); +} + +void Logger::error(const String &domain, const String &msg) { + String logMsg; + logMsg += String("Err: ", 6); + logMsg += msg; + appendDomain(domain, logMsg); + + print(logMsg); +} + +void Logger::fatal(const String &domain, const String &msg) { + String logMsg; + logMsg += String("Fatal:", 6); + logMsg += msg; + appendDomain(domain, logMsg); + + print(logMsg); +} + +void Logger::registerLogStream(AbstractLogStream *pLogStream) { + if (nullptr == pLogStream) { + return; + } + + mLogStreams.add(pLogStream); +} + +void Logger::unregisterLogStream(AbstractLogStream *logStream) { + if (nullptr != logStream) { + return; + } + + for (size_t i = 0; i < mLogStreams.size(); ++i) { + if (mLogStreams[i] == logStream) { + delete mLogStreams[i]; + mLogStreams.remove(i); + } + } +} + +Logger::Logger() : + mLogStreams(), + mVerboseMode(VerboseMode::Normal), + mIntention(0) { + mLogStreams.add(new StdLogStream); + +#ifdef OSRE_WINDOWS + mLogStreams.add(new Platform::Win32DbgLogStream); +#endif // OSRE_WINDOWS +} + +Logger::~Logger() { + for (size_t i = 0; i < mLogStreams.size(); ++i) { + delete mLogStreams[i]; + } +} + +String Logger::getDateTime() { + static const uint32_t Space = 2; + /* DateTime currentDateTime = DateTime::getCurrentUTCTime(); + std::stringstream stream; + stream.fill('0'); + stream << std::setw(Space) << currentDateTime.getCurrentDay() << "." + << std::setw(Space) << currentDateTime.getCurrentMonth() << "." + << std::setw(Space * 2) << currentDateTime.getCurrentYear() << " " + << std::setw(Space) << currentDateTime.getCurrentHour() << ":" + << std::setw(Space) << currentDateTime.getCurrentMinute() << ":" + << std::setw(Space) << currentDateTime.getCurrentSeconds(); + */ + String todo("none", 4); + return todo; +} + +void Logger::StdLogStream::write(const String &msg) { + std::cout << msg.c_str(); +} + +void tracePrint(const String &domain, const String &file, int line, const String &msg) { + String message; + message += msg; + addTraceInfo(file, line, message); + Logger::getInstance()->trace(domain, message); +} + +void debugPrint(const String &domain, const String &file, int line, const String &msg) { + String message; + message += msg; + addTraceInfo(file, line, message); + Logger::getInstance()->debug(domain, message); +} + +void infoPrint(const String &domain, const String &file, int line, const String &msg) { + String message; + message += msg; + addTraceInfo(file, line, message); + Logger::getInstance()->info(domain, message); +} + +void warnPrint(const String &domain, const String &file, int line, const String &message) { + String msg; + msg += message; + addTraceInfo(file, line, msg); + Logger::getInstance()->warn(domain, msg); +} + +void errorPrint(const String &domain, const String &file, int line, const String &message) { + String msg; + msg += message; + addTraceInfo(file, line, msg); + Logger::getInstance()->error(domain, msg); +} + +void fatalPrint(const String &domain, const String &file, int line, const String &message) { + String msg; + msg += message; + addTraceInfo(file, line, msg); + Logger::getInstance()->fatal(domain, msg); +} + +} // namespace cppcore diff --git a/include/cppcore/Common/Logger.h b/include/cppcore/Common/Logger.h new file mode 100644 index 0000000..d373edc --- /dev/null +++ b/include/cppcore/Common/Logger.h @@ -0,0 +1,226 @@ +#pragma once + +#include +#include +#include + +namespace cppcore { + +#define DECL_LOG_MODULE(name) static constexpr char Tag[] = #name; + +using String = TStringBase; + +//------------------------------------------------------------------------------------------------- +/// +/// @brief This pure abstract interface class declares the protocol for log-stream implementation. +/// You can use log streams to pipes logs to you preferred output device like a simple text-file +/// or a log window in a GUI application. Implement the write message and attach a valid instance +/// to the logger itself to use your own implementation. +//------------------------------------------------------------------------------------------------- +class AbstractLogStream { +public: + /// @brief The default class destructor, virtual. + virtual ~AbstractLogStream() = default; + + /// @brief Will write a message into the attached log stream. + /// @param message The message to log. + virtual void write(const String &message) = 0; + + /// @brief The stream will be activated. + virtual void activate(); + + /// @brief The stream will be deactivated. + virtual void desactivate(); + + /// @brief Returns true, if the stream is active. + /// @return true, if the stream is active, else false will be returned. + virtual bool isActive() const; + + // No copying + AbstractLogStream(const AbstractLogStream &) = delete; + AbstractLogStream &operator = (const AbstractLogStream &) = delete; + +protected: + /// @brief The default class constructor. + AbstractLogStream() = default; + +private: + bool mIsActive = true; +}; + +//------------------------------------------------------------------------------------------------- +/// +/// @brief This class implements a simple logger. +/// +/// The logger is implemented as a singleton. You can attach several log streams to it, which can +/// be used to log the messages to several output channels like a window or a log file or something +/// else. +/// The granularity of the logged messages can be controlled by the severity of the logger. The +/// supported modes are normal ( no debug and info messages ), verbose ( all messages will be +/// logged ) and debug ( the debug messages will be logged as well, be careful with this option ). +//------------------------------------------------------------------------------------------------- +class Logger final { +public: + /// @brief Describes the verbode mode. + enum class VerboseMode { + Normal, ///< Only warnings and errors will be logged. + Verbose, ///< Normal messages will be logged as well. + Debug, ///< All debug messages will be logged as well. + Trace ///< Will enable the tracing. + }; + + /// @brief Describes the mode for prints into the active log stream. + enum class PrintMode { + WithDateTime, ///< A dateTime string will put be in front of the entry. + WhithoutDateTime ///< No DateTime will be there. + }; + +public: + /// @brief Creates the unique logger instance and returns a pointer showing to it. + /// @return The singleton pointer of the logger. + static Logger *create(); + + /// @brief returns the singleton instance pointer of the logger. + /// @return The singleton pointer of the logger. + static Logger *getInstance(); + + /// @brief Kills the only instance of the logger. + static void kill(); + + /// @brief Set the severity of the logger. + /// @param[in] sev The new severity of the logger. + /// @see Severity + void setVerboseMode(VerboseMode sev); + + /// @brief Returns the current severity of the logger. + /// @return The current severity. + VerboseMode getVerboseMode() const; + + /// @brief Logs a trace message. + /// @param[in] domain The domain. + /// @param[in] msg The message to log. + void trace(const String &domain, const String &msg); + + /// @brief Logs a debug message. + /// @param[in] domain The domain. + /// @param[in] msg The message to log. + void debug(const String &domain, const String &msg); + + /// @brief Logs an info message. + /// @param[in] domain The domain. + /// @param[in] msg The message to log. + void info(const String &domain, const String &msg); + + /// @brief Logs a print message. + /// @param[in] message The message to log. + /// @param[in] mode Logging mode + void print( const String &message, PrintMode mode = PrintMode::WhithoutDateTime ); + + /// @brief Logs a warn message. + /// @param[in] domain The domain. + /// @param[in] msg The message to log. + void warn( const String &domain, const String &msg ); + + /// @brief Logs a error message. + /// @param[in] domain The domain. + /// @param[in] msg The message to log. + void error(const String &domain, const String &msg); + + /// @brief Logs a fatal error message. + /// @param[in] domain The domain. + /// @param[in] msg The message to log. + void fatal(const String &domain, const String &msg); + + /// @brief Registers a new log stream. + /// @param[in] pLogStream A pointer showing to the log stream. + void registerLogStream(AbstractLogStream *pLogStream); + + /// @brief Unregisters a registered log stream. + /// @param[in] pLogStream A pointer showing to the log stream. + void unregisterLogStream(AbstractLogStream *pLogStream); + +private: + Logger(); + ~Logger(); + String getDateTime(); + +private: + // @brief The Standard log stream. + class StdLogStream : public AbstractLogStream { + public: + /// @brief The class constructor. + StdLogStream() = default; + + /// @brief The class destructor. + ~StdLogStream() override = default; + + /// @brief Will write a message into the stream. + /// @param msg [in] The message to write. + void write(const String &msg) override; + }; + + static Logger *sLogger; + + using LogStreamArray = cppcore::TArray; + LogStreamArray mLogStreams; + VerboseMode mVerboseMode; + uint32_t mIntention; +}; + +// Logger helper function prototypes +void tracePrint(const String &domain, const String &file, int line, const String &msg); +void debugPrint(const String &domain, const String &file, int line, const String &msg); +void infoPrint( const String &domain, const String &file, int line, const String &msg ); +void warnPrint( const String &domain, const String &file, int line, const String &msg ); +void errorPrint( const String &domain, const String &file, int line, const String &msg ); +void fatalPrint( const String &domain, const String &file, int line, const String &msg ); + +} // namespace cppcore + +//------------------------------------------------------------------------------------------------- +/// @fn osre_trace +/// @brief This helper macro will write the trace message into the logger. +/// @param domain The domain to log for. +/// @param message The message to log. +//------------------------------------------------------------------------------------------------- +#define log_trace(domain, msg) cppcore::tracePrint(domain, __FILE__, __LINE__, msg) + +//------------------------------------------------------------------------------------------------- +/// @fn osre_debug +/// @brief This helper macro will write the debug message into the logger. +/// @param domain The domain to log for. +/// @param message The message to log. +//------------------------------------------------------------------------------------------------- +#define log_debug(domain, msg) cppcore::debugPrint( domain, __FILE__, __LINE__, msg) + +//------------------------------------------------------------------------------------------------- +/// @fn osre_log +/// @brief This helper macro will write the info message into the logger. +/// @param domain The domain to log for. +/// @param message The message to log. +//------------------------------------------------------------------------------------------------- +#define log_info(domain, msg) cppcore::infoPrint( domain, __FILE__, __LINE__, msg) + +//------------------------------------------------------------------------------------------------- +/// @fn osre_warn +/// @brief This helper macro will write a warning into the logger. +/// @param domain The domain to log for. +/// @param message The warning to writhe into the log. +//------------------------------------------------------------------------------------------------- +#define log_warn(domain, message) cppcore::warnPrint( domain, __FILE__, __LINE__, message) + +//------------------------------------------------------------------------------------------------- +/// @fn osre_error +/// @brief This helper macro will write a error into the logger. +/// @param domain The domain to log for. +/// @param message The warning to writhe into the log. +//------------------------------------------------------------------------------------------------- +#define log_error(domain, message) cppcore::errorPrint( domain, __FILE__, __LINE__, message) + +//------------------------------------------------------------------------------------------------- +/// @fn osre_fatal +/// @brief This helper macro will write a fatal error into the logger. +/// @param domain The domain to log for. +/// @param message The warning to writhe into the log. +//------------------------------------------------------------------------------------------------- +#define log_fatal( domain, message ) cppcore::fatalPrint( domain,__FILE__, __LINE__, message) diff --git a/include/cppcore/Common/TStringBase.h b/include/cppcore/Common/TStringBase.h index 3d3a83b..038b1dc 100644 --- a/include/cppcore/Common/TStringBase.h +++ b/include/cppcore/Common/TStringBase.h @@ -86,8 +86,12 @@ class TStringBase { /// @brief Not equal operator. bool operator != (const TStringBase &rhs) const; + TStringBase &operator += (const TStringBase &rhs); + TStringBase &operator+=(char c); + T operator[](size_t index) const; + private: - static constexpr size_t InitSize = 256; + static constexpr size_t InitSize = 512; T mBuffer[InitSize] = {}; T *mStringBuffer{nullptr}; size_t mSize{0}; @@ -156,21 +160,25 @@ inline void TStringBase::clear() { template inline void TStringBase::copyFrom(TStringBase &base, const T *ptr, size_t size) { - if (ptr != nullptr) { - T *targetPtr = base.mBuffer; - if (size > 0) { - if (size > base.mCapacity) { - if (base.mStringBuffer != nullptr) { - delete [] base.mStringBuffer; - } - base.mStringBuffer = new T[size]; - base.mCapacity = size; - targetPtr = base.mStringBuffer; - } - memcpy(targetPtr, ptr, size * sizeof(T)); - base.mSize = size; + if (ptr == nullptr) { + return; + } + + T *targetPtr = base.mBuffer; + if (size == 0) { + return; + } + + if (size > base.mCapacity) { + if (base.mStringBuffer != nullptr) { + delete [] base.mStringBuffer; } + base.mStringBuffer = new T[size]; + base.mCapacity = size; + targetPtr = base.mStringBuffer; } + memcpy(targetPtr, ptr, size * sizeof(T)); + base.mSize = size; } template @@ -188,8 +196,30 @@ inline bool TStringBase::operator == (const TStringBase &rhs) const { } template -inline bool TStringBase::operator != (const TStringBase &rhs) const { +inline bool TStringBase::operator != (const TStringBase &rhs) const { return !(*this == rhs); } +template +inline TStringBase &TStringBase::operator += (const TStringBase &rhs) { + if (rhs.isEmpty()) { + return *this; + } + + copyFrom(*this, rhs.c_str(), rhs.size()); + + return *this; +} + +template +inline TStringBase& TStringBase::operator+=(char c) { + copyFrom(*this, &c, 1); + return *this; +} + +template +inline T TStringBase::operator[](size_t index) const { + return mBuffer[index]; +} + } // namespace cppcore From 0b0c425b170bc6bd65f1f5793d40f310533e6c5f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 21 Jul 2025 13:41:47 +0200 Subject: [PATCH 2/7] Add first logger version --- code/Common/Logger.cpp | 22 +++++++++++++++ include/cppcore/Common/Logger.h | 48 +++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/code/Common/Logger.cpp b/code/Common/Logger.cpp index 519581f..a4ec023 100644 --- a/code/Common/Logger.cpp +++ b/code/Common/Logger.cpp @@ -1,3 +1,25 @@ +/*----------------------------------------------------------------------------------------------- +The MIT License (MIT) + +Copyright (c) 2014-2025 Kim Kulling + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-----------------------------------------------------------------------------------------------*/ #include #include #include diff --git a/include/cppcore/Common/Logger.h b/include/cppcore/Common/Logger.h index d373edc..073727e 100644 --- a/include/cppcore/Common/Logger.h +++ b/include/cppcore/Common/Logger.h @@ -1,3 +1,25 @@ +/*----------------------------------------------------------------------------------------------- +The MIT License (MIT) + +Copyright (c) 2014-2025 Kim Kulling + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-----------------------------------------------------------------------------------------------*/ #pragma once #include @@ -63,16 +85,20 @@ class Logger final { public: /// @brief Describes the verbode mode. enum class VerboseMode { - Normal, ///< Only warnings and errors will be logged. - Verbose, ///< Normal messages will be logged as well. - Debug, ///< All debug messages will be logged as well. - Trace ///< Will enable the tracing. + Invalid = -1, ///< Invalid marker + Normal, ///< Only warnings and errors will be logged. + Verbose, ///< Normal messages will be logged as well. + Debug, ///< All debug messages will be logged as well. + Trace, ///< Will enable the tracing. + Count ///< Number of enums }; /// @brief Describes the mode for prints into the active log stream. enum class PrintMode { + Invalid = -1, ///< Invalid marker WithDateTime, ///< A dateTime string will put be in front of the entry. - WhithoutDateTime ///< No DateTime will be there. + WhithoutDateTime, ///< No DateTime will be there. + Count ///< Number of enums }; public: @@ -183,7 +209,7 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin /// @param domain The domain to log for. /// @param message The message to log. //------------------------------------------------------------------------------------------------- -#define log_trace(domain, msg) cppcore::tracePrint(domain, __FILE__, __LINE__, msg) +#define log_trace(domain, msg) ::cppcore::tracePrint(domain, __FILE__, __LINE__, msg) //------------------------------------------------------------------------------------------------- /// @fn osre_debug @@ -191,7 +217,7 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin /// @param domain The domain to log for. /// @param message The message to log. //------------------------------------------------------------------------------------------------- -#define log_debug(domain, msg) cppcore::debugPrint( domain, __FILE__, __LINE__, msg) +#define log_debug(domain, msg) ::cppcore::debugPrint(domain, __FILE__, __LINE__, msg) //------------------------------------------------------------------------------------------------- /// @fn osre_log @@ -199,7 +225,7 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin /// @param domain The domain to log for. /// @param message The message to log. //------------------------------------------------------------------------------------------------- -#define log_info(domain, msg) cppcore::infoPrint( domain, __FILE__, __LINE__, msg) +#define log_info(domain, msg) ::cppcore::infoPrint(domain, __FILE__, __LINE__, msg) //------------------------------------------------------------------------------------------------- /// @fn osre_warn @@ -207,7 +233,7 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin /// @param domain The domain to log for. /// @param message The warning to writhe into the log. //------------------------------------------------------------------------------------------------- -#define log_warn(domain, message) cppcore::warnPrint( domain, __FILE__, __LINE__, message) +#define log_warn(domain, message) ::cppcore::warnPrint(domain, __FILE__, __LINE__, message) //------------------------------------------------------------------------------------------------- /// @fn osre_error @@ -215,7 +241,7 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin /// @param domain The domain to log for. /// @param message The warning to writhe into the log. //------------------------------------------------------------------------------------------------- -#define log_error(domain, message) cppcore::errorPrint( domain, __FILE__, __LINE__, message) +#define log_error(domain, message) ::cppcore::errorPrint(domain, __FILE__, __LINE__, message) //------------------------------------------------------------------------------------------------- /// @fn osre_fatal @@ -223,4 +249,4 @@ void fatalPrint( const String &domain, const String &file, int line, const Strin /// @param domain The domain to log for. /// @param message The warning to writhe into the log. //------------------------------------------------------------------------------------------------- -#define log_fatal( domain, message ) cppcore::fatalPrint( domain,__FILE__, __LINE__, message) +#define log_fatal(domain, message) ::cppcore::fatalPrint(domain, __FILE__, __LINE__, message) From 80e9a930412a7386b59da1ef072d4a65a0259333 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 22 Jul 2025 20:55:29 +0200 Subject: [PATCH 3/7] Update Logger.cpp Fix review findings --- code/Common/Logger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/Common/Logger.cpp b/code/Common/Logger.cpp index a4ec023..03883f4 100644 --- a/code/Common/Logger.cpp +++ b/code/Common/Logger.cpp @@ -72,7 +72,7 @@ void AbstractLogStream::activate() { mIsActive = true; } -void AbstractLogStream::desactivate() { +void AbstractLogStream::deactivate() { mIsActive = false; } @@ -224,7 +224,7 @@ void Logger::registerLogStream(AbstractLogStream *pLogStream) { } void Logger::unregisterLogStream(AbstractLogStream *logStream) { - if (nullptr != logStream) { + if (nullptr == logStream) { return; } From 2c3c24adabe44032aa8ce8161173a1298e13fc76 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 22 Jul 2025 20:56:18 +0200 Subject: [PATCH 4/7] Fix review finding --- code/Common/Logger.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/Common/Logger.cpp b/code/Common/Logger.cpp index 03883f4..cdad976 100644 --- a/code/Common/Logger.cpp +++ b/code/Common/Logger.cpp @@ -241,10 +241,6 @@ Logger::Logger() : mVerboseMode(VerboseMode::Normal), mIntention(0) { mLogStreams.add(new StdLogStream); - -#ifdef OSRE_WINDOWS - mLogStreams.add(new Platform::Win32DbgLogStream); -#endif // OSRE_WINDOWS } Logger::~Logger() { From 4e729a4c810305c33991ec9b6b20f898307431ae Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 22 Jul 2025 20:57:05 +0200 Subject: [PATCH 5/7] Fix review findings --- include/cppcore/Common/Logger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cppcore/Common/Logger.h b/include/cppcore/Common/Logger.h index 073727e..dbbe497 100644 --- a/include/cppcore/Common/Logger.h +++ b/include/cppcore/Common/Logger.h @@ -52,7 +52,7 @@ class AbstractLogStream { virtual void activate(); /// @brief The stream will be deactivated. - virtual void desactivate(); + virtual void deactivate(); /// @brief Returns true, if the stream is active. /// @return true, if the stream is active, else false will be returned. From dd486cfa10f8b4d49c60b1c0d06a3cd309b06ee5 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 22 Jul 2025 20:57:55 +0200 Subject: [PATCH 6/7] Fix typo --- include/cppcore/Common/Logger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cppcore/Common/Logger.h b/include/cppcore/Common/Logger.h index dbbe497..fe2ce1e 100644 --- a/include/cppcore/Common/Logger.h +++ b/include/cppcore/Common/Logger.h @@ -97,7 +97,7 @@ class Logger final { enum class PrintMode { Invalid = -1, ///< Invalid marker WithDateTime, ///< A dateTime string will put be in front of the entry. - WhithoutDateTime, ///< No DateTime will be there. + WithoutDateTime, ///< No DateTime will be there. Count ///< Number of enums }; From 123a5255edf3b386c17816bd6ac65cb2b281f0d7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 22 Jul 2025 21:03:14 +0200 Subject: [PATCH 7/7] Fix review findings --- include/cppcore/Common/TStringBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cppcore/Common/TStringBase.h b/include/cppcore/Common/TStringBase.h index 038b1dc..33b5d17 100644 --- a/include/cppcore/Common/TStringBase.h +++ b/include/cppcore/Common/TStringBase.h @@ -95,7 +95,7 @@ class TStringBase { T mBuffer[InitSize] = {}; T *mStringBuffer{nullptr}; size_t mSize{0}; - size_t mCapacity{256}; + size_t mCapacity{InitSize}; HashId mHashId{0}; };