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 | |
Mayank Garg | 72c71d2 | 2021-02-03 23:54:45 -0800 | [diff] [blame^] | 19 | /** |
| 20 | * Helper class for class tags for CarService. |
| 21 | */ |
| 22 | public final class CarLog { |
| 23 | private static final String PREFIX = "CAR."; |
| 24 | // Matcher to check if class name has keyword "Car" |
| 25 | private static final String MATCHER = ".*Car([A-Z].*|$)"; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 26 | |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 27 | public static final String TAG_AM = "CAR.AM"; |
Vitalii Tomkiv | 4637147 | 2016-05-23 16:55:22 -0700 | [diff] [blame] | 28 | public static final String TAG_APP_FOCUS = "CAR.APP_FOCUS"; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 29 | public static final String TAG_AUDIO = "CAR.AUDIO"; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 30 | public static final String TAG_DIAGNOSTIC = "CAR.DIAGNOSTIC"; |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 31 | public static final String TAG_HAL = "CAR.HAL"; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 32 | public static final String TAG_INPUT = "CAR.INPUT"; |
Simon Dai | 527eb55 | 2019-02-12 13:06:15 -0800 | [diff] [blame] | 33 | public static final String TAG_MEDIA = "CAR.MEDIA"; |
Keun-young Park | 4aeb4bf | 2015-12-08 18:31:33 -0800 | [diff] [blame] | 34 | public static final String TAG_PACKAGE = "CAR.PACKAGE"; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 35 | public static final String TAG_POWER = "CAR.POWER"; |
Keun-young Park | 4727da3 | 2016-05-31 10:00:51 -0700 | [diff] [blame] | 36 | public static final String TAG_PROJECTION = "CAR.PROJECTION"; |
keunyoung | 4b0212c | 2015-10-29 17:11:57 -0700 | [diff] [blame] | 37 | public static final String TAG_SENSOR = "CAR.SENSOR"; |
| 38 | public static final String TAG_SERVICE = "CAR.SERVICE"; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 39 | public static final String TAG_STORAGE = "CAR.STORAGE"; |
Keun young Park | 7af7d6c | 2019-09-12 10:31:48 -0700 | [diff] [blame] | 40 | public static final String TAG_USER = "CAR.USER"; |
Eric Jeong | ae2c04c | 2020-02-21 09:18:31 -0800 | [diff] [blame] | 41 | public static final String TAG_WATCHDOG = "CAR.WATCHDOG"; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 42 | |
Mayank Garg | 72c71d2 | 2021-02-03 23:54:45 -0800 | [diff] [blame^] | 43 | /** |
| 44 | * Returns TAG that should be used for logging. |
| 45 | */ |
| 46 | public static String tagFor(Class<?> clazz) { |
| 47 | String tag = clazz.getSimpleName(); |
| 48 | // If class has a matcher, don't add prefix. |
| 49 | if (tag.matches(MATCHER)) return tag; |
| 50 | return PREFIX + tag; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 51 | } |
keunyoung | ca51507 | 2015-07-10 12:21:47 -0700 | [diff] [blame] | 52 | } |