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 23 #include "common/rs_macros.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class RSB_EXPORT RSLog { 28 public: 29 enum Tag { RS = 0, RS_CLIENT }; 30 enum Level { LEVEL_INFO = 0, LEVEL_DEBUG, LEVEL_WARN, LEVEL_ERROR, LEVEL_FATAL }; 31 virtual ~RSLog() = default; 32 }; 33 34 void RSB_EXPORT RSLogOutput(RSLog::Tag tag, RSLog::Level level, const char* format, ...); 35 } // namespace Rosen 36 } // namespace OHOS 37 38 #define ROSEN_LOGI(format, ...) \ 39 RSLogOutput(RSLog::Tag::RS_CLIENT, RSLog::Level::LEVEL_INFO, format, ##__VA_ARGS__) 40 #define ROSEN_LOGD(format, ...) \ 41 RSLogOutput(RSLog::Tag::RS_CLIENT, RSLog::Level::LEVEL_DEBUG, format, ##__VA_ARGS__) 42 #define ROSEN_LOGE(format, ...) \ 43 RSLogOutput(RSLog::Tag::RS_CLIENT, RSLog::Level::LEVEL_ERROR, format, ##__VA_ARGS__) 44 #define ROSEN_LOGW(format, ...) \ 45 RSLogOutput(RSLog::Tag::RS_CLIENT, RSLog::Level::LEVEL_WARN, format, ##__VA_ARGS__) 46 #define ROSEN_LOGF(format, ...) \ 47 RSLogOutput(RSLog::Tag::RS_CLIENT, RSLog::Level::LEVEL_FATAL, format, ##__VA_ARGS__) 48 49 #define RS_LOGI(format, ...) \ 50 RSLogOutput(RSLog::Tag::RS, RSLog::Level::LEVEL_INFO, format, ##__VA_ARGS__) 51 #define RS_LOGD(format, ...) \ 52 RSLogOutput(RSLog::Tag::RS, RSLog::Level::LEVEL_DEBUG, format, ##__VA_ARGS__) 53 #define RS_LOGE(format, ...) \ 54 RSLogOutput(RSLog::Tag::RS, RSLog::Level::LEVEL_ERROR, format, ##__VA_ARGS__) 55 #define RS_LOGW(format, ...) \ 56 RSLogOutput(RSLog::Tag::RS, RSLog::Level::LEVEL_WARN, format, ##__VA_ARGS__) 57 #define RS_LOGF(format, ...) \ 58 RSLogOutput(RSLog::Tag::RS, RSLog::Level::LEVEL_FATAL, format, ##__VA_ARGS__) 59 60 #endif // RENDER_SERVICE_BASE_CORE_COMMON_RS_LOG_H 61