本文整理汇总了Java中android.util.Log.getStackTraceString方法的典型用法代码示例。如果您正苦于以下问题:Java Log.getStackTraceString方法的具体用法?Java Log.getStackTraceString怎么用?Java Log.getStackTraceString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.Log
的用法示例。
在下文中一共展示了Log.getStackTraceString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: println
import android.util.Log; //导入方法依赖的package包/类
/**
* 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: ensureRtcEngineReadyLock
import android.util.Log; //导入方法依赖的package包/类
private RtcEngine ensureRtcEngineReadyLock() {
if (mRtcEngine == null) {
String appId = mContext.getString(R.string.private_app_id);
if (TextUtils.isEmpty(appId)) {
throw new RuntimeException("NEED TO use your App ID, get your own ID at https://dashboard.agora.io/");
}
try {
mRtcEngine = RtcEngine.create(mContext, appId, mEngineEventHandler.mRtcEventHandler);
} catch (Exception e) {
log.error(Log.getStackTraceString(e));
throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
}
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION);
mRtcEngine.enableAudioVolumeIndication(200, 3); // 200 ms
mRtcEngine.setLogFile(Environment.getExternalStorageDirectory()
+ File.separator + mContext.getPackageName() + "/log/agora-rtc.log");
}
return mRtcEngine;
}
示例3: ensureRtcEngineReadyLock
import android.util.Log; //导入方法依赖的package包/类
private RtcEngine ensureRtcEngineReadyLock() {
if (mRtcEngine == null) {
String appId = mContext.getString(R.string.private_app_id);
if (TextUtils.isEmpty(appId)) {
throw new RuntimeException("NEED TO use your App ID, get your own ID at https://dashboard.agora.io/");
}
try {
mRtcEngine = RtcEngine.create(mContext, appId, mEngineEventHandler.mRtcEventHandler);
} catch (Exception e) {
log.error(Log.getStackTraceString(e));
throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
}
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
mRtcEngine.enableVideo();
mRtcEngine.setLogFile(Environment.getExternalStorageDirectory()
+ File.separator + mContext.getPackageName() + "/log/agora-rtc.log");
mRtcEngine.enableDualStreamMode(true);
}
return mRtcEngine;
}
示例4: initializeAgoraEngine
import android.util.Log; //导入方法依赖的package包/类
private void initializeAgoraEngine() {
try {
mRtcEngine = RtcEngine.create(getBaseContext(), 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));
}
}
示例5: leakInfo
import android.util.Log; //导入方法依赖的package包/类
public static String leakInfo(Context context, HeapDump heapDump, AnalysisResult result,
boolean detailed) {
PackageManager packageManager = context.getPackageManager();
String packageName = context.getPackageName();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
String info = "In " + packageName + ":" + packageInfo.versionName + ":" + packageInfo
.versionCode + ".\n";
String detailedString = "";
if (result.leakFound) {
if (result.excludedLeak) {
info = info + "* LEAK CAN BE IGNORED.\n";
}
info = info + "* " + result.className;
if (!heapDump.referenceName.equals("")) {
info = info + " (" + heapDump.referenceName + SocializeConstants.OP_CLOSE_PAREN;
}
info = info + " has leaked:\n" + result.leakTrace.toString() + "\n";
if (detailed) {
detailedString = "\n* Details:\n" + result.leakTrace.toDetailedString();
}
} else {
info = result.failure != null ? info + "* FAILURE:\n" + Log.getStackTraceString
(result.failure) + "\n" : info + "* NO LEAK FOUND.\n\n";
}
return info + "* Reference Key: " + heapDump.referenceKey + "\n" + "* Device: " +
Build.MANUFACTURER + " " + Build.BRAND + " " + Build.MODEL + " " + Build
.PRODUCT + "\n" + "* Android Version: " + VERSION.RELEASE + " API: " +
VERSION.SDK_INT + " LeakCanary: " + BuildConfig.LIBRARY_VERSION + "\n" + "* " +
"Durations: watch=" + heapDump.watchDurationMs + "ms, gc=" + heapDump
.gcDurationMs + "ms, heap dump=" + heapDump.heapDumpDurationMs + "ms, " +
"analysis=" + result.analysisDurationMs + "ms" + "\n" + detailedString;
} catch (NameNotFoundException e) {
throw new RuntimeException(e);
}
}
示例6: printErrStackTrace
import android.util.Log; //导入方法依赖的package包/类
@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);
android.util.Log.e(s, log);
}
示例7: log
import android.util.Log; //导入方法依赖的package包/类
@Override public void log(int level, String message, Throwable t) {
int logLevel = level == WARN ? Log.WARN : Log.DEBUG;
if (t != null) message = message + '\n' + Log.getStackTraceString(t);
// 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);
Log.println(logLevel, "OkHttp", message.substring(i, end));
i = end;
} while (i < newline);
}
}
示例8: println
import android.util.Log; //导入方法依赖的package包/类
private void println(int priority, String message, Throwable t) {
if (message == null) {
message = "";
}
if (t != null) {
message += '\n' + Log.getStackTraceString(t);
}
Log.println(priority, mTag, message);
}
示例9: initializeAgoraEngine
import android.util.Log; //导入方法依赖的package包/类
private void initializeAgoraEngine() {
try {
mRtcEngine = RtcEngine.create(getBaseContext(), 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_LIVE_BROADCASTING);
}
示例10: log
import android.util.Log; //导入方法依赖的package包/类
private static void log(int level, Object o, Throwable tr) {
if (!ENABLED) return;
String trace = generateTrace();
String toast = trace.split("\\(")[0];
String message = generateMessage(o) + SEPARATOR + trace;
if (tr != null) {
message += "\n" + Log.getStackTraceString(tr);
}
switch (level) {
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);
// ToastManager.show("Log.WARN\n" + toast);
break;
case Log.ERROR:
Log.e(TAG, message);
// ToastManager.show("Log.ERROR\n" + toast);
// throw new IllegalStateException(message);
break;
case Log.ASSERT:
Log.wtf(TAG, message);
// ToastManager.show("Log.ASSERT\n" + toast);
// throw new IllegalStateException(message);
break;
default:
throw new IllegalStateException();
}
}
示例11: dumpStacktrace
import android.util.Log; //导入方法依赖的package包/类
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);
}
示例12: getStackTraceString
import android.util.Log; //导入方法依赖的package包/类
public static String getStackTraceString(Throwable th) {
return Log.getStackTraceString(th);
}
示例13: getStackTraceString
import android.util.Log; //导入方法依赖的package包/类
@Test public void getStackTraceString() {
Throwable throwable = new Throwable("test");
String androidTraceString = Log.getStackTraceString(throwable);
assertThat(Utils.getStackTraceString(throwable)).isEqualTo(androidTraceString);
}
示例14: getStackTraceString
import android.util.Log; //导入方法依赖的package包/类
public static String getStackTraceString(Throwable tr) {
return Log.getStackTraceString(tr);
}
示例15: getStackTraceString
import android.util.Log; //导入方法依赖的package包/类
public static String getStackTraceString(Throwable tr) {
return Log.getStackTraceString(tr);
}