LCOV - code coverage report
Current view: top level - Source - logging.hpp (source / functions) Coverage Total Hit
Test: coverage Lines: 100.0 % 3 3
Test Date: 2026-03-02 16:42:41 Functions: - 0 0

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "definition.hpp"
       4              : 
       5              : std::string backtrace(int skip = 1);
       6              : 
       7              : /* A little logging facility
       8              :  * Can redirect non GUI output to file for debug purpose
       9              :  */
      10              : namespace Logging {
      11              : enum COMType { CT_xboard = 0, CT_uci = 1, CT_pretty = 2 };
      12              : extern COMType ct;
      13              : 
      14              : enum LogLevel : uint8_t { 
      15              :    logTrace = 0, 
      16              :    logDebug = 1, 
      17              :    logInfo = 2, 
      18              :    logInfoPrio = 3, 
      19              :    logWarn = 4, 
      20              :    logGUI = 5, 
      21              :    logError = 6, 
      22              :    logFatal = 7, 
      23              :    logOff = 8, 
      24              :    logMax = 9 
      25              : };
      26              : 
      27              : inline constexpr array1d<std::string_view,3> _protocolComment = {"# ", "info string ", ""};
      28              : 
      29              : inline constexpr array1d<std::string_view,logMax> _levelNames = {
      30              :    "Trace ", 
      31              :    "Debug ", 
      32              :    "Info  ", 
      33              :    "Info  ", 
      34              :    "Warn  ", 
      35              :    "",  
      36              :    "Error ", 
      37              :    "Fatal ", 
      38              :    "Off..."
      39              : };
      40              : 
      41              : #ifdef WITH_FMTLIB   
      42              : inline constexpr array1d<fmt::text_style,logMax> _levelStyles = {
      43              :          fmt::fg(fmt::color::light_gray) | fmt::emphasis::faint,
      44              :          fmt::fg(fmt::color::dark_green) | fmt::emphasis::italic,
      45              :          fmt::fg(fmt::color::sky_blue) ,
      46              :          fmt::fg(fmt::color::lime_green) | fmt::emphasis::bold,
      47              :          fmt::fg(fmt::color::orange_red) | fmt::emphasis::bold,
      48              :          {},
      49              :          fmt::fg(fmt::color::crimson) | fmt::emphasis::bold,
      50              :          fmt::fg(fmt::color::pale_violet_red) | fmt::emphasis::bold,
      51              :          {}
      52              :          };
      53              : #endif
      54              : 
      55              : class LogIt {
      56              :    friend void init();
      57              :    friend void finalize();
      58              : 
      59              :   public:
      60        43942 :    explicit LogIt(LogLevel loglevel): _level(loglevel) {}
      61              :    template<typename T> FORCE_FINLINE Logging::LogIt& operator<<(T const& value) {
      62        49243 :       _buffer << value;
      63        14094 :       return *this;
      64              :    }
      65              :    ~LogIt();
      66              : 
      67              :   private:
      68              :    static std::mutex  _mutex;
      69              :    std::ostringstream _buffer;
      70              :    LogLevel           _level;
      71              :    static std::unique_ptr<std::ofstream> _of;
      72              : };
      73              : 
      74              : void hellooo();
      75              : 
      76              : void init();
      77              : 
      78              : void finalize();
      79              : } // namespace Logging
        

Generated by: LCOV version 2.0-1