1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_BASE_CORE_COMMON_RS_LOG_H 17 #define RENDER_SERVICE_BASE_CORE_COMMON_RS_LOG_H 18 19 // NOT redundant, we need PRIu64/PRId64 for logging 20 #include <cinttypes> 21 #include <string> 22 #include <hilog/log.h> 23 24 #include "common/rs_macros.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 // The "0xD001400" is the domain ID for graphic module that alloted by the OS. 29 constexpr OHOS::HiviewDFX::HiLogLabel LABEL_RS = { LOG_CORE, 0xD001400, "OHOS::RS" }; 30 constexpr OHOS::HiviewDFX::HiLogLabel LABEL_ROSEN = { LOG_CORE, 0xD001400, "OHOS::ROSEN" }; 31 32 class RSB_EXPORT RSLog { 33 public: 34 enum Tag { RS = 0, RS_CLIENT }; 35 enum Level { LEVEL_INFO = 0, LEVEL_DEBUG, LEVEL_WARN, LEVEL_ERROR, LEVEL_FATAL }; 36 virtual ~RSLog() = default; 37 }; 38 39 void RSB_EXPORT RSLogOutput(RSLog::Tag tag, RSLog::Level level, const char* format, ...); 40 } // namespace Rosen 41 } // namespace OHOS 42 43 #undef LOG_DOMAIN 44 #define LOG_DOMAIN 0xD001406 45 46 #undef LOG_TAG 47 #define LOG_TAG "OHOS::RS" 48 49 #define ROSEN_LOGI(format, ...) \ 50 HILOG_INFO(LOG_CORE, format, ##__VA_ARGS__) 51 #define ROSEN_LOGD(format, ...) \ 52 HILOG_DEBUG(LOG_CORE, format, ##__VA_ARGS__) 53 #define ROSEN_LOGE(format, ...) \ 54 HILOG_ERROR(LOG_CORE, format, ##__VA_ARGS__) 55 #define ROSEN_LOGW(format, ...) \ 56 HILOG_WARN(LOG_CORE, format, ##__VA_ARGS__) 57 #define ROSEN_LOGF(format, ...) \ 58 HILOG_FATAL(LOG_CORE, format, ##__VA_ARGS__) 59 60 #define RS_LOGI(format, ...) \ 61 HILOG_INFO(LOG_CORE, format, ##__VA_ARGS__) 62 #define RS_LOGD(format, ...) \ 63 HILOG_DEBUG(LOG_CORE, format, ##__VA_ARGS__) 64 #define RS_LOGE(format, ...) \ 65 HILOG_ERROR(LOG_CORE, format, ##__VA_ARGS__) 66 #define RS_LOGW(format, ...) \ 67 HILOG_WARN(LOG_CORE, format, ##__VA_ARGS__) 68 #define RS_LOGF(format, ...) \ 69 HILOG_FATAL(LOG_CORE, format, ##__VA_ARGS__) 70 71 #endif // RENDER_SERVICE_BASE_CORE_COMMON_RS_LOG_H 72