• Lv0
    粉丝0

积分1 / 贡献0

提问1答案被采纳0文章0

作者动态

    为什么日志没有输出

    webster 显示全部楼层 发表于 2024-4-28 03:44:37
    #ifndef OHOS_SERIALSERVICE_LOG_WRAPPER_H
    #define OHOS_SERIALSERVICE_LOG_WRAPPER_H
    
    #include "hilog/log.h"
    
    #ifdef LOG_DOMAIN
    #undef LOG_DOMAIN
    #endif
    
    #ifdef LOG_TAG
    #undef LOG_TAG
    #endif
    
    namespace OHOS {
    namespace Serial {
    
        using namespace OHOS::HiviewDFX;
        static constexpr unsigned int LOG_DOMAIN = 0xD006666;
        static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "SerialService"};
    
        #define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
        //#define FORMAT(fmt, ...) "[%{public}s:%{public}d] %{public}s# " fmt, FILENAME, __LINE__, __FUNCTION__, ##__VA_ARGS__
        //#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
    
        /*
            #ifndef __cplusplus
    
                #define SERIALSERVICE_LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
                #define SERIALSERVICE_LOGI(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
                #define SERIALSERVICE_LOGW(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
                #define SERIALSERVICE_LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
                #define SERIALSERVICE_LOGF(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
    
            #else
        */
    
    #define SERIALSERVICE_LOGE(fmt, ...) HiLog::Error( \
        LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
    
    #define SERIALSERVICE_LOGW(fmt, ...) HiLog::Warn( \
        LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
    
    #define SERIALSERVICE_LOGI(fmt, ...) HiLog::Info( \
        LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
    
    #define SERIALSERVICE_LOGF(fmt, ...) HiLog::Fatal( \
        LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
    
    #define SERIALSERVICE_LOGD(fmt, ...) HiLog::Debug( \
        LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
    
        //#endif
    }
    }
    #endif // OHOS_SERIALSERVICE_LOG_WRAPPER_H

    您尚未登录,无法参与评论,登录后可以:
    参与开源共建问题交流
    认同或收藏高质量问答
    获取积分成为开源共建先驱

    精彩评论1

    深开鸿_王石

    沙发 发表于 2024-4-28 18:26:40
    ndk里用hilog可以看:https://forums.openharmony.cn/fo ... tid=1983&extra=;若是设备上的应用,那就随便找个exe看看就好,比如hidumper啥的

    Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

    返回顶部