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:fr.inria.ucn.collectors.SocketsCollector.java

/**
 * /*from w  w w . ja va 2s.co  m*/
 * @param c
 * @param ts
 */
public void run(Context c, long ts) {
    try {
        JSONObject data = new JSONObject();
        data.put("sockets", getSock(c));
        Helpers.sendResultObj(c, "sockets", ts, data);
    } catch (JSONException jex) {
        Log.w(Constants.LOGTAG, "failed to create json object", jex);
    }
}

From source file:com.google.cast.samples.games.spellcast.messages.CastSpellsMessage.java

@Override
public JSONObject toJSON() {
    JSONObject serialized = new JSONObject();
    JSONArray array = new JSONArray();
    for (SpellEventData spell : mSpells) {
        array.put(spell.toJSON());/*from w w w  .j a  v  a 2  s .  c o  m*/
    }
    try {
        serialized.put(KEY_SPELLS, array);
    } catch (JSONException e) {
        Log.w(TAG, "JSONException converting spell list to JSON.", e);
    }

    return serialized;
}

From source file:Main.java

/**
 * decide use XLOG or android default log
 * @param tag log tag/*ww w  . ja  v  a 2  s  . com*/
 * @param msg log info message
 * @param tr An exception to log
 * @return log level
 */
public static int w(String tag, String msg, Throwable tr) {
    return /*XLOG_ON ? Xlog.w(tag, msg, tr) : */Log.w(tag, msg, tr);
}

From source file:com.android.quicksearchbox.JsonBackedSuggestionExtras.java

public String getExtra(String columnName) {
    try {//from   www  . j  a  v  a 2s  .c  om
        if (mExtras.isNull(columnName)) {
            return null;
        } else {
            return mExtras.getString(columnName);
        }
    } catch (JSONException e) {
        Log.w(TAG, "Could not extract JSON extra", e);
        return null;
    }
}

From source file:com.github.piasy.biv.example.App.java

static String getSystemProperty(String propName) {
    String line;// w  w  w .  j  a  va 2s. c  o  m
    BufferedReader input = null;
    try {
        Process p = Runtime.getRuntime().exec("getprop " + propName);
        input = new BufferedReader(new InputStreamReader(p.getInputStream(), "UTF-8"), 1024);
        line = input.readLine();
        input.close();
    } catch (IOException ex) {
        Log.w(TAG, "Unable to read sysprop " + propName, ex);
        return null;
    } finally {
        IOUtils.closeQuietly(input);
    }
    return line;
}

From source file:info.schnatterer.nusic.android.util.TextUtil.java

/**
 * Tries to load an asset file as text. If <code>assetPath</code> ends in
 * <code>.html</code>, the HTML code is rendered into "displayable styled"
 * text.//from   ww  w.  ja v a 2s  .  co m
 * 
 * @param context
 *            context to load asset and (potential resources) from
 * @param assetPath
 *            path of the asset to load
 * @param replaceResources
 *            if <code>true</code>, resources such as
 *            <code>@string/abc</code> are replaced with their localized
 *            values from the app's resource strings (e.g.
 *            <code>strings.xml</code>). Set to <code>false</code> for
 *            better performance.
 * @return (potentially styled) text from asset
 */
public static CharSequence loadTextFromAsset(Context context, String assetPath, boolean replaceResources) {
    if (assetPath != null) {
        InputStream is = null;
        try {
            is = context.getResources().getAssets().open(assetPath);
            String assetText = IOUtils.toString(is);
            if (assetPath.matches(REGEX_ENDING_HTML)) {
                return fromHtml(replaceResourceStrings(assetText));
            } else {
                return assetText;
            }
        } catch (IOException e) {
            Log.w(Constants.LOG, "Unable to load asset from path \"" + assetPath + "\"", e);
            return context.getString(R.string.TextAssetActivity_errorLoadingFile);
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
    return null;
}

From source file:Main.java

/**
 * This method is used by the core logging functions to nicely format output to the logcat
 * @param logMethod the method to call. Should be {@link Log#i(String, String)} or another {@link Log} static method
 * @param format the text to display, using java string format arguments
 * @param args the arguments to show in the format string.
 *///from w w  w .  j a  v a2  s .co  m
private static void log(Method logMethod, String format, Object... args) {
    try {
        StackTraceElement[] trace = Thread.currentThread().getStackTrace();
        StringBuilder b = new StringBuilder();
        b.append(format).append(", ");
        int index = 1;
        String name = null;
        boolean loop = true;
        do {
            index++;
            if (trace != null && index < trace.length) {
                name = trace[index].getClassName();

                if (name != null) {
                    if (!name.contains("self.philbrown.AbLE.AbLEUtil")) {
                        loop = false;
                    }
                }
            } else {
                index = 1;
                loop = false;
            }

        } while (loop);
        b.append(formatStackTrace(trace[index]));
        b.append(buildCommaSeparatedString(args));
        try {
            logMethod.invoke(null, "AbLE", String.format(Locale.US, b.toString(), args));
        } catch (Exception e) {
            e.printStackTrace();
        }
    } catch (Throwable t) {
        Log.w("AbLE", "Log Failed", t);
    }
}

From source file:com.auth0.api.handler.APIResponseHandler.java

@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
    Log.e(this.getClass().getName(), "Operation failed", error);
    Map errorResponse = null;//from   w  w w.jav a2s. co m
    if (statusCode == 400 || statusCode == 401) {
        try {
            errorResponse = new ObjectMapper().readValue(responseBody, Map.class);
            Log.e(this.getClass().getName(), "Response error " + errorResponse);
        } catch (IOException e) {
            Log.w(this.getClass().getName(), "Failed to parse json error response", error);
        }
    }
    callback.onFailure(new APIClientException("Failed to perform operation", error, statusCode, errorResponse));
}

From source file:com.deltadna.android.sdk.net.NetworkManager.java

public NetworkManager(String envKey, String collectUrl, String engageUrl, Settings settings,
        @Nullable String hash) {// w w  w  .j  av a  2  s  .  c o  m

    this.collectUrl = collectUrl + '/' + envKey;
    this.engageUrl = engageUrl + '/' + envKey;
    this.settings = settings;

    this.hash = hash;
    MessageDigest md = null;
    if (hash != null && !hash.isEmpty()) {
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            Log.w(TAG, "Events will not be hashed", e);
        }
    }
    md5 = md;

    dispatcher = new NetworkDispatcher(new Handler(Looper.getMainLooper()));
}

From source file:eu.geekgasm.kintrol.KinosKontroller.java

private void disconnectTelnetClient() {
    if (telnetClient != null && telnetClient.isConnected()) {
        try {// w ww. ja v a  2  s.  co  m
            telnetClient.disconnect();
        } catch (IOException e) {
            Log.w(TAG, "Error disconnecting Telnet client: ", e);
        }
    }
    notificationListener.handleNoConnectionStatusUpdate();
}