当前位置: 首页>>代码示例>>Java>>正文


Java Log.getStackTraceString方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:LogWrapper.java

示例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;
}
 
开发者ID:AgoraIO,项目名称:OpenVoiceCall-Android,代码行数:20,代码来源:WorkerThread.java

示例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;
}
 
开发者ID:AgoraIO,项目名称:OpenLive-Android,代码行数:21,代码来源:WorkerThread.java

示例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));
    }
}
 
开发者ID:AgoraIO,项目名称:Agora-Android-Voice-Tutorial-1to1,代码行数:10,代码来源:VoiceChatViewActivity.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:LeakCanary.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:MyLogImp.java

示例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);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:AndroidPlatform.java

示例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);
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:11,代码来源:Cat.java

示例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);
}
 
开发者ID:AgoraIO,项目名称:Agora-Video-Source-Android,代码行数:11,代码来源:VideoChatViewActivity.java

示例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();
        }
    }
 
开发者ID:killnono,项目名称:Dalaran,代码行数:40,代码来源:LogUtils.java

示例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);
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:11,代码来源:DumpUtils.java

示例12: getStackTraceString

import android.util.Log; //导入方法依赖的package包/类
public static String getStackTraceString(Throwable th) {
    return Log.getStackTraceString(th);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:DaoLog.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:UtilsTest.java

示例14: getStackTraceString

import android.util.Log; //导入方法依赖的package包/类
public static String getStackTraceString(Throwable tr) {
    return Log.getStackTraceString(tr);
}
 
开发者ID:mengdd,项目名称:TodoRealm,代码行数:4,代码来源:LogUtils.java

示例15: getStackTraceString

import android.util.Log; //导入方法依赖的package包/类
public static String getStackTraceString(Throwable tr) {
	return Log.getStackTraceString(tr);
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:4,代码来源:VLog.java


注:本文中的android.util.Log.getStackTraceString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。