Example usage for android.util Log println

List of usage examples for android.util Log println

Introduction

In this page you can find the example usage for android.util Log println.

Prototype

public static int println(int priority, String tag, String msg) 

Source Link

Document

Low-level logging call.

Usage

From source file:es.uva.tel.gte.cardiomanager.main.MainActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    // TODO Auto-generated method stub
    super.onConfigurationChanged(newConfig);
    Log.println(Log.ASSERT, "DEBUG", "ConfigChangdeddd");
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * WARN  ?./*from w  w w. j a  va 2s  .  c o m*/
 * 
 * @param clazz  ??  Class.
 * @param tr Throwable.
 */
public static void w(final Class<?> clazz, final Throwable tr) {
    if (LogUtil.isWarnEnabled()) {
        Log.println(Log.WARN, TAG, LogUtil.getClassLineNumber(clazz) + " - " + Log.getStackTraceString(tr));

        //  ?? ?   ?.
        if (LogUtil.isFileLogEnabled()) {
            write(Log.WARN, LogUtil.getClassLineNumber(clazz), tr);
        }
    }
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * WARN  ?./*from   www.  j  a  va2 s .co m*/
 * 
 * @param clazz  ??  Class.
 * @param msg .
 * @param tr Throwable.
 */
public static void w(final Class<?> clazz, final String msg, final Throwable tr) {
    if (LogUtil.isWarnEnabled()) {
        Log.println(Log.WARN, TAG,
                LogUtil.getClassLineNumber(clazz) + " - " + msg + '\n' + Log.getStackTraceString(tr));

        //  ?? ?   ?.
        if (LogUtil.isFileLogEnabled()) {
            write(Log.WARN, LogUtil.getClassLineNumber(clazz), msg, tr);
        }
    }
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * ERROR  ?.//from  w ww .j ava  2 s .  co m
 * 
 * @param clazz  ??  Class.
 * @param msg .
 */
public static void e(final Class<?> clazz, final String msg) {
    if (LogUtil.isErrorEnabled()) {
        Log.println(Log.ERROR, TAG, LogUtil.getClassLineNumber(clazz) + " - " + msg);

        //  ?? ?   ?.
        if (LogUtil.isFileLogEnabled()) {
            write(Log.ERROR, LogUtil.getClassLineNumber(clazz), msg);
        }
    }
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * ERROR  ?./*from   w  w w  . ja va  2 s.c  om*/
 * 
 * @param clazz  ??  Class.
 * @param tr Throwable.
 */
public static void e(final Class<?> clazz, final Throwable tr) {
    if (LogUtil.isErrorEnabled()) {
        Log.println(Log.ERROR, TAG, LogUtil.getClassLineNumber(clazz) + " - " + Log.getStackTraceString(tr));

        //  ?? ?   ?.
        if (LogUtil.isFileLogEnabled()) {
            write(Log.ERROR, LogUtil.getClassLineNumber(clazz), tr);
        }
    }
}

From source file:com.morphoss.acal.service.UpdateTimezones.java

private String getTimeZone(String tzid) {
    requestor.interpretUriString(tzUrl("get", tzid));
    InputStream is = null;// w w w.  jav a  2  s  .c o  m
    StringBuilder getResponse = new StringBuilder();
    try {
        is = requestor.doRequest("GET", null, null, null);
        if (requestor.getStatusCode() != 200) {
            Log.println(Constants.LOGI, TAG,
                    "" + requestor.getStatusCode() + " response from Timezone Server at " + tzUrl("get", tzid));
            return null;
        }
        BufferedReader r = new BufferedReader(new InputStreamReader(is),
                AcalConnectionPool.DEFAULT_BUFFER_SIZE);
        String line;
        while ((line = r.readLine()) != null) {
            getResponse.append(line).append("\n");
        }
    } catch (IllegalStateException e) {
        Log.w(TAG, "Auto-generated catch block", e);
    } catch (IOException e) {
        Log.w(TAG, "Auto-generated catch block", e);
    } finally {
        try {
            is.close();
        } catch (Exception e) {
        }
        ;
    }
    try {
        VComponent vc = VComponent.createComponentFromBlob(getResponse.toString());
        List<VComponent> children = vc.getChildren();
        return children.get(0).getCurrentBlob();
    } catch (Exception e) {
        Log.w(TAG, "Auto-generated catch block", e);
        return null;
    }
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * ERROR  ?./*from www  .  j  av a 2s  .  co  m*/
 * 
 * @param clazz  ??  Class.
 * @param msg .
 * @param tr Throwable.
 */
public static void e(final Class<?> clazz, final String msg, final Throwable tr) {
    if (LogUtil.isErrorEnabled()) {
        Log.println(Log.ERROR, TAG,
                LogUtil.getClassLineNumber(clazz) + " - " + msg + '\n' + Log.getStackTraceString(tr));

        //  ?? ?   ?.
        if (LogUtil.isFileLogEnabled()) {
            write(Log.ERROR, LogUtil.getClassLineNumber(clazz), msg, tr);
        }
    }
}

From source file:com.morphoss.acal.service.connector.AcalRequestor.java

/**
 * Interpret the URI in the string to set protocol, host, port & path for the next request.
 * If the URI only matches a path part then protocol/host/port will be unchanged. This call
 * will only allow for path parts that are anchored to the web root.  This is used internally
 * for following Location: redirects./* w w  w  .  j av a2s  .  c o  m*/
 *
 * This is also used to interpret the 'path' parameter to the request calls generally.
 *
 * @param uriString
 */
public void interpretUriString(String uriString) {

    if (uriString == null)
        return;

    // Match a URL, including an ipv6 address like http://[DEAD:BEEF:CAFE:F00D::]:8008/
    final Pattern uriMatcher = Pattern.compile("^(?:(https?)://)?" + // Protocol
            "(" + // host spec
            "(?:(?:[a-z0-9-]+[.]){1,7}(?:[a-z0-9-]+))" + // Hostname or IPv4 address
            "|(?:\\[(?:[0-9a-f]{0,4}:)+(?:[0-9a-f]{0,4})?\\])" + // IPv6 address
            ")" + "(?:[:]([0-9]{2,5}))?" + // Port number
            "(/.*)?$" // Path bit.
            , Pattern.CASE_INSENSITIVE | Pattern.DOTALL);

    final Pattern pathMatcher = Pattern.compile("^(/.*)$");

    if (Constants.LOG_VERBOSE)
        Log.println(Constants.LOGV, TAG, "Interpreting '" + uriString + "'");
    Matcher m = uriMatcher.matcher(uriString);
    if (m.matches()) {
        if (m.group(1) != null && !m.group(1).equals("")) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found protocol '" + m.group(1) + "'");
            protocol = m.group(1);
            if (m.group(3) == null || m.group(3).equals("")) {
                port = (protocol.equals(PROTOCOL_HTTP) ? 80 : 443);
            }
        }
        if (m.group(2) != null) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found hostname '" + m.group(2) + "'");
            setHostName(m.group(2));
        }
        if (m.group(3) != null && !m.group(3).equals("")) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found port '" + m.group(3) + "'");
            port = Integer.parseInt(m.group(3));
            if (m.group(1) != null && (port == 0 || port == 80 || port == 443)) {
                port = (protocol.equals(PROTOCOL_HTTP) ? 80 : 443);
            }
        }
        if (m.group(4) != null && !m.group(4).equals("")) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found path '" + m.group(4) + "'");
            setPath(m.group(4));
        }
        if (!initialised)
            initialise();
    } else {
        m = pathMatcher.matcher(uriString);
        if (m.find()) {
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found relative path '" + m.group(1) + "'");
            setPath(m.group(1));
        } else {
            if (Constants.LOG_DEBUG)
                Log.println(Constants.LOGD, TAG, "Using Uri class to process redirect...");
            Uri newLocation = Uri.parse(uriString);
            if (newLocation.getHost() != null)
                setHostName(newLocation.getHost());
            setPortProtocol(newLocation.getPort(), newLocation.getScheme());
            setPath(newLocation.getPath());
            if (Constants.LOG_VERBOSE)
                Log.println(Constants.LOGV, TAG, "Found new location at '" + fullUrl() + "'");

        }
    }
}

From source file:com.morphoss.acal.service.UpdateTimezones.java

private void scheduleNextUpdate() {
    this.TIME_TO_EXECUTE = System.currentTimeMillis() + (deferMe ? 90000 : 86400000 * 7);
    //      this.TIME_TO_EXECUTE = System.currentTimeMillis() + 90000;
    Log.println(Constants.LOGV, TAG,
            "Scheduling next instance at " + AcalDateTime.fromMillis(this.TIME_TO_EXECUTE).fmtIcal());
    context.addWorkerJob(this);
}

From source file:com.kth.common.utils.etc.LogUtil.java

/**
 * Stack Trace  ?.//  w w  w  . j  a  v  a 2  s. c o m
 * 
 * @param clazz  ??  Class.
 * @param level  .
 * @param msg .
 */
public static void stackTrace(final Class<?> clazz, final int level, final String msg) {
    if (Log.isLoggable(TAG, level)) {
        Thread th = Thread.currentThread();
        StackTraceElement[] stack = th.getStackTrace();

        StringBuilder sb = new StringBuilder();
        if (msg != null && !"".equals(msg)) {
            sb.append(msg).append("\n");
        }
        for (StackTraceElement element : stack) {
            if (!"getStackTrace".equals(element.getMethodName())
                    && !"stackTrace".equals(element.getMethodName())) {
                sb.append("\tat ").append(element.toString()).append("\n");
            }
        }
        Log.println(level, TAG, LogUtil.getClassLineNumber(clazz) + " - " + sb.toString());
    }
}