122736c2fSopenharmony_ci/*
222736c2fSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
322736c2fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
422736c2fSopenharmony_ci * you may not use this file except in compliance with the License.
522736c2fSopenharmony_ci * You may obtain a copy of the License at
622736c2fSopenharmony_ci *
722736c2fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
822736c2fSopenharmony_ci *
922736c2fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1022736c2fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1122736c2fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1222736c2fSopenharmony_ci * See the License for the specific language governing permissions and
1322736c2fSopenharmony_ci * limitations under the License.
1422736c2fSopenharmony_ci */
1522736c2fSopenharmony_ci
1622736c2fSopenharmony_ci#ifndef SERVICES_INCLUDE_GLOBAL_H
1722736c2fSopenharmony_ci#define SERVICES_INCLUDE_GLOBAL_H
1822736c2fSopenharmony_ci
1922736c2fSopenharmony_ci#include <sys/time.h>
2022736c2fSopenharmony_ci
2122736c2fSopenharmony_ci#include <cerrno>
2222736c2fSopenharmony_ci#include <ctime>
2322736c2fSopenharmony_ci
2422736c2fSopenharmony_ci#include "hilog/log.h"
2522736c2fSopenharmony_ci#include "ipc_object_stub.h"
2622736c2fSopenharmony_ci#include "iremote_broker.h"
2722736c2fSopenharmony_ci#include "peer_holder.h"
2822736c2fSopenharmony_ci#include "refbase.h"
2922736c2fSopenharmony_ci
3022736c2fSopenharmony_cinamespace OHOS {
3122736c2fSopenharmony_cinamespace MiscServices {
3222736c2fSopenharmony_ciusing BRemoteObject = IPCObjectStub;
3322736c2fSopenharmony_ci
3422736c2fSopenharmony_ci#define LOG_INFO(fmt, args...) \
3522736c2fSopenharmony_ci    LogTimeStamp();            \
3622736c2fSopenharmony_ci    printf("I %s:%d  %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
3722736c2fSopenharmony_ci
3822736c2fSopenharmony_ci#define LOG_ERROR(fmt, args...) \
3922736c2fSopenharmony_ci    LogTimeStamp();             \
4022736c2fSopenharmony_ci    printf("E %s:%d  %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
4122736c2fSopenharmony_ci
4222736c2fSopenharmony_ci#define LOG_WARNING(fmt, args...) \
4322736c2fSopenharmony_ci    LogTimeStamp();               \
4422736c2fSopenharmony_ci    printf("W %s:%d  %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
4522736c2fSopenharmony_ci
4622736c2fSopenharmony_ci#if DEBUG
4722736c2fSopenharmony_ci#define LOG_DEBUG(fmt, args...) \
4822736c2fSopenharmony_ci    LogTimeStamp();             \
4922736c2fSopenharmony_ci    printf("D %s:%d  %s - " fmt, basename(__FILE__), __LINE__, __FUNCTION__, ##args)
5022736c2fSopenharmony_ci#else
5122736c2fSopenharmony_ci#define LOG_DEBUG(fmt, args...)
5222736c2fSopenharmony_ci#endif
5322736c2fSopenharmony_ci
5422736c2fSopenharmony_civoid LogTimeStamp();
5522736c2fSopenharmony_ci
5622736c2fSopenharmony_ci// Error Code
5722736c2fSopenharmony_cinamespace ErrorCode {
5822736c2fSopenharmony_ci// Error Code definition in the input method management system
5922736c2fSopenharmony_ciconstexpr int32_t NO_ERROR = 0;
6022736c2fSopenharmony_ci
6122736c2fSopenharmony_ci// system service error
6222736c2fSopenharmony_ciconstexpr int32_t ERROR_NULL_POINTER = 1;
6322736c2fSopenharmony_ciconstexpr int32_t ERROR_PACKAGE_MANAGER = 12;
6422736c2fSopenharmony_ciconstexpr int32_t ERROR_KEYWORD_NOT_FOUND = 26;
6522736c2fSopenharmony_ciconstexpr int32_t ERROR_ENABLE_IME = 27;
6622736c2fSopenharmony_ci
6722736c2fSopenharmony_ciconstexpr int32_t ERROR_ENABLE_SECURITY_MODE = 32;
6822736c2fSopenharmony_ci}; // namespace ErrorCode
6922736c2fSopenharmony_ci
7022736c2fSopenharmony_ciconstexpr HiviewDFX::HiLogLabel g_SMALL_SERVICES_LABEL = { LOG_CORE, 0xD001C10, "ImsaKit" };
7122736c2fSopenharmony_ci
7222736c2fSopenharmony_ci#define IMSA_HILOGD(fmt, ...)                                                                                    \
7322736c2fSopenharmony_ci    (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain,                     \
7422736c2fSopenharmony_ci        OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \
7522736c2fSopenharmony_ci        __FUNCTION__, ##__VA_ARGS__)
7622736c2fSopenharmony_ci#define IMSA_HILOGE(fmt, ...)                                                                                    \
7722736c2fSopenharmony_ci    (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain,                     \
7822736c2fSopenharmony_ci        OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \
7922736c2fSopenharmony_ci        __FUNCTION__, ##__VA_ARGS__)
8022736c2fSopenharmony_ci#define IMSA_HILOGF(fmt, ...)                                                                                    \
8122736c2fSopenharmony_ci    (void)HILOG_IMPL(LOG_CORE, LOG_FATAL, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain,                     \
8222736c2fSopenharmony_ci        OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \
8322736c2fSopenharmony_ci        __FUNCTION__, ##__VA_ARGS__)
8422736c2fSopenharmony_ci#define IMSA_HILOGI(fmt, ...)                                                                                    \
8522736c2fSopenharmony_ci    (void)HILOG_IMPL(LOG_CORE, LOG_INFO, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain,                      \
8622736c2fSopenharmony_ci        OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \
8722736c2fSopenharmony_ci        __FUNCTION__, ##__VA_ARGS__)
8822736c2fSopenharmony_ci#define IMSA_HILOGW(fmt, ...)                                                                                    \
8922736c2fSopenharmony_ci    (void)HILOG_IMPL(LOG_CORE, LOG_WARN, OHOS::MiscServices::g_SMALL_SERVICES_LABEL.domain,                      \
9022736c2fSopenharmony_ci        OHOS::MiscServices::g_SMALL_SERVICES_LABEL.tag, "line: %{public}d, function: %{public}s," fmt, __LINE__, \
9122736c2fSopenharmony_ci        __FUNCTION__, ##__VA_ARGS__)
9222736c2fSopenharmony_ci} // namespace MiscServices
9322736c2fSopenharmony_ci} // namespace OHOS
9422736c2fSopenharmony_ci#endif // SERVICES_INCLUDE_GLOBAL_H
95