Java Code Examples for android.util.Log#WARN

The following examples show how to use android.util.Log#WARN . These examples are extracted from open source projects. 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 Project: GTTools   File: LogLine.java    License: MIT License 6 votes vote down vote up
public static int convertCharToLogLevel(char logLevelChar) {
	
	switch (logLevelChar) {
		case 'D':
			return Log.DEBUG;
		case 'E':
			return Log.ERROR;
		case 'I':
			return Log.INFO;
		case 'V':
			return Log.VERBOSE;
		case 'W':
			return Log.WARN;
	}
	return -1;
}
 
Example 2
@Override
protected void log(int priority, @Nullable String tag, @NotNull String message, @Nullable Throwable t) {
    // Workaround for devices that doesn't show lower priority logs
    if(Build.MANUFACTURER == null) {
        return;
    }
    if (Build.MANUFACTURER.equals("HUAWEI") || Build.MANUFACTURER.equals("samsung")) {
        if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO)
            priority = Log.ERROR;
    }
    if (priority >= Log.WARN) {
        if(message.length() < MAX_LOG_LENGTH) {
            super.log(priority, tag, message, t);
            return;
        }
        splitLogMessage(priority, tag, message, t);
    } else {
        if(message.length() < MAX_LOG_LENGTH) {
            super.log(priority, tag, message, t);
            return;
        }
        splitLogMessage(priority, tag, message, t);
    }
}
 
Example 3
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
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 5
Source Project: RxShell   File: JUnitTree.java    License: Apache License 2.0 6 votes vote down vote up
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
Source Project: DoraemonKit   File: LogLine.java    License: Apache License 2.0 6 votes vote down vote up
private static int convertCharToLogLevel(char logLevelChar) {

        switch (logLevelChar) {
            case 'D':
                return Log.DEBUG;
            case 'E':
                return Log.ERROR;
            case 'I':
                return Log.INFO;
            case 'V':
                return Log.VERBOSE;
            case 'W':
                return Log.WARN;
            case 'F':
                return Log.VERBOSE;
        }
        return -1;
    }
 
Example 7
Source Project: Neptune   File: PluginDebugLog.java    License: Apache License 2.0 6 votes vote down vote up
private static void logInternal(String tag, Object msg, int logLevel) {
    if (!TextUtils.isEmpty(tag) && null != msg) {
        String content = String.valueOf(msg);
        switch (logLevel) {
            case Log.ERROR:
                Log.e(tag, content);
                break;
            case Log.WARN:
                Log.w(tag, content);
                break;
            case Log.INFO:
                Log.i(tag, content);
                break;
            case Log.DEBUG:
                Log.d(tag, content);
                break;
            default:
                Log.v(tag, content);
                break;
        }
    }
}
 
Example 8
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 9
Source Project: apollo-DuerOS   File: LogUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * log Send a logLevel log message and log the exception, then collect the log entry.
 *
 * @param aLogLevel  Used to identify log level
 * @param aTag       Used to identify the source of a log message. It usually identifies the class or activity
 *                   where the log call occurs.
 * @param aMessage   The message you would like logged.
 * @param aThrowable An exception to log
 */
public static void log(int aLogLevel, String aTag, String aMessage, Throwable aThrowable) {
    if (isLoggable(aLogLevel)) {
        switch (aLogLevel) {
            case Log.VERBOSE:
                Log.v(TAG, aTag + ": " + aMessage, aThrowable);
                break;
            case Log.DEBUG:
                Log.d(TAG, aTag + ": " + aMessage, aThrowable);
                break;
            case Log.INFO:
                Log.i(TAG, aTag + ": " + aMessage, aThrowable);
                break;
            case Log.WARN:
                Log.w(TAG, aTag + ": " + aMessage, aThrowable);
                break;
            case Log.ERROR:
                Log.e(TAG, aTag + ": " + aMessage, aThrowable);
                break;
            default:
                Log.e(TAG, aTag + ": " + aMessage, aThrowable);
        }
    }
}
 
Example 10
Source Project: browser   File: LogUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
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
@Override
protected void log(int priority, @Nullable String tag, @NotNull String message, @Nullable Throwable t) {
    if(priority >= Log.WARN) {
        if (message.length() < MAX_LOG_LENGTH) {
            Log.println(priority, tag, message);
            return;
        }
        BitgattDebugTree.splitLogMessage(priority, tag, message, t);
    }
}
 
Example 12
Source Project: DoraemonKit   File: LogInfoItem.java    License: Apache License 2.0 5 votes vote down vote up
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 13
Source Project: timecat   File: LogUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 用于区分不同接口数据 打印传入参数
 *
 * @param index
 * @param str
 */

private static void print(int index, Object str) {
    if (!OPEN_LOG) {
        return;
    }
    if (log == null) {
        log = new LogUtil(USER_NAME);
    }
    String name = log.getFunctionName();
    if (name != null) {
        str = String.format("%s -----> %s", name, str);
    }

    // Close the debug log When DEBUG is false
    if (!DEBUG) {
        if (index <= Log.DEBUG) {
            return;
        }
    }
    switch (index) {
        case Log.VERBOSE:
            Log.v(tag, str.toString());
            break;
        case Log.DEBUG:
            Log.d(tag, str.toString());
            break;
        case Log.INFO:
            Log.i(tag, str.toString());
            break;
        case Log.WARN:
            Log.w(tag, str.toString());
            break;
        case Log.ERROR:
            Log.e(tag, str.toString());
            break;
        default:
            break;
    }
}
 
Example 14
Source Project: sctalk   File: Logger.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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
public void initLogger() {
    // Default configuration
    int consoleLogLevel = BuildConfig.DEBUG ? Log.VERBOSE : Log.INFO;
    // File logging based on preferences
    String fileLoggingLevelString = getPreferencesProvider().getFileLoggingLevel();
    if (fileLoggingLevelString.equals(getString(R.string.preferences_file_logging_level_entries_value_disabled))) {
        if (Timber.forest().contains(FileLoggingTree.INSTANCE)) {
            Timber.uproot(FileLoggingTree.INSTANCE);
        }
    } else {
        if (PermissionUtils.hasPermissions(this, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)) {
            int fileLogLevel = Log.ERROR;
            if (fileLoggingLevelString.equals(getString(R.string.preferences_file_logging_level_entries_value_debug))) {
                fileLogLevel = Log.DEBUG;
            } else if (fileLoggingLevelString.equals(getString(R.string.preferences_file_logging_level_entries_value_info))) {
                fileLogLevel = Log.INFO;
            } else if (fileLoggingLevelString.equals(getString(R.string.preferences_file_logging_level_entries_value_warning))) {
                fileLogLevel = Log.WARN;
            } else if (fileLoggingLevelString.equals(getString(R.string.preferences_file_logging_level_entries_value_error))) {
                fileLogLevel = Log.ERROR;
            }
            consoleLogLevel = Math.min(consoleLogLevel, fileLogLevel);
            if (Timber.forest().contains(FileLoggingTree.INSTANCE)) {
                Timber.uproot(FileLoggingTree.INSTANCE);
            }
            Timber.plant(FileLoggingTree.INSTANCE.setPriority(fileLogLevel));
        } else {
            Toast.makeText(this, R.string.permission_logging_denied_temporarily_message, Toast.LENGTH_LONG).show();
        }
    }
    Timber.plant(ConsoleLoggingTree.INSTANCE.setPriority(consoleLogLevel));
}
 
Example 16
private static void log(int type, String str) {
    if (isDebug) {
        switch (type) {
            case Log.WARN:
                Log.w(TAG, str);
                break;
            case Log.ERROR:
                Log.e(TAG, str);
                break;
            case Log.DEBUG:
                Log.d(TAG, str);
                break;
        }
    }
}
 
Example 17
Source Project: apollo-DuerOS   File: LogUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void dumpException(Throwable t) {
    if (CommonParams.LOG_LEVEL <= Log.WARN) {
        final int innerBufLen = 256;
        StringBuilder err = new StringBuilder(innerBufLen);

        err.append("Got exception: ");
        err.append(t.toString());
        err.append("\n");

        System.out.println(err.toString());
        t.printStackTrace(System.out);
    }
}
 
Example 18
int w(String tag, Throwable tr) {
    if (enableLogging && logLevel <= Log.WARN) return Log.w(tag, tr);
    return 0;
}
 
Example 19
Source Project: NewbieGuide   File: LogUtil.java    License: Apache License 2.0 4 votes vote down vote up
public static void w(String msg) {
    if (level <= Log.WARN) {
        String tag = generateTag();
        Log.w(tag, msg);
    }
}
 
Example 20
public static void w(String tag, String s, Throwable tr) {
    if (LOG_LEVEL_MIN <= Log.WARN) {
        Log.w(getTAG(tag), getStr(s), tr);
    }
}