android.util.Log#getStackTraceString ( )源码实例Demo

下面列出了android.util.Log#getStackTraceString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: media-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码2 项目: media-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码3 项目: user-interface-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码4 项目: user-interface-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 *
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag      Tag for for the log data.  Can be used to organize log statements.
 * @param msg      The actual message to be logged. The actual message to be logged.
 * @param tr       If an exception was thrown, this can be sent along for the logging
 *                 facilities
 *                 to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
/**
 * Prints data out to the console using Android's native log mechanism.
 *
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag      Tag for for the log data.  Can be used to organize log statements.
 * @param msg      The actual message to be logged. The actual message to be logged.
 * @param tr       If an exception was thrown, this can be sent along for the logging
 *                 facilities
 *                 to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码6 项目: RxAndroidBle   文件: RxBleLog.java
private static void throwShade(int priority, Throwable t, String message, Object... args) {
    if (priority < loggerSetup.logLevel) {
        return;
    }

    final String formattedMessage = formatString(message, args);
    final String finalMessage;

    if (formattedMessage == null || formattedMessage.length() == 0) {
        if (t != null) {
            finalMessage = Log.getStackTraceString(t);
        } else {
            // Swallow message if it's null and there's no throwable.
            return;
        }
    } else if (t != null) {
        finalMessage = formattedMessage + "\n" + Log.getStackTraceString(t);
    } else {
        finalMessage = formattedMessage;
    }

    String tag = createTag();
    println(priority, tag, finalMessage);
}
 
源代码7 项目: graphics-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码8 项目: fit-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码9 项目: user-interface-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码10 项目: animation-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码11 项目: user-interface-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码12 项目: fit-samples   文件: LogWrapper.java
/**
 * Prints data out to the console using Android's native log mechanism.
 * @param priority Log level of the data being logged.  Verbose, Error, etc.
 * @param tag Tag for for the log data.  Can be used to organize log statements.
 * @param msg The actual message to be logged. The actual message to be logged.
 * @param tr If an exception was thrown, this can be sent along for the logging facilities
 *           to extract and print useful information.
 */
@Override
public void println(int priority, String tag, String msg, Throwable tr) {
    // There actually are log methods that don't take a msg parameter.  For now,
    // if that's the case, just convert null to the empty string and move on.
    String useMsg = msg;
    if (useMsg == null) {
        useMsg = "";
    }

    // If an exeption was provided, convert that exception to a usable string and attach
    // it to the end of the msg method.
    if (tr != null) {
        msg += "\n" + Log.getStackTraceString(tr);
    }

    // This is functionally identical to Log.x(tag, useMsg);
    // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg)
    Log.println(priority, tag, useMsg);

    // If this isn't the last node in the chain, move things along.
    if (mNext != null) {
        mNext.println(priority, tag, msg, tr);
    }
}
 
源代码13 项目: sctalk   文件: DumpUtils.java
public static void dumpStacktrace(Logger logger, String desc,
		boolean oneLine) {
	String stackTraceString = Log.getStackTraceString(new Throwable());

	if (oneLine) {
		stackTraceString = stackTraceString.replace("\n", "####");
	}
	
	logger.d("%s:%s", desc, stackTraceString);
}
 
源代码14 项目: NaviBee   文件: VoiceCallEngine.java
private VoiceCallEngine() {
    try {
        mRtcEngine = RtcEngine.create(NaviBeeApplication.getInstance().getBaseContext(), NaviBeeApplication.getInstance().getString(R.string.agora_app_id), mRtcEventHandler);
    } catch (Exception e) {
        Log.e(LOG_TAG, Log.getStackTraceString(e));

        throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
    }
    mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION);
}
 
源代码15 项目: HotFixDemo   文件: MyLogImp.java
@Override
public void printErrStackTrace(String s, Throwable throwable, String s1, Object... objects) {
    String log = objects == null ? s1 : String.format(s1, objects);
    if (log == null) {
        log = "";
    }
    log = log + "  " + Log.getStackTraceString(throwable);
    Log.e(s, log);
}
 
源代码16 项目: QNotified   文件: BugCollector.java
public static void onThrowable(Throwable th) {
    try {
        long time = System.currentTimeMillis();
        String logstr = Log.getStackTraceString(th);
        int hash = logstr.hashCode();


    } catch (Throwable ignored) {
    }
}
 
源代码17 项目: XposedSmsCode   文件: XLog.java
private static void log(int priority, String message, Object... args) {
    if (priority < sLogLevel)
        return;

    message = String.format(message, args);

    if (args.length > 0 && args[args.length - 1] instanceof Throwable) {
        Throwable throwable = (Throwable) args[args.length - 1];
        String stacktraceStr = Log.getStackTraceString(throwable);
        message += '\n' + stacktraceStr;
    }

    // Write to the default log tag
    Log.println(priority, LOG_TAG, message);

    // Duplicate to the Xposed log if enabled
    if (LOG_TO_XPOSED) {
        if (priority <= Log.DEBUG) { // DEBUG level 不会在Xposed日志中生成,所以调整等级
            priority = Log.INFO;
        }
        Log.println(priority, "Xposed", LOG_TAG + ": " + message);
    }

    if (LOG_TO_EDXPOSED) {
        Log.println(priority, "EdXposed-Bridge", LOG_TAG + ": " + message);
    }
}
 
源代码18 项目: PreferencesProvider   文件: LogUtils.java
public static String getStackTraceString(Throwable tr) {
    return Log.getStackTraceString(tr);
}
 
源代码19 项目: Ezalor   文件: LogUtils.java
public static void logwForce(Throwable e) {
    String msg = Log.getStackTraceString(e);
    Log.w(getCurrentAppTagForce(), msg);
    saveLogIfNeeded(getCurrentAppTagForce(), msg, "W");
}
 
源代码20 项目: Phantom   文件: VLog.java
public static String getStackTraceString(Throwable tr) {
    return Log.getStackTraceString(tr);
}