Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

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

Prototype

public static int w(String tag, String msg, Throwable tr) 

Source Link

Document

Send a #WARN log message and log the exception.

Usage

From source file:count.ly.messaging.Event.java

/**
 * Creates and returns a JSONObject containing the event data from this object.
 * @return a JSONObject containing the event data from this object
 *///from  w  ww.  ja  v  a2s .c  om
JSONObject toJSON() {
    final JSONObject json = new JSONObject();

    try {
        json.put(KEY_KEY, key);
        json.put(COUNT_KEY, count);
        json.put(TIMESTAMP_KEY, timestamp);

        if (segmentation != null) {
            json.put(SEGMENTATION_KEY, new JSONObject(segmentation));
        }

        // we put in the sum last, the only reason that a JSONException would be thrown
        // would be if sum is NaN or infinite, so in that case, at least we will return
        // a JSON object with the rest of the fields populated
        json.put(SUM_KEY, sum);
    } catch (JSONException e) {
        if (Countly.sharedInstance().isLoggingEnabled()) {
            Log.w(Countly.TAG, "Got exception converting an Event to JSON", e);
        }
    }

    return json;
}

From source file:es.upm.dit.gsi.noticiastvi.gtv.item.SetRemoveFavoriteThread.java

private boolean doFavorite() {
    if (!TEST) {//from  w  ww  .j a va2 s . c  o m
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet getRequest = new HttpGet(Constant.SERVER_URL + "?action=" + action + "&identifier=" + userId
                + "&content=" + id + "&preference=5");
        try {
            HttpResponse getResponse = client.execute(getRequest);
            InputStream source = getResponse.getEntity().getContent();
            if (source != null) {
                String res = convertStreamToString(source);
                return res.contains("ok");
            } else {
                return false;
            }
        } catch (IOException e) {
            getRequest.abort();
            Log.w(getClass().getSimpleName(), "Error", e);
            return false;
        }
    } else {
        Log.i("favorite", "TEST_MODE");
        return true;
    }

}

From source file:com.amazon.s3.http.HttpMethodReleaseInputStream.java

/**
 * Constructs an input stream based on an {@link HttpMethod} object
 * representing an HTTP connection. If a connection input stream is
 * available, this constructor wraps the underlying input stream in an
 * {@link InterruptableInputStream} and makes that stream available. If no
 * underlying connection is available, an empty {@link ByteArrayInputStream}
 * is made available.//from  w  w w . j  ava 2  s . c  om
 * 
 * @param httpMethod
 *            The HTTP method being executed, whose response content is to
 *            be wrapped.
 */
public HttpMethodReleaseInputStream(HttpEntityEnclosingRequest httpMethod) {
    this.httpRequest = httpMethod;

    try {
        this.inputStream = httpMethod.getEntity().getContent();
    } catch (IOException e) {

        Log.w(TAG, "Unable to obtain HttpMethod's response data stream", e);

        try {
            httpMethod.getEntity().getContent().close();
        } catch (Exception ex) {
        }
        this.inputStream = new ByteArrayInputStream(new byte[] {}); // Empty
        // input
        // stream;
    }
}

From source file:crow.util.JsonUtil.java

private static JSONArray toJSONObject(Set<Object> set) throws JSONException {
    JSONArray jsonOb = new JSONArray();
    if ((set == null) || (set.isEmpty()))
        return jsonOb;
    Iterator<Object> iter = set.iterator();
    while (iter.hasNext()) {
        Object value = iter.next();
        if ((value instanceof String) || (value instanceof Integer) || (value instanceof Double)
                || (value instanceof Long) || (value instanceof Float)) {
            jsonOb.put(value);/*from  ww w .  j av a 2 s. co  m*/
            continue;
        }
        if ((value instanceof Map<?, ?>)) {
            try {
                @SuppressWarnings("unchecked")
                Map<String, Object> valueMap = (Map<String, Object>) value;
                jsonOb.put(toJSONObject(valueMap));
            } catch (ClassCastException e) {
                Log.w(TAG, "Unknown map type in json serialization: ", e);
            }
            continue;
        }
        if ((value instanceof Set<?>)) {
            try {
                @SuppressWarnings("unchecked")
                Set<Object> valueSet = (Set<Object>) value;
                jsonOb.put(toJSONObject(valueSet));
            } catch (ClassCastException e) {
                Log.w(TAG, "Unknown map type in json serialization: ", e);
            }
            continue;
        }
        Log.e(TAG, "Unknown value in json serialization: " + value.toString() + " : "
                + value.getClass().getCanonicalName().toString());
    }
    return jsonOb;
}