From ffcea870ba332417fc8825d2be37e169d35e4a83 Mon Sep 17 00:00:00 2001
From: kongr45gpen <electrovesta@gmail.com>
Date: Fri, 30 Aug 2019 03:05:30 +0300
Subject: [PATCH] Use `noexcept` for some Logging functions

Thanks @xlxs41 for the suggestion!
---
 inc/Logger.hpp              | 6 +++---
 src/Logger.cpp              | 4 ++--
 src/Platform/x86/Logger.cpp | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/inc/Logger.hpp b/inc/Logger.hpp
index 1fce8729..f4b6bdd8 100644
--- a/inc/Logger.hpp
+++ b/inc/Logger.hpp
@@ -58,6 +58,7 @@ public:
 	 * Each severity is tied to a number. The higher the number, the higher the severity.
 	 */
 	enum LogLevel : LogLevelType {
+		disabled = 0, ///< Use this log level to disable logging entirely. No message should be logged as disabled.
 		trace = 32, ///< Very detailed information, useful for tracking the individual steps of an operation
 		debug = 64, ///< General debugging information
 		info = 96, ///< Noteworthy or periodical events
@@ -65,7 +66,6 @@ public:
 		warning = 160, ///< Unexpected events that do not compromise the operability of a function
 		error = 192, ///< Unexpected failure of an operation
 		emergency = 254, ///< Unexpected failure that renders the entire system unusable
-		disabled = 255, ///< Use this log level to disable logging entirely. No message should be logged as disabled.
 	};
 
 	/**
@@ -110,13 +110,13 @@ public:
 		 * @return The current Logger::LogEntry where the value has been appended
 		 */
 		template <class T>
-		Logger::LogEntry& operator<<(const T value) {
+		Logger::LogEntry& operator<<(const T value) noexcept {
 			etl::to_string(value, message, format, true);
 
 			return *this;
 		}
 
-		Logger::LogEntry& operator<<(const std::string& value);
+		Logger::LogEntry& operator<<(const std::string& value) noexcept;
 	};
 
 	/**
diff --git a/src/Logger.cpp b/src/Logger.cpp
index a6ca19f8..64bb617f 100644
--- a/src/Logger.cpp
+++ b/src/Logger.cpp
@@ -2,14 +2,14 @@
 
 // Reimplementation of the function for variable C strings
 template <>
-Logger::LogEntry& Logger::LogEntry::operator<<(char* value) {
+Logger::LogEntry& Logger::LogEntry::operator<<(char* value) noexcept {
 	message.append(value);
 	return *this;
 }
 
 // Reimplementation of the function for C strings
 template <>
-Logger::LogEntry& Logger::LogEntry::operator<<(const char* value) {
+Logger::LogEntry& Logger::LogEntry::operator<<(const char* value) noexcept {
 	message.append(value);
 	return *this;
 }
diff --git a/src/Platform/x86/Logger.cpp b/src/Platform/x86/Logger.cpp
index 7848d226..5f6c839f 100644
--- a/src/Platform/x86/Logger.cpp
+++ b/src/Platform/x86/Logger.cpp
@@ -61,7 +61,7 @@ void Logger::log(Logger::LogLevel level, String<LOGGER_MAX_MESSAGE_SIZE> & messa
 
 // Reimplementation of the log function for C++ strings
 // This is kept in the Platform files, since we don't want to mess with std::strings in the microcontroller
-Logger::LogEntry& Logger::LogEntry::operator<<(const std::string & value) {
+Logger::LogEntry& Logger::LogEntry::operator<<(const std::string & value) noexcept {
 	message.append(value.c_str());
 
 	return *this;
-- 
GitLab