Skip to content

File Logging.hpp

File List > api > cppSDK > SDKBase > Logging.hpp

Go to the documentation of this file

#ifndef __CORE_LITE_LOGGING_HPP__
#define __CORE_LITE_LOGGING_HPP__

#include "spdlog/spdlog.h"
#include "spdlog/sinks/rotating_file_sink.h"

namespace ManusSDK
{
    class Log
    {
    public:
        //Simple
        static void Debug(const char* p_Tag, const char* p_String);
        static void Info(const char* p_Tag, const char* p_String);
        static void Warn(const char* p_Tag, const char* p_String);
        static void Error(const char* p_Tag, const char* p_String);

        //Templated
        template<typename... Args>
        static void Debug(const char* p_Tag, const char* p_Format, Args &&...p_Args)
        {
            std::string t_Log = fmt::format(p_Format, std::forward<Args>(p_Args)...);
            Debug(p_Tag, t_Log.c_str());
        }

        template<typename... Args>
        static void Info(const char* p_Tag, const char* p_Format, Args &&...p_Args)
        {
            std::string t_Log = fmt::format(p_Format, std::forward<Args>(p_Args)...);
            Info(p_Tag, t_Log.c_str());
        }

        template<typename... Args>
        static void Warn(const char* p_Tag, const char* p_Format, Args &&...p_Args)
        {
            std::string t_Log = fmt::format(p_Format, std::forward<Args>(p_Args)...);
            Warn(p_Tag, t_Log.c_str());
        }

        template<typename... Args>
        static void Error(const char* p_Tag, const char* p_Format, Args &&...p_Args)
        {
            std::string t_Log = fmt::format(p_Format, std::forward<Args>(p_Args)...);
            Error(p_Tag, t_Log.c_str());
        }

        static void RegisterCallback(void* p_Function);
    };
}

#endif