Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static String makeLogTag(String str) { final String LOG_PREFIX = "ccl_"; final int LOG_PREFIX_LENGTH = LOG_PREFIX.length(); final int MAX_LOG_TAG_LENGTH = 23; if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) { return LOG_PREFIX + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH - 1); } return LOG_PREFIX + str; } /** * WARNING: Don't use this when obfuscating class names with Proguard! */ public static String makeLogTag(Class<?> cls) { return makeLogTag(cls.getSimpleName()); } }