Example usage for android.util Log WARN

List of usage examples for android.util Log WARN

Introduction

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

Prototype

int WARN

To view the source code for android.util Log WARN.

Click Source Link

Document

Priority constant for the println method; use Log.w.

Usage

From source file:com.github.luluvise.droid_utils.lib.network.ConnectionMonitor.java

/**
 * Initializes the {@link ConnectionMonitor}. It registers a
 * {@link NetworkReceiver} in order to be notified about network state
 * changes.//from  w w  w . j  av  a  2 s. co  m
 * 
 * @param application
 *            The {@link Application} object
 */
public void register(@Nonnull Application application) {
    if (mIsRegistered.compareAndSet(false, true)) {
        // permanently register the listener using the application context
        final IntentFilter filter = NetworkReceiver.getFilter();
        LocalBroadcastManager.getInstance(application).registerReceiver(mNetReceiver, filter);
    } else {
        LogUtils.log(Log.WARN, TAG, "ConnectionMonitor multiple initialization attempt");
    }
}

From source file:nl.frankkie.bronylivewallpaper.CLog.java

public static void w(String tag, String msg) {
    if (shouldLog && errorLevel <= Log.WARN) {
        Log.w(tag, msg);
    }
}

From source file:org.thoughtland.xlocation.Util.java

public static void bug(XHook hook, Throwable ex) {
    int priority;
    if (ex instanceof ActivityShare.AbortException)
        priority = Log.WARN;
    else if (ex instanceof ActivityShare.ServerException)
        priority = Log.WARN;/*from  www  .  j av  a  2  s .c o m*/
    else if (ex instanceof ConnectTimeoutException)
        priority = Log.WARN;
    else if (ex instanceof FileNotFoundException)
        priority = Log.WARN;
    else if (ex instanceof HttpHostConnectException)
        priority = Log.WARN;
    else if (ex instanceof NoClassDefFoundError)
        priority = Log.WARN;
    else if (ex instanceof OutOfMemoryError)
        priority = Log.WARN;
    else if (ex instanceof RuntimeException)
        priority = Log.WARN;
    else if (ex instanceof SecurityException)
        priority = Log.WARN;
    else if (ex instanceof SocketTimeoutException)
        priority = Log.WARN;
    else if (ex instanceof SSLPeerUnverifiedException)
        priority = Log.WARN;
    else if (ex instanceof TransactionTooLargeException)
        priority = Log.WARN;
    else if (ex instanceof UnknownHostException)
        priority = Log.WARN;
    else
        priority = Log.ERROR;

    boolean xlocation = false;
    for (StackTraceElement frame : ex.getStackTrace())
        if (frame.getClassName() != null && frame.getClassName().startsWith("org.thoughtland.xlocation")) {
            xlocation = true;
            break;
        }
    if (!xlocation)
        priority = Log.WARN;

    log(hook, priority, ex.toString() + " uid=" + Process.myUid() + "\n" + Log.getStackTraceString(ex));
}

From source file:biz.bokhorst.xprivacy.Util.java

public static void bug(XHook hook, Throwable ex) {
    if (ex instanceof InvocationTargetException) {
        InvocationTargetException exex = (InvocationTargetException) ex;
        if (exex.getTargetException() != null)
            ex = exex.getTargetException();
    }//from w  w  w. jav a  2s.  co  m

    int priority;
    if (ex instanceof ActivityShare.AbortException)
        priority = Log.WARN;
    else if (ex instanceof ActivityShare.ServerException)
        priority = Log.WARN;
    else if (ex instanceof ConnectTimeoutException)
        priority = Log.WARN;
    else if (ex instanceof FileNotFoundException)
        priority = Log.WARN;
    else if (ex instanceof HttpHostConnectException)
        priority = Log.WARN;
    else if (ex instanceof NameNotFoundException)
        priority = Log.WARN;
    else if (ex instanceof NoClassDefFoundError)
        priority = Log.WARN;
    else if (ex instanceof OutOfMemoryError)
        priority = Log.WARN;
    else if (ex instanceof RuntimeException)
        priority = Log.WARN;
    else if (ex instanceof SecurityException)
        priority = Log.WARN;
    else if (ex instanceof SocketTimeoutException)
        priority = Log.WARN;
    else if (ex instanceof SSLPeerUnverifiedException)
        priority = Log.WARN;
    else if (ex instanceof StackOverflowError)
        priority = Log.WARN;
    else if (ex instanceof TransactionTooLargeException)
        priority = Log.WARN;
    else if (ex instanceof UnknownHostException)
        priority = Log.WARN;
    else if (ex instanceof UnsatisfiedLinkError)
        priority = Log.WARN;
    else
        priority = Log.ERROR;

    boolean xprivacy = false;
    for (StackTraceElement frame : ex.getStackTrace())
        if (frame.getClassName() != null && frame.getClassName().startsWith("biz.bokhorst.xprivacy")) {
            xprivacy = true;
            break;
        }
    if (!xprivacy)
        priority = Log.WARN;

    log(hook, priority, ex.toString() + " uid=" + Process.myUid() + "\n" + Log.getStackTraceString(ex));
}

From source file:com.android.talkback.labeling.LabelProvider.java

/**
 * Inserts a label in the labels database.
 *
 * @param uri The content URI for labels.
 * @param values The values to insert for the new label.
 * @return The URI of the newly inserted label,
 *         or {@code null} if the insert failed.
 *//*from   w w w.j a  va2s  . com*/
@Override
public Uri insert(Uri uri, ContentValues values) {
    if (uri == null) {
        LogUtils.log(this, Log.WARN, NULL_URI_FORMAT_STRING);
        return null;
    }

    if (!UserManagerCompat.isUserUnlocked(getContext())) {
        return null;
    }

    switch (sUriMatcher.match(uri)) {
    case LABELS:
        initializeDatabaseIfNull();

        if (values == null) {
            return null;
        }

        if (values.containsKey(LabelsTable.KEY_ID)) {
            LogUtils.log(this, Log.WARN, "Label ID must be assigned by the database.");
            return null;
        }

        long rowId = mDatabase.insert(LabelsTable.TABLE_NAME, null, values);

        if (rowId < 0) {
            LogUtils.log(this, Log.WARN, "Failed to insert label.");
            return null;
        } else {
            return ContentUris.withAppendedId(LABELS_CONTENT_URI, rowId);
        }
    default:
        LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri);
        return null;
    }
}

From source file:com.android.utils.traversal.OrderedTraversalController.java

/**
 * Creates tree that reproduces AccessibilityNodeInfoCompat tree hierarchy
 * @param rootNode root node that is starting point for tree reproduction
 * @param parent parent WorkingTree node for subtree that would be returned in this method
 * @param includeChildrenOfNodesWithWebActions whether to calculator order for nodes that
 *        support web actions. Although TalkBack uses the naviagation order specified by the
 *        nodes, Switch Access needs to know about all nodes at the time the tree is being
 *        created.//ww  w. j  av  a2 s . c  o m
 * @return subtree that reproduces accessibility node hierarchy
 */
private WorkingTree createWorkingTree(AccessibilityNodeInfoCompat rootNode, WorkingTree parent,
        NodeCachedBoundsCalculator boundsCalculator, boolean includeChildrenOfNodesWithWebActions) {
    if (mNodeTreeMap.containsKey(rootNode)) {
        LogUtils.log(OrderedTraversalController.class, Log.WARN,
                "creating node tree with looped nodes - break the loop edge");
        return null;
    }

    WorkingTree tree = new WorkingTree(rootNode, parent);
    mNodeTreeMap.put(rootNode, tree);

    // When we reach a node that supports web navigation, we traverse using the web navigation
    // actions, so we should not try to determine the ordering of its descendants.
    if (!includeChildrenOfNodesWithWebActions && WebInterfaceUtils.supportsWebActions(rootNode)) {
        return tree;
    }

    ReorderedChildrenIterator iterator = ReorderedChildrenIterator.createAscendingIterator(rootNode,
            boundsCalculator);
    while (iterator != null && iterator.hasNext()) {
        AccessibilityNodeInfoCompat child = iterator.next();
        WorkingTree childSubTree = createWorkingTree(child, tree, boundsCalculator,
                includeChildrenOfNodesWithWebActions);
        if (childSubTree != null) {
            tree.addChild(childSubTree);
        }
    }

    if (iterator != null) {
        iterator.recycle();
    }
    return tree;
}

From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java

@Test
public void formatRendersWarningLevel() throws IOException {
    final JsonLog log = getLog(Log.WARN, "tag", "message", new RuntimeException());
    assertThat(log.level, is(equalTo("WARN")));
}

From source file:com.facebook.FileLruCache.java

OutputStream openPutStream(final String key, String contentTag) throws IOException {
    final File buffer = BufferFile.newFile(this.directory);
    buffer.delete();/*w ww. j av  a  2 s  .c  o m*/
    if (!buffer.createNewFile()) {
        throw new IOException("Could not create file at " + buffer.getAbsolutePath());
    }

    FileOutputStream file = null;
    try {
        file = new FileOutputStream(buffer);
    } catch (FileNotFoundException e) {
        Logger.log(LoggingBehaviors.CACHE, Log.WARN, TAG, "Error creating buffer output stream: " + e);
        throw new IOException(e.getMessage());
    }

    StreamCloseCallback renameToTargetCallback = new StreamCloseCallback() {
        @Override
        public void onClose() {
            final File target = new File(directory, Utility.md5hash(key));
            if (!buffer.renameTo(target)) {
                buffer.delete();
            }
            trim();
        }
    };

    CloseCallbackOutputStream cleanup = new CloseCallbackOutputStream(file, renameToTargetCallback);
    BufferedOutputStream buffered = new BufferedOutputStream(cleanup, Utility.DEFAULT_STREAM_BUFFER_SIZE);
    boolean success = false;

    try {
        // Prefix the stream with the actual key, since there could be collisions
        JSONObject header = new JSONObject();
        header.put(HEADER_CACHEKEY_KEY, key);
        if (!Utility.isNullOrEmpty(contentTag)) {
            header.put(HEADER_CACHE_CONTENT_TAG_KEY, contentTag);
        }

        StreamHeader.writeHeader(buffered, header);

        success = true;
        return buffered;
    } catch (JSONException e) {
        // JSON is an implementation detail of the cache, so don't let JSON exceptions out.
        Logger.log(LoggingBehaviors.CACHE, Log.WARN, TAG, "Error creating JSON header for cache file: " + e);
        throw new IOException(e.getMessage());
    } finally {
        if (!success) {
            buffered.close();
        }
    }
}

From source file:com.psiphon3.psiphonlibrary.StatusList.java

/**
 * @return Returns the last non-DEBUG, non-WARN(ing) item, or null if there is none.
 *//*from   www  . j  a  v a 2s  . co m*/
public static StatusEntry getLastStatusEntryForDisplay() {
    synchronized (m_statusHistory) {
        ListIterator<StatusEntry> iterator = m_statusHistory.listIterator(m_statusHistory.size());

        while (iterator.hasPrevious()) {
            StatusEntry current_item = iterator.previous();
            if (current_item.priority() != Log.DEBUG && current_item.priority() != Log.WARN) {
                return current_item;
            }
        }

        return null;
    }
}

From source file:com.scvngr.levelup.core.util.LogManager.java

/**
 * Log a message./* w ww  . ja  v a2 s  . co  m*/
 *
 * @param msg message to log. This message is expected to be a format string if varargs are
 *            passed in.
 * @param args optional arguments to be formatted into {@code msg}.
 */
public static void w(@NonNull final String msg, @Nullable final Object... args) {
    logMessage(Log.WARN, msg, args, null);
}