Line data Source code
1 : // 2 : // Copyright 2024 OpenModelViewer Authors 3 : // 4 : // Licensed under the Apache License, Version 2.0 (the "License"); 5 : // you may not use this file except in compliance with the License. 6 : // You may obtain a copy of the License at 7 : // 8 : // http://www.apache.org/licenses/LICENSE-2.0 9 : // 10 : // Unless required by applicable law or agreed to in writing, software 11 : // distributed under the License is distributed on an "AS IS" BASIS, 12 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 : // See the License for the specific language governing permissions and 14 : // limitations under the License. 15 : // 16 : 17 : #pragma once 18 : 19 : #include <string_view> 20 : 21 : namespace openmodelviewer::core::log 22 : { 23 : /** 24 : * @brief Defines severity levels for log messages. 25 : * 26 : * These levels help filter and categorize log output, 27 : * making it easier to distinguish between normal activity, 28 : * debugging information, and actual problems. 29 : */ 30 : enum class LogLevel 31 : { 32 : Trace, ///< Detailed internal information, typically only useful for developers and diagnostics. 33 : Debug, ///< General debugging information, useful during development. 34 : Info, ///< Standard messages that indicate normal operation. 35 : Warning, ///< Something unexpected happened, but the system can continue running. 36 : Error, ///< A significant issue occurred; some part of the system failed. 37 : Critical ///< A severe error indicating the program might not continue running. 38 : }; 39 : 40 : /** 41 : * @brief Converts a LogLevel enum value to its corresponding string representation. 42 : * 43 : * @param level The log level to convert. 44 : * @return A string view representing the log level. 45 : */ 46 14 : inline std::string_view to_string(LogLevel level) noexcept 47 : { 48 14 : switch (level) 49 : { 50 0 : case LogLevel::Trace: return "Trace"; 51 1 : case LogLevel::Debug: return "Debug"; 52 11 : case LogLevel::Info: return "Info"; 53 1 : case LogLevel::Warning: return "Warning"; 54 1 : case LogLevel::Error: return "Error"; 55 0 : case LogLevel::Critical: return "Critical"; 56 : } 57 : 58 0 : return "Invalid_LogLevel"; 59 : } 60 : 61 : } // namespace openmodelviewer::core::log