LCOV - code coverage report
Current view: top level - include/openmodelviewer/core/log - log_level.hpp (source / functions) Hit Total Coverage
Test: libopenmodelviewer coverage Lines: 6 9 66.7 %
Date: 2025-07-03 20:26:48 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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             : namespace openmodelviewer::core::log
      20             : {
      21             :     /**
      22             :      * @brief Defines severity levels for log messages.
      23             :      * These levels help filter and categorize log output.
      24             :      */
      25             :     enum class LogLevel
      26             :     {
      27             :         Trace,    ///< Detailed internal information, typically only useful for developers and diagnostics.
      28             :         Debug,    ///< General debugging information, useful during development.
      29             :         Info,     ///< Standard messages that indicate normal operation.
      30             :         Warning,  ///< Something unexpected happened, but the system can continue running.
      31             :         Error,    ///< A significant issue occurred; some part of the system failed.
      32             :         Critical  ///< A severe error indicating the program might not continue running.
      33             :     };
      34             : 
      35             :     /**
      36             :      * @brief Converts a LogLevel enum value to its corresponding string representation.
      37             :      *
      38             :      * @param level The log level to convert.
      39             :      * @return A null-terminated string representing the log level (e.g., "Info", "Error").
      40             :      */
      41          14 :     static inline const char* logLevelToString(LogLevel level) noexcept
      42             :     {
      43          14 :         switch (level)
      44             :         {
      45           0 :         case LogLevel::Trace:    return "Trace";
      46           1 :         case LogLevel::Debug:    return "Debug";
      47          11 :         case LogLevel::Info:     return "Info";
      48           1 :         case LogLevel::Warning:  return "Warning";
      49           1 :         case LogLevel::Error:    return "Error";
      50           0 :         case LogLevel::Critical: return "Critical";
      51           0 :         default:                 return "UNKNOWN";
      52             :         }
      53             :     }
      54             : } // namespace openmodelviewer::core::log

Generated by: LCOV version 1.14