1 /* 2 * Copyright (c) 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 RD_LOG_PRINT_H 17 #define RD_LOG_PRINT_H 18 19 #include <string> 20 21 namespace DocumentDB { 22 constexpr const char *LOG_TAG_DOC = "GAUSSDB_RD"; 23 24 class LogPrint { 25 public: 26 enum class Level { 27 LEVEL_DEBUG, 28 LEVEL_INFO, 29 LEVEL_WARN, 30 LEVEL_ERROR, 31 LEVEL_FATAL 32 }; 33 34 static void Log(Level level, const char *tag, const char *format, ...); 35 }; 36 } // namespace DocumentDB 37 38 #define NO_LOG(...) // No log in normal and release. Used for the convenience when deep debugging 39 #define GLOGD(...) LogPrint::Log(LogPrint::Level::LEVEL_DEBUG, LOG_TAG_DOC, __VA_ARGS__) 40 #define GLOGI(...) LogPrint::Log(LogPrint::Level::LEVEL_INFO, LOG_TAG_DOC, __VA_ARGS__) 41 #define GLOGW(...) LogPrint::Log(LogPrint::Level::LEVEL_WARN, LOG_TAG_DOC, __VA_ARGS__) 42 #define GLOGE(...) LogPrint::Log(LogPrint::Level::LEVEL_ERROR, LOG_TAG_DOC, __VA_ARGS__) 43 #define GLOGF(...) LogPrint::Log(LogPrint::Level::LEVEL_FATAL, LOG_TAG_DOC, __VA_ARGS__) 44 #endif // LOG_PRINT_H