Java Code Examples for android.util.Log#ERROR

The following examples show how to use android.util.Log#ERROR . 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: 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 2
Source File: LogLineAdapterUtil.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
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 3
Source File: LoggerPrinter.java    From XFrame with Apache License 2.0 6 votes vote down vote up
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 4
Source File: LogLine.java    From GTTools with MIT License 6 votes vote down vote up
public static char convertLogLevelToChar(int logLevel) {

		switch (logLevel) {
			case Log.DEBUG:
				return 'D';
			case Log.ERROR:
				return 'E';
			case Log.INFO:
				return 'I';
			case Log.VERBOSE:
				return 'V';
			case Log.WARN:
				return 'W';
		}
		return ' ';
	}
 
Example 5
Source File: LogLine.java    From DoraemonKit with Apache License 2.0 6 votes vote down vote up
private static char convertLogLevelToChar(int logLevel) {

        switch (logLevel) {
            case Log.DEBUG:
                return 'D';
            case Log.ERROR:
                return 'E';
            case Log.INFO:
                return 'I';
            case Log.VERBOSE:
                return 'V';
            case Log.WARN:
                return 'W';
        }
        return ' ';
    }
 
Example 6
Source File: MLog.java    From Readhub with Apache License 2.0 5 votes vote down vote up
private static void printLog(int priority, String tag, String message) {
    try {
        switch (priority) {
            case Log.VERBOSE:
                Logger.t(tag).v(message);
                break;
            case Log.INFO:
                Logger.t(tag).i(message);
                break;
            case Log.DEBUG:
                if (isJSONValid(message)) {
                    Logger.t(tag).json(message);
                } else {
                    Logger.t(tag).d(message);
                }
                break;
            case Log.WARN:
                Logger.t(tag).w(message);
                break;
            case Log.ERROR:
                Logger.t(tag).e(message);
                break;
            default:
                Logger.t(tag).d(message);
                break;
        }
        return;
    } catch (Exception exception) {
        exception.printStackTrace();
        Logger.t(tag).w(exception.toString());
    }
}
 
Example 7
Source File: App.java    From okuki with Apache License 2.0 5 votes vote down vote up
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if (priority == Log.VERBOSE || priority == Log.DEBUG) {
        return;
    }

    //TODO Log to crash reporting
    if (t != null) {
        if (priority == Log.ERROR) {
            //TODO Log throwable as error to crash reporting
        } else if (priority == Log.WARN) {
            //TODO Log throwable as warning to crash reporting
        }
    }
}
 
Example 8
Source File: KcaVpnService.java    From kcanotify with GNU General Public License v3.0 5 votes vote down vote up
private void startNative(ParcelFileDescriptor vpn) {
    // Prepare rules
    int prio = Log.ERROR;
    int rcode = 3;
    SharedPreferences prefs = getSharedPreferences("pref", Context.MODE_PRIVATE);
    boolean enable = prefs.getBoolean("socks5_enable", false);
    String addr = prefs.getString("socks5_address", "");
    String portNum = prefs.getString("socks5_port", "0");
    String username = prefs.getString("socks5_name", "");
    String password = prefs.getString("socks5_pass", "");
    int port = 0;
    if (!portNum.equals(""))
        port = Integer.parseInt(portNum);
    if (enable && !(addr.equals("") || port == 0)) {
        Log.i(TAG, String.format("Proxy enabled, with address %s and port %d, Auth with %s %s", addr, port, username, password));
        // Resolve proxy address
        try {
            addr = InetAddress.getByName( addr ).getHostAddress();
            Log.i(TAG, "Proxy resolved: " + addr);
        }
        catch (UnknownHostException e) {
            Log.w(TAG, "Unknown proxy hostname: " + addr);
        }
        jni_socks5(addr, port, username, password);
    } else {
        Log.i(TAG, "Proxy disabled");
        jni_socks5("", 0, "", "");
    }
    jni_start(vpn.getFd(), true, rcode, prio);
}
 
Example 9
Source File: DefaultSonicRuntimeImpl.java    From AgentWeb with Apache License 2.0 5 votes vote down vote up
@Override
public void log(String tag, int level, String message) {
    switch (level) {
        case Log.ERROR:
            Log.e(tag, message);
            break;
        case Log.INFO:
            Log.i(tag, message);
            break;
        default:
            Log.d(tag, message);
    }
}
 
Example 10
Source File: CarlifeUtil.java    From apollo-DuerOS with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @return true for debug variant, false for release
 */
public static boolean isDebug() {
    if (CommonParams.LOG_LEVEL < Log.ERROR) {
        return true;
    } else {
        return false;
    }

}
 
Example 11
Source File: LoggerPrinter.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 最终打印方法
 * @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 12
Source File: LogUtil.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 记录E级别日志 在记录E级别日志时调用, 如果日志配置为不记录日志或日志级别高于E, 不记录日志
 * 
 * @param tr 异常对象
 * @param msg 日志信息, 支持动态传参可以是一个或多个(避免日志信息的+操作过早的执行)
 * @author kjxu
 */
public static void e(Throwable tr, String... msg) {
    if (ADB && LOG_DEGREE <= Log.ERROR) {
    	getMethodNames(new Throwable().getStackTrace());
    	String msgStr = createLog(msg);
    	
        Log.e(className, msgStr, tr);
        
        writeLogToFile(Log.ERROR, className, msgStr, tr);

    }
}
 
Example 13
Source File: Logger.java    From sctalk with Apache License 2.0 5 votes vote down vote up
/**
 * log.e
 */
public void e(String format, Object... args) {
	if (logLevel <= Log.ERROR) {
		lock.lock();
		try {
			String message = createMessage(getInputString(format, args));
			Log.e(tagName, message);
		} finally {
			lock.unlock();
		}
	}
}
 
Example 14
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 15
Source File: GndApplication.java    From ground-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void log(int priority, String tag, @NonNull String message, Throwable throwable) {
  if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO) {
    return;
  }

  FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
  crashlytics.log(message);

  if (throwable != null && priority == Log.ERROR) {
    crashlytics.recordException(throwable);
  }
}
 
Example 16
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 17
Source File: AmplitudeLog.java    From shinny-futures-android with GNU General Public License v3.0 4 votes vote down vote up
int e(String tag, String msg, Throwable tr) {
    if (enableLogging && logLevel <= Log.ERROR) return Log.e(tag, msg, tr);
    return 0;
}
 
Example 18
Source File: VLog.java    From Phantom with Apache License 2.0 4 votes vote down vote up
public static void e(Throwable throwable, String msg, Object... format) {
    if (Log.ERROR >= sLevel) {
        Log.e(sTag, buildMsg(String.format(msg, format)), throwable);
    }
}
 
Example 19
Source File: L.java    From materialup with Apache License 2.0 4 votes vote down vote up
private static void log(final int pType, final Throwable t, final Object s1,
                        final Object... args) {
    if (pType == Log.ERROR || BuildConfig.DEBUG || Log.isLoggable("L", pType)) {
        final StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[4];

        final String fullClassName = stackTraceElement.getClassName();
        final String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
        final int lineNumber = stackTraceElement.getLineNumber();
        final String method = stackTraceElement.getMethodName();

        final String tag = className + ":" + lineNumber;

        final StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(method);
        stringBuilder.append("(): ");

        if (s1 != null) {
            final String message = (args == null) ? s1.toString()
                    : String.format((String) s1, args);
            stringBuilder.append(message);
        }

        switch (pType) {
            case Log.VERBOSE:
                if (t != null) {
                    Log.v(tag, stringBuilder.toString(), t);
                } else {
                    Log.v(tag, stringBuilder.toString());
                }
                break;

            case Log.DEBUG:
                if (t != null) {
                    Log.d(tag, stringBuilder.toString(), t);
                } else {
                    Log.d(tag, stringBuilder.toString());
                }
                break;

            case Log.INFO:
                if (t != null) {
                    Log.i(tag, stringBuilder.toString(), t);
                } else {
                    Log.i(tag, stringBuilder.toString());
                }
                break;

            case Log.WARN:
                if (t != null) {
                    Log.w(tag, stringBuilder.toString(), t);
                } else {
                    Log.w(tag, stringBuilder.toString());
                }
                break;

            case Log.ERROR:
                if (t != null) {
                    Log.e(tag, stringBuilder.toString(), t);
                } else {
                    Log.e(tag, stringBuilder.toString());
                }
                break;
        }
    }
}
 
Example 20
Source File: VLog.java    From Phantom with Apache License 2.0 4 votes vote down vote up
public static void e(String format, Object... args) {
    if (Log.ERROR >= sLevel) {
        Log.e(sTag, buildMsg(String.format(format, args)));
    }
}