Java Code Examples for android.util.Log#ASSERT
The following examples show how to use
android.util.Log#ASSERT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingUtils.java From go-bees with GNU General Public License v3.0 | 6 votes |
/** * Formats the priority of the log. */ private static String formatPriority(int priority) { switch (priority) { 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 2
Source File: RobolectricTestWithConfig.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private static String logTypeToString(int type) { switch (type) { case Log.ASSERT: return "Assert"; case Log.DEBUG: return "Debug"; case Log.ERROR: return "Error"; case Log.WARN: return "Warn"; case Log.INFO: return "Info"; case Log.VERBOSE: return "Verbose"; default: return "?"; } }
Example 3
Source File: RobolectricTestWithConfig.java From xDrip with GNU General Public License v3.0 | 6 votes |
private static String logTypeToString(int type) { switch (type) { case Log.ASSERT: return "Assert"; case Log.DEBUG: return "Debug"; case Log.ERROR: return "Error"; case Log.WARN: return "Warn"; case Log.INFO: return "Info"; case Log.VERBOSE: return "Verbose"; default: return "?"; } }
Example 4
Source File: LoggerPrinter.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 判断日志级别是否允许输出 * @param logLevel 日志级别 * @param logType 日志类型 * @return {@code true} yes, {@code false} no */ private boolean checkLogLevel(final LogLevel logLevel, final int logType) { switch (logLevel) { case INFO: // 正常级别 i if (logType != Log.VERBOSE && logType != Log.DEBUG) { return true; } break; case WARN: // 警告级别 w if (logType != Log.VERBOSE && logType != Log.DEBUG && logType != Log.INFO) { return true; } break; case ERROR: // 异常级别 e, wtf if (logType == Log.ERROR || logType == Log.ASSERT) { return true; } break; default: break; } return false; }
Example 5
Source File: LoggerPrinter.java From XFrame with Apache License 2.0 | 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 6
Source File: McuMgrBleTransport.java From mcumgr-android with Apache License 2.0 | 6 votes |
@Override public void log(int priority, @NonNull String message) { if (mLoggingEnabled) { switch (priority) { case Log.DEBUG: LOG.debug(message); break; case Log.INFO: LOG.info(message); break; case Log.WARN: LOG.warn(message); break; case Log.ERROR: case Log.ASSERT: LOG.error(message); break; case Log.VERBOSE: default: LOG.trace(message); break; } } }
Example 7
Source File: TimberDataModule.java From DebugOverlay-Android with Apache License 2.0 | 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 8
Source File: XLog.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private String logLevel(int level) { String l = "W"; switch (level) { case Log.WARN: l = "W"; break; case Log.ASSERT: l = "A"; break; case Log.VERBOSE: l = "V"; break; case Log.DEBUG: l = "D"; break; case Log.INFO: l = "I"; break; case Log.ERROR: l = "E"; break; } return l; }
Example 9
Source File: LoggerTest.java From AppAuth-Android with Apache License 2.0 | 5 votes |
private void configureLog(int minLevel) { for (int level = Log.VERBOSE; level <= Log.ASSERT; level++) { when(mMockLockWrap.isLoggable(Logger.LOG_TAG, level)).thenReturn(level >= minLevel); } when(mMockLockWrap.getStackTraceString(any(Throwable.class))).thenReturn("STACK"); Logger.setInstance(new Logger(mMockLockWrap)); }
Example 10
Source File: AndroidLogger.java From sentry-android with MIT License | 5 votes |
private int toLogcatLevel(SentryLevel sentryLevel) { switch (sentryLevel) { case INFO: return Log.INFO; case WARNING: return Log.WARN; case FATAL: return Log.ASSERT; case LOG: case DEBUG: default: return Log.DEBUG; } }
Example 11
Source File: ReleaseTimberTree.java From Learning-Resources with MIT License | 5 votes |
@Override protected void log(int priority, String tag, String message, Throwable t) { if (isLoggable(tag, priority)) { //Report to Caught Exception to Crash Reporting tools Like Crashlytics ( Or other Tools) if (priority == Log.ERROR && tag != null) { //Crashlytics.log(priority,tag,message); //Crashlytics.log(message); } //Message is short enough, no need to be broken in chunk 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 messagePart = message.substring(i, end); if (priority == Log.ASSERT) { Log.wtf(tag, messagePart); } else { Log.println(priority, tag, messagePart); } i = end; } while (i < newLine); } } }
Example 12
Source File: Timber.java From RxJava2RetrofitDemo with Apache License 2.0 | 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 13
Source File: ReleaseTree.java From InstantAppStarter with MIT License | 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
Source File: LoggerPrinter.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 最终打印方法 * @param logType 日志类型 * @param tag 日志 TAG * @param message 日志信息 */ private void finalLogPrinter(final int logType, final String tag, final String message) { // 防止 null 处理 if (message == null) return; // 获取日志类型 switch (logType) { 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); break; case Log.ERROR: Log.e(tag, message); break; case Log.ASSERT: Log.wtf(tag, message); break; default: // 默认使用, 自定义级别 Log.wtf(tag, message); break; } }
Example 15
Source File: LogPrintUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 最终打印日志方法 ( 全部调用此方法 ) * @param logType 日志类型 * @param tag 打印 Tag * @param message 日志信息 */ private static void printLog(final int logType, final String tag, final String message) { // 防止 null 处理 if (message == null) return; // 获取日志类型 switch (logType) { case Log.ERROR: Log.e(tag, message); break; case Log.INFO: Log.i(tag, message); break; case Log.VERBOSE: Log.v(tag, message); break; case Log.WARN: Log.w(tag, message); break; case Log.ASSERT: Log.wtf(tag, message); break; case Log.DEBUG: Log.d(tag, message); break; default: Log.d(tag, message); break; } }
Example 16
Source File: LogInfoItem.java From DoraemonKit with Apache License 2.0 | 5 votes |
public LogInfoItem(String log) { orginalLog = log; if (log.contains("V/")) { level = Log.VERBOSE; } else if (log.contains("D/")) { level = Log.DEBUG; } else if (log.contains("I/")) { level = Log.INFO; } else if (log.contains("W/")) { level = Log.WARN; } else if (log.contains("E/")) { level = Log.ERROR; } else if (log.contains("A/")) { level = Log.ASSERT; } int beginIndex = log.indexOf(": "); if (beginIndex == -1) { meseage = log; } else { meseage = log.substring(beginIndex + 2); } beginIndex = log.indexOf("/"); int endIndex = log.indexOf("/", beginIndex + 1); if (beginIndex != -1 && endIndex != -1) { packagePriority = log.substring(beginIndex + 1, endIndex - 3); } endIndex = log.indexOf(" "); if (endIndex != -1) { date = log.substring(0, endIndex); } beginIndex = endIndex; endIndex = log.indexOf(" ", beginIndex + 1); if (endIndex != -1 && beginIndex != -1) { time = log.substring(beginIndex, endIndex); } }
Example 17
Source File: FileTree.java From ViseLog with Apache License 2.0 | 4 votes |
private void saveMessageToSDCard(int type, String tag, String message) { //如果SD卡不存在或无法使用,则无法把日志信息写入SD卡 if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { System.out.print("sdcard unmounted, skip dump exception"); return; } File dir = new File(PATH + mDirectory); if (!dir.exists()) { dir.mkdirs(); } String timeDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis())); String timeHour = new SimpleDateFormat("yyyy-MM-dd-HH").format(new Date(System.currentTimeMillis())); String timeMinute = new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date(System.currentTimeMillis())); String timeSecond = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date(System.currentTimeMillis())); String fileName = FILE_NAME_VERBOSE; switch (type) { case Log.VERBOSE: fileName = FILE_NAME_VERBOSE + timeMinute; break; case Log.INFO: fileName = FILE_NAME_INFO + timeHour; break; case Log.DEBUG: fileName = FILE_NAME_DEBUG + timeMinute; break; case Log.WARN: fileName = FILE_NAME_WARN + timeDay; break; case Log.ERROR: fileName = FILE_NAME_ERROR + timeSecond; break; case Log.ASSERT: fileName = FILE_NAME_ASSERT + timeDay; break; default: break; } mLogFile = new File(PATH + mDirectory + File.separator + fileName + FILE_NAME_SUFFIX); try { if (!mLogFile.exists()) { mLogFile.createNewFile(); mIsPrintPhoneInfo = true; } else { mIsPrintPhoneInfo = false; } PrintWriter printWriter = new PrintWriter(new BufferedWriter(new FileWriter(mLogFile, true))); if (!mIsPrintPhoneInfo) { //换行 printWriter.println(); printWriter.println(); } //打印发生异常的时间 printWriter.println(timeSecond); if (mIsPrintPhoneInfo) { //打印手机信息 printPhoneInfo(printWriter); //换行 printWriter.println(); } //打印日志信息 printWriter.print(tag + "\t" + message); printWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
Example 18
Source File: AmplitudeLog.java From shinny-futures-android with GNU General Public License v3.0 | 4 votes |
int wtf(String tag, String msg, Throwable tr) { if (enableLogging && logLevel <= Log.ASSERT) return Log.wtf(tag, msg, tr); return 0; }
Example 19
Source File: AmplitudeLog.java From shinny-futures-android with GNU General Public License v3.0 | 4 votes |
int wtf(String tag, Throwable tr) { if (enableLogging && logLevel <= Log.ASSERT) return Log.wtf(tag, tr); return 0; }
Example 20
Source File: AmplitudeLog.java From shinny-futures-android with GNU General Public License v3.0 | 4 votes |
int wtf(String tag, String msg) { if (enableLogging && logLevel <= Log.ASSERT) return Log.wtf(tag, msg); return 0; }