|
| 1 | +/** |
| 2 | + * Copyright (C) 2010-2016 eBusiness Information, Excilys Group |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * 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, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package org.androidannotations.helper; |
| 17 | + |
| 18 | +import org.androidannotations.holder.GeneratedClassHolder; |
| 19 | + |
| 20 | +public final class LogHelper { |
| 21 | + |
| 22 | + private static final int MAX_TAG_LEN = 23; |
| 23 | + |
| 24 | + private LogHelper() { |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Log tag length needs to be limited to 23. |
| 29 | + * |
| 30 | + * @see <a href= |
| 31 | + * "http://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String,%20int)"> |
| 32 | + * Log.isLoggable() JavaDoc</a> |
| 33 | + */ |
| 34 | + public static String trimLogTag(String tag) { |
| 35 | + if (tag == null) { |
| 36 | + return ""; |
| 37 | + } else if (tag.length() > MAX_TAG_LEN) { |
| 38 | + return tag.substring(0, MAX_TAG_LEN); |
| 39 | + } else { |
| 40 | + return tag; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Log tag length needs to be limited to 23. |
| 46 | + * |
| 47 | + * @see <a href= |
| 48 | + * "http://developer.android.com/reference/android/util/Log.html#isLoggable(java.lang.String,%20int)"> |
| 49 | + * Log.isLoggable() JavaDoc</a> |
| 50 | + */ |
| 51 | + public static String logTagForClassHolder(GeneratedClassHolder holder) { |
| 52 | + return trimLogTag(holder.getGeneratedClass().name()); |
| 53 | + } |
| 54 | +} |
0 commit comments