1 /* 2 * Copyright (C) 2022 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 LOCATION_LOG_H 17 #define LOCATION_LOG_H 18 19 #include "hilog/log.h" 20 21 namespace OHOS { 22 namespace Location { 23 #ifndef LOCATION_LOG_DOMAIN 24 #define LOCATION_LOG_DOMAIN 0xD002300 25 #endif 26 27 #undef LOCATION_LOG_TAG 28 #define LOCATION_LOG_TAG "Locator" 29 30 #ifndef LOCATION_FUNC_FMT 31 #define LOCATION_FUNC_FMT "[(%{public}s:%{public}d)]" 32 #endif 33 34 #ifndef LOCATION_FILE_NAME 35 #define LOCATION_FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 36 #endif 37 38 #ifndef LOCATION_FUNC_INFO 39 #define LOCATION_FUNC_INFO __FUNCTION__, __LINE__ 40 #endif 41 42 #define LBSLOGE(label, fmt, ...) do { \ 43 (void)HILOG_IMPL(LOG_CORE, LOG_ERROR, LOCATION_LOG_DOMAIN, label.tag, \ 44 LOCATION_FUNC_FMT fmt, LOCATION_FUNC_INFO, ##__VA_ARGS__); \ 45 } while (0) 46 47 #define LBSLOGW(label, fmt, ...) do { \ 48 (void)HILOG_IMPL(LOG_CORE, LOG_WARN, LOCATION_LOG_DOMAIN, label.tag, \ 49 LOCATION_FUNC_FMT fmt, LOCATION_FUNC_INFO, ##__VA_ARGS__); \ 50 } while (0) 51 52 #define LBSLOGI(label, fmt, ...) do { \ 53 (void)HILOG_IMPL(LOG_CORE, LOG_INFO, LOCATION_LOG_DOMAIN, label.tag, \ 54 LOCATION_FUNC_FMT fmt, LOCATION_FUNC_INFO, ##__VA_ARGS__); \ 55 } while (0) 56 57 #define LBSLOGD(label, fmt, ...) do { \ 58 (void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOCATION_LOG_DOMAIN, label.tag, \ 59 LOCATION_FUNC_FMT fmt, LOCATION_FUNC_INFO, ##__VA_ARGS__); \ 60 } while (0) 61 62 #define LBSLOGF(label, fmt, ...) do { \ 63 (void)HILOG_IMPL(LOG_CORE, HILOG_FATAL, LOCATION_LOG_DOMAIN, label.tag, \ 64 LOCATION_FUNC_FMT fmt, LOCATION_FUNC_INFO, ##__VA_ARGS__); \ 65 } while (0) 66 67 static constexpr OHOS::HiviewDFX::HiLogLabel GEO_CONVERT = {LOG_CORE, LOCATION_LOG_DOMAIN, "GeoConvert"}; 68 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR = {LOG_CORE, LOCATION_LOG_DOMAIN, "Locator"}; 69 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_STANDARD = {LOG_CORE, LOCATION_LOG_DOMAIN, "Locator_standard"}; 70 static constexpr OHOS::HiviewDFX::HiLogLabel SWITCH_CALLBACK = {LOG_CORE, LOCATION_LOG_DOMAIN, "SwitchCallback"}; 71 static constexpr OHOS::HiviewDFX::HiLogLabel GNSS_STATUS_CALLBACK = { 72 LOG_CORE, LOCATION_LOG_DOMAIN, "GnssStatusCallback" 73 }; 74 static constexpr OHOS::HiviewDFX::HiLogLabel NMEA_MESSAGE_CALLBACK = { 75 LOG_CORE, LOCATION_LOG_DOMAIN, "NmeaMessageCallback" 76 }; 77 static constexpr OHOS::HiviewDFX::HiLogLabel CACHED_LOCATIONS_CALLBACK = { 78 LOG_CORE, LOCATION_LOG_DOMAIN, "CachedLocationsCallback" 79 }; 80 static constexpr OHOS::HiviewDFX::HiLogLabel COUNTRY_CODE_CALLBACK = { 81 LOG_CORE, LOCATION_LOG_DOMAIN, "CountryCodeCallback" 82 }; 83 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATING_DATA_CALLBACK = { 84 LOG_CORE, LOCATION_LOG_DOMAIN, "LocatingDataCallback" 85 }; 86 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_CALLBACK = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocatorCallback"}; 87 static constexpr OHOS::HiviewDFX::HiLogLabel GNSS = {LOG_CORE, LOCATION_LOG_DOMAIN, "GnssAbility"}; 88 static constexpr OHOS::HiviewDFX::HiLogLabel GNSS_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "GnssAbilityTest"}; 89 static constexpr OHOS::HiviewDFX::HiLogLabel NETWORK = {LOG_CORE, LOCATION_LOG_DOMAIN, "NetworkAbility"}; 90 static constexpr OHOS::HiviewDFX::HiLogLabel NETWORK_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "NetworkAbilityTest"}; 91 static constexpr OHOS::HiviewDFX::HiLogLabel PASSIVE = {LOG_CORE, LOCATION_LOG_DOMAIN, "PassiveAbility"}; 92 static constexpr OHOS::HiviewDFX::HiLogLabel PASSIVE_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "PassiveAbilityTest"}; 93 static constexpr OHOS::HiviewDFX::HiLogLabel REQUEST_MANAGER = {LOG_CORE, LOCATION_LOG_DOMAIN, "RequestManager"}; 94 static constexpr OHOS::HiviewDFX::HiLogLabel REPORT_MANAGER = {LOG_CORE, LOCATION_LOG_DOMAIN, "ReportManager"}; 95 static constexpr OHOS::HiviewDFX::HiLogLabel COMMON_UTILS = {LOG_CORE, LOCATION_LOG_DOMAIN, "CommonUtils"}; 96 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_EVENT = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocatorEvent"}; 97 static constexpr OHOS::HiviewDFX::HiLogLabel COUNTRY_CODE = {LOG_CORE, LOCATION_LOG_DOMAIN, "CountryCode"}; 98 static constexpr OHOS::HiviewDFX::HiLogLabel VISIBILITY_CONTROLLER = { 99 LOG_CORE, LOCATION_LOG_DOMAIN, "VisibilityController" 100 }; 101 static constexpr OHOS::HiviewDFX::HiLogLabel FUSION_CONTROLLER = {LOG_CORE, LOCATION_LOG_DOMAIN, "FusionController"}; 102 static constexpr OHOS::HiviewDFX::HiLogLabel DISTRIBUTION_CONTROLLER = { 103 LOG_CORE, LOCATION_LOG_DOMAIN, "Location_Distribution" 104 }; 105 static constexpr OHOS::HiviewDFX::HiLogLabel HIVIEW_EVENT = {LOG_CORE, LOCATION_LOG_DOMAIN, "ChrEvent"}; 106 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_BACKGROUND_PROXY = { 107 LOG_CORE, LOCATION_LOG_DOMAIN, "LocatorBackgroundProxy" 108 }; 109 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATION_NAPI = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocationNapi"}; 110 static constexpr OHOS::HiviewDFX::HiLogLabel LOCATION_GNSS_GEOFENCE_CALLBACK = { 111 LOG_CORE, LOCATION_LOG_DOMAIN, "LocationGnssGeofenceCallback" 112 }; 113 static constexpr OHOS::HiviewDFX::HiLogLabel NAPI_UTILS = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocationNapiUtils"}; 114 } // namespace Location 115 } // namespace OHOS 116 #endif // LOCATION_LOG_H 117