keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.car; |
| 18 | |
bkchoi | 5107653 | 2021-06-14 14:35:01 -0700 | [diff] [blame] | 19 | import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; |
| 20 | |
| 21 | import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; |
| 22 | |
Mayank Garg | 72c71d2 | 2021-02-03 23:54:45 -0800 | [diff] [blame] | 23 | /** |
| 24 | * Helper class for class tags for CarService. |
| 25 | */ |
| 26 | public final class CarLog { |
| 27 | private static final String PREFIX = "CAR."; |
| 28 | // Matcher to check if class name has keyword "Car" |
| 29 | private static final String MATCHER = ".*Car([A-Z].*|$)"; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 30 | |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 31 | public static final String TAG_AM = "CAR.AM"; |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 32 | public static final String TAG_APP_FOCUS = "CAR.APP_FOCUS"; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 33 | public static final String TAG_AUDIO = "CAR.AUDIO"; |
Yuncheol Heo | 7ac86e8 | 2020-12-02 09:12:35 -0800 | [diff] [blame] | 34 | public static final String TAG_CLUSTER = "CAR.CLUSTER"; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 35 | public static final String TAG_DIAGNOSTIC = "CAR.DIAGNOSTIC"; |
Changyeon Jo | c882f7a | 2021-03-09 08:41:41 -0800 | [diff] [blame] | 36 | public static final String TAG_EVS = "CAR.EVS"; |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 37 | public static final String TAG_HAL = "CAR.HAL"; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 38 | public static final String TAG_INPUT = "CAR.INPUT"; |
Simon Dai | 527eb55 | 2019-02-12 13:06:15 -0800 | [diff] [blame] | 39 | public static final String TAG_MEDIA = "CAR.MEDIA"; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 40 | public static final String TAG_POWER = "CAR.POWER"; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 41 | public static final String TAG_PROJECTION = "CAR.PROJECTION"; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 42 | public static final String TAG_SENSOR = "CAR.SENSOR"; |
| 43 | public static final String TAG_SERVICE = "CAR.SERVICE"; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 44 | public static final String TAG_STORAGE = "CAR.STORAGE"; |
Zhomart Mukhamejanov | 44570cb | 2021-06-07 10:23:13 -0700 | [diff] [blame] | 45 | public static final String TAG_TELEMETRY = "CAR.TELEMETRY"; |
Ashutosh Agarwal | 9743335 | 2021-10-04 18:14:58 +0000 | [diff] [blame] | 46 | public static final String TAG_TIME = "CAR.TIME"; |
Eric Jeong | ae2c04c | 2020-02-21 09:18:31 -0800 | [diff] [blame] | 47 | public static final String TAG_WATCHDOG = "CAR.WATCHDOG"; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 48 | |
Mayank Garg | 72c71d2 | 2021-02-03 23:54:45 -0800 | [diff] [blame] | 49 | /** |
| 50 | * Returns TAG that should be used for logging. |
| 51 | */ |
| 52 | public static String tagFor(Class<?> clazz) { |
| 53 | String tag = clazz.getSimpleName(); |
| 54 | // If class has a matcher, don't add prefix. |
| 55 | if (tag.matches(MATCHER)) return tag; |
| 56 | return PREFIX + tag; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 57 | } |
bkchoi | 5107653 | 2021-06-14 14:35:01 -0700 | [diff] [blame] | 58 | |
| 59 | @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE, |
| 60 | details = "private constructor") |
| 61 | private CarLog() { |
| 62 | throw new UnsupportedOperationException("contains only static methods"); |
| 63 | } |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 64 | } |