Updated on 2022-03-13 GMT+08:00

HIAILog

Log class of HiAI. This class is defined in log.h.

      class HIAILog {
      public:
        /**
        * @ingroup hiaiengine
        * @brief   Obtain the HIAILog pointer.
        */
        HIAI_LIB_INTERNAL static HIAILog* GetInstance();

        /**
        * @ingroup hiaiengine
        * @brief: Whether to initialize HiAILog or not
        * @return: Whether to initialize HiAILog or not. "true" indciates yes.
        */
        HIAI_LIB_INTERNAL bool IsInit() { return isInitFlag; }

        /**
        * @ingroup hiaiengine
        * @brief   Obtain the log output level.
        * @return: Log output level
        */
        HIAI_LIB_INTERNAL uint32_t HIAIGetCurLogLevel();

        /**
        * @ingroup hiaiengine
        * @brief   Check whether the log needs to be output.
        * @param [in]errorCode: Error code of a message
        * @return   Whether a log can be output
        */
        HIAI_LIB_INTERNAL bool HIAILogOutputEnable(const uint32_t errorCode);

        /**
        * @ingroup hiaiengine
        * @brief   Level corresponding to the log
        * @param [in]logLevel: Log level in the macro definition
        */
        HIAI_LIB_INTERNAL std::string HIAILevelName(const uint32_t logLevel);

        /**
        * @ingroup hiaiengine
        * @brief   Output a log.
        * @param [in]moudleID: Component ID defined by enum
        * @param [in]logLevel: Log level in the macro definition
        * @param [in]strLog: Output log content
        */
        HIAI_LIB_INTERNAL void HIAISaveLog(const int32_t moudleID,
            const uint32_t logLevel, const char* strLog);
      protected:
        /**
        * @ingroup hiaiengine
        * @brief   HIAILog constructor
        */
        HIAI_LIB_INTERNAL HIAILog();
        HIAI_LIB_INTERNAL ~HIAILog() {}
      private:
        /**
        * @ingroup hiaiengine
        * @brief   HIAILog initialization function
        */
        HIAI_LIB_INTERNAL void Init();
        HIAI_LIB_INTERNAL HIAILog(const HIAILog&) = delete;
        HIAI_LIB_INTERNAL HIAILog(HIAILog&&) = delete;
        HIAI_LIB_INTERNAL HIAILog& operator=(const HIAILog&) = delete;
        HIAI_LIB_INTERNAL HIAILog& operator=(HIAILog&&) = delete;
      private:
        HIAI_LIB_INTERNAL static std::mutex mutexHandle;
        uint32_t outputLogLevel;
        std::map<uint32_t, std::string> levelName;
        std::map<std::string, uint32_t> levelNum;
        static bool isInitFlag;
    };