Java Code Examples for android.util.Log.ERROR

The following are Jave code examples for showing how to use ERROR 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: TMvpSimple   File: LogUtils.java   Source Code and License Vote up 6 votes
/**
 * Send an {@link Log#ERROR} log message.
 *
 * @param object The object to print.
 */
public static void printError(Object object) {
    if (Log.ERROR > DEBUG_LEVEL) {
        String tag = getClassName();
        String method = callMethodAndLine();
        String content = "";
        if (object != null) {
            content = object.toString() + "                    ----    "
                    + method;
        } else {
            content = " ## " + "                    ----    " + method;
        }
        Log.e(tag, content);
        if (DEBUG_SYSOUT) {
            System.err.println(tag + "  " + method + "  " + content);
        }
    }
}
 
Example 2
Project: DebugOverlay-Android   File: TimberDataModule.java   Source Code and License Vote up 6 votes
private static LogcatLine.Priority getLogcatLinePriority(int priority) {
    if (Log.VERBOSE == priority) {
        return LogcatLine.Priority.VERBOSE;
    } else if (Log.DEBUG == priority) {
        return LogcatLine.Priority.DEBUG;
    } else if (Log.INFO == priority) {
        return LogcatLine.Priority.INFO;
    } else if (Log.WARN == priority) {
        return LogcatLine.Priority.WARNING;
    } else if (Log.ERROR == priority) {
        return LogcatLine.Priority.ERROR;
    } else if (Log.ASSERT == priority) {
        return LogcatLine.Priority.ASSERT;
    } else {
        return LogcatLine.Priority.SILENT;
    }
}
 
Example 3
Project: historian   File: Util.java   Source Code and License Vote up 6 votes
public static String priorityString(int priority) {
  switch (priority) {
    case Log.VERBOSE:
      return "VERBOSE";
    case Log.DEBUG:
      return "DEBUG";
    case Log.INFO:
      return "INFO";
    case Log.WARN:
      return "WARN";
    case Log.ERROR:
      return "ERROR";
    case Log.ASSERT:
      return "ASSERT";
    default:
      return "UNKNOWN";
  }
}
 
Example 4
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 5
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 6
Project: FinalProject   File: LogMessageHelper.java   Source Code and License Vote up 6 votes
public static String prefixForPriority(int priority) {
    switch (priority) {
        case Log.VERBOSE:
            return "[VERBOSE] ";
        case Log.DEBUG:
            return "[DEBUG] ";
        case Log.INFO:
            return "[INFO] ";
        case Log.WARN:
            return "[WARN] ";
        case Log.ERROR:
            return "[ERROR] ";
        case Log.ASSERT:
            return "[ASSERT] ";
        default:
            return "[UNKNOWN(" + priority + ")] ";
    }
}
 
Example 7
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 8
Project: javaide   File: LogLineAdapterUtil.java   Source Code and License Vote up 6 votes
public static int getBackgroundColorForLogLevel(Context context, int logLevel) {
    int result = android.R.color.black;
    switch (logLevel) {
        case Log.DEBUG:
            result = R.color.background_debug;
            break;
        case Log.ERROR:
            result = R.color.background_error;
            break;
        case Log.INFO:
            result = R.color.background_info;
            break;
        case Log.VERBOSE:
            result = R.color.background_verbose;
            break;
        case Log.WARN:
            result = R.color.background_warn;
            break;
        case LOG_WTF:
            result = R.color.background_wtf;
            break;
    }

    return ContextCompat.getColor(context,result);
}
 
Example 9
Project: superglue   File: LumberYard.java   Source Code and License Vote up 6 votes
public String displayLevel() {
  switch (level) {
    case Log.VERBOSE:
      return "V";
    case Log.DEBUG:
      return "D";
    case Log.INFO:
      return "I";
    case Log.WARN:
      return "W";
    case Log.ERROR:
      return "E";
    case Log.ASSERT:
      return "A";
    default:
      return "?";
  }
}
 
Example 10
Project: MyBlogPost   File: Logger.java   Source Code and License Vote up 6 votes
private static void longLog(int mode, String tag, String message) {
    int maxLogSize = 1000;
    for (int i = 0; i <= message.length() / maxLogSize; i++) {
        int start = i * maxLogSize;
        int end = (i + 1) * maxLogSize;
        end = end > message.length() ? message.length() : end;

        if (mode == Log.DEBUG) {
            Log.d(TAG + tag, message.substring(start, end));
        } else if (mode == Log.ERROR) {
            Log.e(TAG + tag, message.substring(start, end));
        } else if (mode == Log.INFO) {
            Log.i(TAG + tag, message.substring(start, end));
        } else if (mode == Log.WARN) {
            Log.w(TAG + tag, message.substring(start, end));
        }
    }
}
 
Example 11
Project: GitHub   File: ExampleApp.java   Source Code and License Vote up 5 votes
@Override protected void log(int priority, String tag, @NonNull String message, Throwable t) {
  if (priority == Log.VERBOSE || priority == Log.DEBUG) {
    return;
  }

  FakeCrashLibrary.log(priority, tag, message);

  if (t != null) {
    if (priority == Log.ERROR) {
      FakeCrashLibrary.logError(t);
    } else if (priority == Log.WARN) {
      FakeCrashLibrary.logWarning(t);
    }
  }
}
 
Example 12
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 13
Project: InstantAppStarter   File: ReleaseTree.java   Source Code and License Vote up 5 votes
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if(isLoggable(tag,priority)){

        if(priority == Log.ERROR && t!=null){
            //Send the log to your crashlatics framework
        }

        if(message.length() < MAX_LOG_LENGTH){
            if(priority == Log.ASSERT){
                Log.wtf(tag,message);
            }else {
                Log.println(priority,tag,message);
            }
            return;
        }
    }

    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);
            String part = message.substring(i, end);
            if (priority == Log.ASSERT) {
                Log.wtf(tag, part);
            } else {
                Log.println(priority, tag, part);
            }
            i = end;
        } while (i < newline);
    }

}
 
Example 14
Project: IslamicLibraryAndroid   File: IslamicLibraryApplication.java   Source Code and License Vote up 5 votes
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    Crashlytics.log(priority, message, tag);
    if (t != null) {
        Crashlytics.logException(t);
    }
    // If this is an error or a warning, log it as a exception so we see it in Crashlytics.
    if (priority >= Log.ERROR) {
        Crashlytics.logException(new Throwable(message));
    }
}
 
Example 15
Project: Quran   File: RecordingLogTree.java   Source Code and License Vote up 5 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";
    default:
      return String.valueOf(priority);
  }
}
 
Example 16
Project: 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 17
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 18
Project: TodoMvp   File: ReleaseTree.java   Source Code and License Vote up 5 votes
@Override protected void log(int priority, String tag, String message, Throwable t) {
  if (isLoggable(tag, priority)) {

    // Report caught exceptions to Crashlytics
    if (priority == Log.ERROR && t != null) {
      //Crashlytics.log(t);
    }

    // Message is short emough, does not need to be broken into chunks
    if (message.length() < MAX_LOG_LENGTH) {
      if (priority == Log.ASSERT) {
        Log.wtf(tag, message);
      } else {
        Log.println(priority, tag, message);
      }
      return;
    }

    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);
        String part = message.substring(i, end);
        if (priority == Log.ASSERT) {
          Log.wtf(tag, part);
        } else {
          Log.println(priority, tag, part);
        }
        i = end;
      } while (i < newLine);
    }
  }
}
 
Example 19
Project: javaide   File: LogLineAdapterUtil.java   Source Code and License Vote up 5 votes
public static boolean logLevelIsAcceptableGivenLogLevelLimit(int logLevel, int logLevelLimit) {

        int minVal = 0;
        switch (logLevel) {

            case Log.VERBOSE:
                minVal = 0;
                break;
            case Log.DEBUG:
                minVal = 1;
                break;
            case Log.INFO:
                minVal = 2;
                break;
            case Log.WARN:
                minVal = 3;
                break;
            case Log.ERROR:
                minVal = 4;
                break;
            case LOG_WTF:
                minVal = 5;
                break;
            default: // e.g. the starting line that says "output of log such-and-such"
                return true;
        }

        return minVal >= logLevelLimit;

    }
 
Example 20
Project: GitHub   File: GlideBuilder.java   Source Code and License Vote up 3 votes
/**
 * Sets a log level constant from those in {@link Log} to indicate the desired log verbosity.
 *
 * <p>The level must be one of {@link Log#VERBOSE}, {@link Log#DEBUG}, {@link Log#INFO},
 * {@link Log#WARN}, or {@link Log#ERROR}.
 *
 * <p>{@link Log#VERBOSE} means one or more lines will be logged per request, including
 * timing logs and failures. {@link Log#DEBUG} means at most one line will be logged
 * per successful request, including timing logs, although many lines may be logged for
 * failures including multiple complete stack traces. {@link Log#INFO} means
 * failed loads will be logged including multiple complete stack traces, but successful loads
 * will not be logged at all. {@link Log#WARN} means only summaries of failed loads will be
 * logged. {@link Log#ERROR} means only exceptional cases will be logged.
 *
 * <p>All logs will be logged using the 'Glide' tag.
 *
 * <p>Many other debugging logs are available in individual classes. The log level supplied here
 * only controls a small set of informative and well formatted logs. Users wishing to debug
 * certain aspects of the library can look for individual <code>TAG</code> variables at the tops
 * of classes and use <code>adb shell setprop log.tag.TAG</code> to enable or disable any relevant
 * tags.
 *
 * @param logLevel The log level to use from {@link Log}.
 * @return This builder.
 */
public GlideBuilder setLogLevel(int logLevel) {
  if (logLevel < Log.VERBOSE || logLevel > Log.ERROR) {
    throw new IllegalArgumentException("Log level must be one of Log.VERBOSE, Log.DEBUG,"
        + " Log.INFO, Log.WARN, or Log.ERROR");
  }
  this.logLevel = logLevel;
  return this;
}