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
21namespace OHOS {
22namespace 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
67static constexpr OHOS::HiviewDFX::HiLogLabel GEO_CONVERT = {LOG_CORE, LOCATION_LOG_DOMAIN, "GeoConvert"};
68static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR = {LOG_CORE, LOCATION_LOG_DOMAIN, "Locator"};
69static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_STANDARD = {LOG_CORE, LOCATION_LOG_DOMAIN, "Locator_standard"};
70static constexpr OHOS::HiviewDFX::HiLogLabel SWITCH_CALLBACK = {LOG_CORE, LOCATION_LOG_DOMAIN, "SwitchCallback"};
71static constexpr OHOS::HiviewDFX::HiLogLabel GNSS_STATUS_CALLBACK = {
72    LOG_CORE, LOCATION_LOG_DOMAIN, "GnssStatusCallback"
73};
74static constexpr OHOS::HiviewDFX::HiLogLabel NMEA_MESSAGE_CALLBACK = {
75    LOG_CORE, LOCATION_LOG_DOMAIN, "NmeaMessageCallback"
76};
77static constexpr OHOS::HiviewDFX::HiLogLabel CACHED_LOCATIONS_CALLBACK = {
78    LOG_CORE, LOCATION_LOG_DOMAIN, "CachedLocationsCallback"
79};
80static constexpr OHOS::HiviewDFX::HiLogLabel COUNTRY_CODE_CALLBACK = {
81    LOG_CORE, LOCATION_LOG_DOMAIN, "CountryCodeCallback"
82};
83static constexpr OHOS::HiviewDFX::HiLogLabel LOCATING_DATA_CALLBACK = {
84    LOG_CORE, LOCATION_LOG_DOMAIN, "LocatingDataCallback"
85};
86static constexpr OHOS::HiviewDFX::HiLogLabel LOCATION_ERR_CALLBACK = {
87    LOG_CORE, LOCATION_LOG_DOMAIN, "LocationErrorCallback"
88};
89static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_CALLBACK = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocatorCallback"};
90static constexpr OHOS::HiviewDFX::HiLogLabel GNSS = {LOG_CORE, LOCATION_LOG_DOMAIN, "GnssAbility"};
91static constexpr OHOS::HiviewDFX::HiLogLabel GNSS_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "GnssAbilityTest"};
92static constexpr OHOS::HiviewDFX::HiLogLabel NETWORK = {LOG_CORE, LOCATION_LOG_DOMAIN, "NetworkAbility"};
93static constexpr OHOS::HiviewDFX::HiLogLabel NETWORK_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "NetworkAbilityTest"};
94static constexpr OHOS::HiviewDFX::HiLogLabel PASSIVE = {LOG_CORE, LOCATION_LOG_DOMAIN, "PassiveAbility"};
95static constexpr OHOS::HiviewDFX::HiLogLabel PASSIVE_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "PassiveAbilityTest"};
96static constexpr OHOS::HiviewDFX::HiLogLabel REQUEST_MANAGER = {LOG_CORE, LOCATION_LOG_DOMAIN, "RequestManager"};
97static constexpr OHOS::HiviewDFX::HiLogLabel REPORT_MANAGER = {LOG_CORE, LOCATION_LOG_DOMAIN, "ReportManager"};
98static constexpr OHOS::HiviewDFX::HiLogLabel COMMON_UTILS = {LOG_CORE, LOCATION_LOG_DOMAIN, "CommonUtils"};
99static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_EVENT = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocatorEvent"};
100static constexpr OHOS::HiviewDFX::HiLogLabel COUNTRY_CODE = {LOG_CORE, LOCATION_LOG_DOMAIN, "CountryCode"};
101static constexpr OHOS::HiviewDFX::HiLogLabel VISIBILITY_CONTROLLER = {
102    LOG_CORE, LOCATION_LOG_DOMAIN, "VisibilityController"
103};
104static constexpr OHOS::HiviewDFX::HiLogLabel FUSION_CONTROLLER = {LOG_CORE, LOCATION_LOG_DOMAIN, "FusionController"};
105static constexpr OHOS::HiviewDFX::HiLogLabel DISTRIBUTION_CONTROLLER = {
106    LOG_CORE, LOCATION_LOG_DOMAIN, "Location_Distribution"
107};
108static constexpr OHOS::HiviewDFX::HiLogLabel HIVIEW_EVENT = {LOG_CORE, LOCATION_LOG_DOMAIN, "ChrEvent"};
109static constexpr OHOS::HiviewDFX::HiLogLabel LOCATOR_BACKGROUND_PROXY = {
110    LOG_CORE, LOCATION_LOG_DOMAIN, "LocatorBackgroundProxy"
111};
112static constexpr OHOS::HiviewDFX::HiLogLabel LOCATION_NAPI = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocationNapi"};
113static constexpr OHOS::HiviewDFX::HiLogLabel LOCATION_GNSS_GEOFENCE_CALLBACK = {
114    LOG_CORE, LOCATION_LOG_DOMAIN, "LocationGnssGeofenceCallback"
115};
116static constexpr OHOS::HiviewDFX::HiLogLabel NAPI_UTILS = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocationNapiUtils"};
117static constexpr OHOS::HiviewDFX::HiLogLabel GEOFENCE_SDK = {
118    LOG_CORE, LOCATION_LOG_DOMAIN, "geofenceSdk"
119};
120static constexpr OHOS::HiviewDFX::HiLogLabel GEOFENCE_SDK_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "GeofenceSdkTest"};
121static constexpr OHOS::HiviewDFX::HiLogLabel LOCATION_CAPI = {LOG_CORE, LOCATION_LOG_DOMAIN, "LocationCapi"};
122static constexpr OHOS::HiviewDFX::HiLogLabel FENCE_EXTENSION = {
123    LOG_CORE, LOCATION_LOG_DOMAIN, "FenceExtension"
124};
125} // namespace Location
126} // namespace OHOS
127#endif // LOCATION_LOG_H
128