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_PACKAGE_MANAGER = 12; 64 constexpr int32_t ERROR_KEYWORD_NOT_FOUND = 26; 65 constexpr int32_t ERROR_ENABLE_IME = 27; 66 67 constexpr int32_t ERROR_ENABLE_SECURITY_MODE = 32; 68 }; // namespace ErrorCode 69 70 constexpr HiviewDFX::HiLogLabel g_SMALL_SERVICES_LABEL = { LOG_CORE, 0xD001C10, "ImsaKit" }; 71 72 #define IMSA_HILOGD(fmt, ...) \ 73 (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain, \ 74 OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \ 75 __FUNCTION__, ##__VA_ARGS__) 76 #define IMSA_HILOGE(fmt, ...) \ 77 (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain, \ 78 OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \ 79 __FUNCTION__, ##__VA_ARGS__) 80 #define IMSA_HILOGF(fmt, ...) \ 81 (void)HILOG_IMPL(LOG_CORE, LOG_FATAL, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain, \ 82 OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \ 83 __FUNCTION__, ##__VA_ARGS__) 84 #define IMSA_HILOGI(fmt, ...) \ 85 (void)HILOG_IMPL(LOG_CORE, LOG_INFO, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain, \ 86 OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \ 87 __FUNCTION__, ##__VA_ARGS__) 88 #define IMSA_HILOGW(fmt, ...) \ 89 (void)HILOG_IMPL(LOG_CORE, LOG_WARN, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain, \ 90 OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \ 91 __FUNCTION__, ##__VA_ARGS__) 92 } // namespace MiscServices 93 } // namespace OHOS 94 #endif // SERVICES_INCLUDE_GLOBAL_H 95