1 /* 2 * Copyright (C) 2021 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 SERVICES_INCLUDE_GLOBAL_H 17 #define SERVICES_INCLUDE_GLOBAL_H 18 19 #include <sys/time.h> 20 21 #include <cerrno> 22 #include <ctime> 23 24 #include "hilog/log.h" 25 #include "ipc_object_stub.h" 26 #include "iremote_broker.h" 27 #include "peer_holder.h" 28 #include "refbase.h" 29 30 namespace OHOS { 31 namespace MiscServices { 32 using BRemoteObject = IPCObjectStub; 33 34 #define LOG_INFO(fmt, args...) \ 35 LogTimeStamp(); \ 36 printf("I %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) 37 38 #define LOG_ERROR(fmt, args...) \ 39 LogTimeStamp(); \ 40 printf("E %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) 41 42 #define LOG_WARNING(fmt, args...) \ 43 LogTimeStamp(); \ 44 printf("W %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) 45 46 #if DEBUG 47 #define LOG_DEBUG(fmt, args...) \ 48 LogTimeStamp(); \ 49 printf("D %s:%d %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args) 50 #else 51 #define LOG_DEBUG(fmt, args...) 52 #endif 53 54 void LogTimeStamp(); 55 56 // Error Code 57 namespace ErrorCode { 58 // Error Code definition in the input method management system 59 constexpr int32_t NO_ERROR = 0; 60 61 // system service error 62 constexpr int32_t ERROR_NULL_POINTER = 1; 63 constexpr int32_t ERROR_KEYWORD_NOT_FOUND = 26; 64 constexpr int32_t ERROR_ENABLE_IME = 27; 65 66 constexpr int32_t ERROR_ENABLE_SECURITY_MODE = 32; 67 }; // namespace ErrorCode 68 69 constexpr HiviewDFX::HiLogLabel g_SMALL_SERVICES_LABEL = { LOG_CORE, 0xD001C00, "ImsaKit" }; 70 71 #define IMSA_HILOGD(fmt, ...) \ 72 (void)OHOS::HiviewDFX::HiLog::Debug(OHOS::MiscServices::g_SMALL_SERVICES_LABEL, \ 73 "line: %{public}d, function: %{public}s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__) 74 #define IMSA_HILOGE(fmt, ...) \ 75 (void)OHOS::HiviewDFX::HiLog::Error(OHOS::MiscServices::g_SMALL_SERVICES_LABEL, \ 76 "line: %{public}d, function: %{public}s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__) 77 #define IMSA_HILOGF(fmt, ...) \ 78 (void)OHOS::HiviewDFX::HiLog::Fatal(OHOS::MiscServices::g_SMALL_SERVICES_LABEL, \ 79 "line: %{public}d, function: %{public}s," fmt, __LINE__FILE__, __FUNCTION__, ##__VA_ARGS__) 80 #define IMSA_HILOGI(fmt, ...) \ 81 (void)OHOS::HiviewDFX::HiLog::Info(OHOS::MiscServices::g_SMALL_SERVICES_LABEL, \ 82 "line: %{public}d, function: %{public}s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__) 83 #define IMSA_HILOGW(fmt, ...) \ 84 (void)OHOS::HiviewDFX::HiLog::Warn(OHOS::MiscServices::g_SMALL_SERVICES_LABEL, \ 85 "line: %{public}d, function: %{public}s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__) 86 } // namespace MiscServices 87 } // namespace OHOS 88 #endif // SERVICES_INCLUDE_GLOBAL_H 89