Java Code Examples for android.util.Log#WARN

The following examples show how to use android.util.Log#WARN . 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: LogLine.java    From GTTools with 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
Source File: BitgattDebugTree.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
@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
Source File: LogUtil.java    From apollo-DuerOS with 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 4
Source File: RobolectricTestWithConfig.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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 5
Source File: LogLineAdapterUtil.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
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 6
Source File: JUnitTree.java    From RxShell with 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 7
Source File: TimberDataModule.java    From DebugOverlay-Android with Apache License 2.0 6 votes vote down vote up
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: LogLine.java    From DoraemonKit with 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 9
Source File: PluginDebugLog.java    From Neptune with 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 10
Source File: LogUtil.java    From apollo-DuerOS with 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 11
Source File: SecurePreferences.java    From secure-preferences with Apache License 2.0 5 votes vote down vote up
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 12
Source File: MyApplication.java    From TowerCollector with Mozilla Public License 2.0 5 votes vote down vote up
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 13
Source File: Logger.java    From sctalk with 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 14
Source File: LogUtil.java    From timecat with 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 15
Source File: LogInfoItem.java    From DoraemonKit with 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 16
Source File: BitgattReleaseTree.java    From bitgatt with Mozilla Public License 2.0 5 votes vote down vote up
@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 17
Source File: LogUtil.java    From browser with 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 18
Source File: LogUtil.java    From NewbieGuide with 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 19
Source File: LogUtils.java    From GLES2_AUDIO_VIDEO_RECODE with Apache License 2.0 4 votes vote down vote up
public static void w(String tag, String s, Throwable tr) {
    if (LOG_LEVEL_MIN <= Log.WARN) {
        Log.w(getTAG(tag), getStr(s), tr);
    }
}
 
Example 20
Source File: AmplitudeLog.java    From shinny-futures-android with GNU General Public License v3.0 4 votes vote down vote up
int w(String tag, Throwable tr) {
    if (enableLogging && logLevel <= Log.WARN) return Log.w(tag, tr);
    return 0;
}