• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE;
20 
21 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport;
22 
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].*|$)";
30 
31     public static final String TAG_AM = "CAR.AM";
32     public static final String TAG_APP_FOCUS = "CAR.APP_FOCUS";
33     public static final String TAG_AUDIO = "CAR.AUDIO";
34     public static final String TAG_CLUSTER = "CAR.CLUSTER";
35     public static final String TAG_DIAGNOSTIC = "CAR.DIAGNOSTIC";
36     public static final String TAG_EVS = "CAR.EVS";
37     public static final String TAG_HAL = "CAR.HAL";
38     public static final String TAG_INPUT = "CAR.INPUT";
39     public static final String TAG_MEDIA = "CAR.MEDIA";
40     public static final String TAG_POWER = "CAR.POWER";
41     public static final String TAG_PROJECTION = "CAR.PROJECTION";
42     public static final String TAG_SENSOR = "CAR.SENSOR";
43     public static final String TAG_SERVICE = "CAR.SERVICE";
44     public static final String TAG_STORAGE = "CAR.STORAGE";
45     public static final String TAG_TELEMETRY = "CAR.TELEMETRY";
46     public static final String TAG_WATCHDOG = "CAR.WATCHDOG";
47 
48     /**
49      * Returns TAG that should be used for logging.
50      */
tagFor(Class<?> clazz)51     public static String tagFor(Class<?> clazz) {
52         String tag = clazz.getSimpleName();
53         // If class has a matcher, don't add prefix.
54         if (tag.matches(MATCHER)) return tag;
55         return PREFIX + tag;
56     }
57 
58     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE,
59             details = "private constructor")
CarLog()60     private CarLog() {
61         throw new UnsupportedOperationException("contains only static methods");
62     }
63 }
64