Java Code Examples for android.util.Log.ASSERT

The following are Jave code examples for showing how to use ASSERT 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: 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 2
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 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: XFrame   File: LoggerPrinter.java   Source Code and License Vote up 6 votes
private void logChunk(int priority, String chunk) {
    logStr.append(LINE_SEPARATOR);
    logStr.append(chunk);
    String TAG = config.getTag();
    switch (priority) {
        case Log.ERROR:
            Log.e(TAG, chunk);
            break;
        case Log.INFO:
            Log.i(TAG, chunk);
            break;
        case Log.VERBOSE:
            Log.v(TAG, chunk);
            break;
        case Log.WARN:
            Log.w(TAG, chunk);
            break;
        case Log.ASSERT:
            Log.wtf(TAG, chunk);
            break;
        case Log.DEBUG:
        default:
            Log.d(TAG, chunk);
            break;
    }
}
 
Example 5
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 6
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 7
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 8
Project: GitHub   File: Timber.java   Source Code and License Vote up 5 votes
/**
 * Break up {@code message} into maximum-length chunks (if needed) and send to either
 * {@link Log#println(int, String, String) Log.println()} or
 * {@link Log#wtf(String, String) Log.wtf()} for logging.
 *
 * {@inheritDoc}
 */
@Override protected void log(int priority, String tag, @NotNull String message, Throwable t) {
  if (message.length() < MAX_LOG_LENGTH) {
    if (priority == Log.ASSERT) {
      Log.wtf(tag, message);
    } else {
      Log.println(priority, tag, message);
    }
    return;
  }

  // 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);
      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 9
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 10
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 11
Project: Android-MVVM-Example   File: ReleaseTree.java   Source Code and License Vote up 5 votes
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if (message.length() < MAX_LOG_LENGTH) {
        if (priority == Log.ASSERT) {
            Log.wtf(tag, message);
        } else {
            Log.println(priority, tag, message);
        }
        return;
    }

    // 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);
            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 12
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 13
Project: Tir   File: Timber.java   Source Code and License Vote up 5 votes
/**
 * Break up {@code message} into maximum-length chunks (if needed) and send to either
 * {@link Log#println(int, String, String) Log.println()} or
 * {@link Log#wtf(String, String) Log.wtf()} for logging.
 * <p>
 * {@inheritDoc}
 */
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if (message.length() < MAX_LOG_LENGTH) {
        if (priority == Log.ASSERT) {
            Log.wtf(tag, message);
        } else {
            Log.println(priority, tag, message);
        }
        return;
    }

    // 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);
            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: CommonLibrary   File: MLog.java   Source Code and License Vote up 5 votes
private static void showLog(int priority, String tag, String message) {
    if (isLoggable && logLevel <= priority) {
        if (priority == Log.ASSERT) {
            Log.wtf(tag, message);
        } else {
            Log.println(priority, tag, message);
        }
    }
}
 
Example 15
Project: MyAnimeViewer   File: MAVApplication.java   Source Code and License Vote up 5 votes
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if (isLoggable(priority)) {
        // Message is short enough, 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;
        }

        // 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);
                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 16
Project: SlotNSlot_Android   File: AndroidHttpClient.java   Source Code and License Vote up 5 votes
/**
 * Enables cURL request logging for this client.
 *
 * @param name to log messages with
 * @param level at which to log messages (see {@link android.util.Log})
 */
public void enableCurlLogging(String name, int level) {
    if (name == null) {
        throw new NullPointerException("name");
    }
    if (level < Log.VERBOSE || level > Log.ASSERT) {
        throw new IllegalArgumentException("Level is out of range ["
            + Log.VERBOSE + ".." + Log.ASSERT + "]");
    }

    curlConfiguration = new LoggingConfiguration(name, level);
}
 
Example 17
Project: FinalProject   File: ReleaseTree.java   Source Code and License Vote up 4 votes
protected void log(int priority, String tag, String message, Throwable t) {
    if(isLoggable(priority)){

        //Report caught exceptions to Crashlytics
        if (priority == Log.ERROR && t != null){
            Crashlytics.logException(t);
        } else if (priority == Log.WARN){
            Crashlytics.log(message);
        } else if (t != null){
            //record the exception if timber is not able to detect it.
            String formattedMessage = LogMessageHelper.format(priority, tag, message);
            Crashlytics.logException(new StackTraceRecorder(formattedMessage));
        }

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

        //split by line , then ensure each line can fit into log's max 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);
                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 18
Project: TMvpSimple-master   File: LogUtils.java   Source Code and License Vote up 3 votes
/**
 * What a Terrible Failure: Report a condition that should never happen. The
 * error will always be logged at level ASSERT with the call stack.
 * Depending on system configuration, a report may be added to the
 * {@link android.os.DropBoxManager} and/or the process may be terminated
 * immediately with an error dialog.
 *
 * @param obj
 */
public static void wtf(Object obj) {
    if (Log.ASSERT > DEBUG_LEVEL) {
        String tag = getClassName();
        String msg = obj != null ? obj.toString() : "obj == null";
        Log.wtf(tag, msg);
    }
}
 
Example 19
Project: TMvpSimple   File: LogUtils.java   Source Code and License Vote up 3 votes
/**
 * What a Terrible Failure: Report a condition that should never happen. The
 * error will always be logged at level ASSERT with the call stack.
 * Depending on system configuration, a report may be added to the
 * {@link android.os.DropBoxManager} and/or the process may be terminated
 * immediately with an error dialog.
 *
 * @param obj
 */
public static void wtf(Object obj) {
    if (Log.ASSERT > DEBUG_LEVEL) {
        String tag = getClassName();
        String msg = obj != null ? obj.toString() : "obj == null";
        Log.wtf(tag, msg);
    }
}
 
Example 20
Project: TMvpSimple-master   File: LogUtils.java   Source Code and License Vote up 2 votes
/**
 * What a Terrible Failure: Report a condition that should never happen. The
 * error will always be logged at level ASSERT with the call stack.
 * Depending on system configuration, a report may be added to the
 * {@link android.os.DropBoxManager} and/or the process may be terminated
 * immediately with an error dialog.
 *
 * @param tag Used to identify the source of a log message.
 * @param msg The message you would like logged.
 */
public static void wtf(String tag, String msg) {
    if (Log.ASSERT > DEBUG_LEVEL) {
        Log.wtf(tag, msg);
    }
}