Java Code Examples for android.util.Log.WARN

The following are Jave code examples for showing how to use WARN of the android.util.Log class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: javaide   File: LogLineAdapterUtil.java   Source Code and License Vote up 6 votes
public static int getForegroundColorForLogLevel(Context context, int logLevel) {
    int result = android.R.color.primary_text_dark;
    switch (logLevel) {
        case Log.DEBUG:
            result = R.color.foreground_debug;
            break;
        case Log.ERROR:
            result = R.color.foreground_error;
            break;
        case Log.INFO:
            result = R.color.foreground_info;
            break;
        case Log.VERBOSE:
            result = R.color.foreground_verbose;
            break;
        case Log.WARN:
            result = R.color.foreground_warn;
            break;
        case LOG_WTF:
            result = R.color.foreground_wtf;
            break;
    }
    return ContextCompat.getColor(context,result);
}
 
Example 2
Project: RxShell   File: JUnitTree.java   Source Code and License Vote up 6 votes
private static String priorityToString(int priority) {
    switch (priority) {
        case Log.ERROR:
            return "E";
        case Log.WARN:
            return "W";
        case Log.INFO:
            return "I";
        case Log.DEBUG:
            return "D";
        case Log.VERBOSE:
            return "V";
        default:
            return String.valueOf(priority);
    }
}
 
Example 3
Project: AndroidBlueprints   File: MyApplication.java   Source Code and License Vote up 6 votes
@Override
protected void log(int priority, String tag, String message, Throwable throwable) {
    if (priority == Log.VERBOSE || priority == Log.DEBUG) {
        return;
    }

    FakeCrashLibrary.log(priority, tag, message);

    if (throwable != null) {
        if (priority == Log.ERROR) {
            FakeCrashLibrary.logError(throwable);
        } else if (priority == Log.WARN) {
            FakeCrashLibrary.logWarning(throwable);
        }
    }
}
 
Example 4
Project: fast_face_android   File: DebugLogFileTree.java   Source Code and License Vote up 6 votes
public String getPriorityString(int priority) {
    if (priority == Log.ASSERT) {
        return "A";
    } else if (priority == Log.ERROR) {
        return "E";
    } else if (priority == Log.WARN) {
        return "W";
    } else if (priority == Log.INFO) {
        return "I";
    } else if (priority == Log.DEBUG) {
        return "D";
    } else if (priority == Log.VERBOSE) {
        return "V";
    }
    return "";
}
 
Example 5
Project: Phial   File: PhialLogger.java   Source Code and License Vote up 6 votes
/**
 * Create new log entry in file.
 * <p>
 * You should not call it directly from your application build some facade (or use Timber) and set it to write to
 * PhialLogger.
 *
 * @param priority Log level. See {@link Log} for constants.
 * @param tag      Explicit or inferred tag. May be {@code null}.
 * @param message  Formatted log message. May be {@code null}.
 * @param t        Accompanying exceptions. May be {@code null}.
 */
public void log(int priority, String tag, String message, Throwable t) {
    final org.slf4j.Logger logger = LoggerFactory.getLogger(tag);

    switch (priority) {
        case Log.VERBOSE:
            logger.trace(message, t);
            break;
        case Log.DEBUG:
            logger.debug(message, t);
            break;
        case Log.INFO:
            logger.info(message, t);
            break;
        case Log.WARN:
            logger.warn(message, t);
            break;
        case Log.ERROR:
            logger.error(message, t);
            break;
        default:
            logger.error("unexpected Log priority: " + priority + " " + message, t);
            break;
    }
}
 
Example 6
Project: superglue   File: LogAdapter.java   Source Code and License Vote up 6 votes
public static @DrawableRes int backgroundForLevel(int level) {
  switch (level) {
    case Log.VERBOSE:
    case Log.DEBUG:
      return R.color.debug_log_accent_debug;
    case Log.INFO:
      return R.color.debug_log_accent_info;
    case Log.WARN:
      return R.color.debug_log_accent_warn;
    case Log.ERROR:
    case Log.ASSERT:
      return R.color.debug_log_accent_error;
    default:
      return R.color.debug_log_accent_unknown;
  }
}
 
Example 7
Project: GitHub   File: SingleRequest.java   Source Code and License Vote up 5 votes
@Override
public void begin() {
  stateVerifier.throwIfRecycled();
  startTime = LogTime.getLogTime();
  if (model == null) {
    if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
      width = overrideWidth;
      height = overrideHeight;
    }
    // Only log at more verbose log levels if the user has set a fallback drawable, because
    // fallback Drawables indicate the user expects null models occasionally.
    int logLevel = getFallbackDrawable() == null ? Log.WARN : Log.DEBUG;
    onLoadFailed(new GlideException("Received null model"), logLevel);
    return;
  }

  status = Status.WAITING_FOR_SIZE;
  if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
    onSizeReady(overrideWidth, overrideHeight);
  } else {
    target.getSize(this);
  }

  if ((status == Status.RUNNING || status == Status.WAITING_FOR_SIZE)
      && canNotifyStatusChanged()) {
    target.onLoadStarted(getPlaceholderDrawable());
  }
  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    logV("finished run method in " + LogTime.getElapsedMillis(startTime));
  }
}
 
Example 8
Project: GitHub   File: AndroidPlatform.java   Source Code and License Vote up 5 votes
@Override public void log(int level, String message, Throwable t) {
  int logLevel = level == WARN ? Log.WARN : Log.DEBUG;
  if (t != null) message = message + '\n' + Log.getStackTraceString(t);

  // Split by line, then ensure each line can fit into Log's maximum length.
  for (int i = 0, length = message.length(); i < length; i++) {
    int newline = message.indexOf('\n', i);
    newline = newline != -1 ? newline : length;
    do {
      int end = Math.min(newline, i + MAX_LOG_LENGTH);
      Log.println(logLevel, "OkHttp", message.substring(i, end));
      i = end;
    } while (i < newline);
  }
}
 
Example 9
Project: RLibrary   File: FileDownloadLog.java   Source Code and License Vote up 5 votes
private static void log(int priority, Object o, Throwable throwable, String message, Object... args) {
    final boolean force = priority >= Log.WARN;
    if (!force && !NEED_LOG) {
        return;
    }

    Log.println(priority, getTag(o), FileDownloadUtils.formatString(message, args));
    if (throwable != null) {
        throwable.printStackTrace();
    }
}
 
Example 10
Project: youkes_browser   File: LogUtil.java   Source Code and License Vote up 5 votes
private static void print(int mode, final String tag, String msg) {
	if (!isPrint) {
		return;
	}
	if (msg == null) {
		Log.e(tag, MSG);
		return;
	}
	switch (mode) {
	case Log.VERBOSE:
		Log.v(tag, msg);
		break;
	case Log.DEBUG:
		Log.d(tag, msg);
		break;
	case Log.INFO:
		Log.i(tag, msg);
		break;
	case Log.WARN:
		Log.w(tag, msg);
		break;
	case Log.ERROR:
		Log.e(tag, msg);
		break;
	default:
		Log.d(tag, msg);
		break;
	}
}
 
Example 11
Project: GitHub   File: AndroidPlatform.java   Source Code and License Vote up 5 votes
@Override public void log(int level, String message, Throwable t) {
  int logLevel = level == WARN ? Log.WARN : Log.DEBUG;
  if (t != null) message = message + '\n' + Log.getStackTraceString(t);

  // Split by line, then ensure each line can fit into Log's maximum length.
  for (int i = 0, length = message.length(); i < length; i++) {
    int newline = message.indexOf('\n', i);
    newline = newline != -1 ? newline : length;
    do {
      int end = Math.min(newline, i + MAX_LOG_LENGTH);
      Log.println(logLevel, "OkHttp", message.substring(i, end));
      i = end;
    } while (i < newline);
  }
}
 
Example 12
Project: TMvpSimple-master   File: LogUtils.java   Source Code and License Vote up 5 votes
/**
 * Send a {@link Log#WARN} log message.
 *
 * @param obj
 */
public static void w(Object obj) {
    if (Log.WARN > DEBUG_LEVEL) {
        String tag = getClassName();
        String msg = obj != null ? obj.toString() : "obj == null";
        Log.w(tag, msg);
    }
}
 
Example 13
Project: MyBlogPost   File: Logger.java   Source Code and License Vote up 5 votes
public static void log(int mode, String message, String tag) {

        if (!BuildConfig.DEBUG)
            return;

        if (message == null)
            return;

        if (tag == null)
            tag = "";

        if (message.trim().length() == 0)
            message = "Data Empty";

        if (ENABLE_LONG_LOG) {
            longLog(mode, tag, message);
        } else {
            if (mode == Log.DEBUG) {
                Log.d(TAG + tag, message);
            } else if (mode == Log.ERROR) {
                Log.e(TAG + tag, message);
            } else if (mode == Log.INFO) {
                Log.i(TAG + tag, message);
            } else if (mode == Log.WARN) {
                Log.w(TAG + tag, message);
            }
        }
    }
 
Example 14
Project: sctalk   File: Logger.java   Source Code and License Vote up 5 votes
/**
 * log.d
 */
public void w(String format, Object... args) {
	if (logLevel <= Log.WARN) {
		lock.lock();
		try {
			String message = createMessage(getInputString(format, args));
			Log.w(tagName, message);
		} finally {
			lock.unlock();
		}
	}
}
 
Example 15
Project: Android-MVVM-Example   File: ReleaseTree.java   Source Code and License Vote up 5 votes
protected boolean isLoggable(int priority) {
    switch (priority) {
        case Log.ERROR:
        case Log.WARN:
            return true;

        default:
            return false;
    }
}
 
Example 16
Project: Dalaran   File: LogUtils.java   Source Code and License Vote up 5 votes
private static void log(int level, Object o, Throwable tr) {
        if (!ENABLED) return;

        String trace = generateTrace();
        String toast = trace.split("\\(")[0];
        String message = generateMessage(o) + SEPARATOR + trace;

        if (tr != null) {
            message += "\n" + Log.getStackTraceString(tr);
        }

        switch (level) {
            case Log.VERBOSE:
                Log.v(TAG, message);
                break;
            case Log.DEBUG:
                Log.d(TAG, message);
                break;
            case Log.INFO:
                Log.i(TAG, message);
                break;
            case Log.WARN:
                Log.w(TAG, message);
//                ToastManager.show("Log.WARN\n" + toast);
                break;
            case Log.ERROR:
                Log.e(TAG, message);
//                ToastManager.show("Log.ERROR\n" + toast);
//                throw new IllegalStateException(message);
                break;
            case Log.ASSERT:
                Log.wtf(TAG, message);
//                ToastManager.show("Log.ASSERT\n" + toast);
//                throw new IllegalStateException(message);
                break;
            default:
                throw new IllegalStateException();
        }
    }
 
Example 17
Project: FileDownloader-master   File: FileDownloadLog.java   Source Code and License Vote up 5 votes
private static void log(int priority, Object o, Throwable throwable, String message, Object... args) {
    final boolean force = priority >= Log.WARN;
    if (!force && !NEED_LOG) {
        return;
    }

    Log.println(priority, getTag(o), FileDownloadUtils.formatString(message, args));
    if (throwable != null) {
        throwable.printStackTrace();
    }
}
 
Example 18
Project: async-file-uploader   File: Logger.java   Source Code and License Vote up 4 votes
/**
 * Send a {@link Log#WARN} message.
 * @param msg The message to be logged.
 */
public static void w(String msg) {
    if (UploadQueue.getLogLevel() <= Log.WARN) {
        Log.v(Constants.TAG, msg);
    }
}
 
Example 19
Project: XPrivacy   File: Util.java   Source Code and License Vote up 4 votes
public static void bug(XHook hook, Throwable ex) {
	if (ex instanceof InvocationTargetException) {
		InvocationTargetException exex = (InvocationTargetException) ex;
		if (exex.getTargetException() != null)
			ex = exex.getTargetException();
	}

	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));
}
 
Example 20
Project: TMvpSimple   File: LogUtils.java   Source Code and License Vote up 2 votes
/**
 * Send a {@link Log#WARN} log message.
 *
 * @param tag Used to identify the source of a log message. It usually
 *            identifies the class or activity where the log call occurs.
 * @param msg The message you would like logged.
 */
public static void w(String tag, String msg) {
    if (Log.WARN > DEBUG_LEVEL) {
        Log.w(tag, msg);
    }
}