【问题标题】:How to log a library variable in java?如何在java中记录库变量?
【发布时间】:2017-10-21 15:02:54
【问题描述】:

我想在外部库(Android 中的 AppCompat)中记录一个变量值。

有可能吗?我知道我可以打断点并检查一个值,但我想检查许多很难用这种方式调试的触摸事件回调

例如,代码是:

int setHeaderTopBottomOffset(CoordinatorLayout parent, V header, int newOffset,
    int minOffset, int maxOffset) {
    final int curOffset = getTopAndBottomOffset();
    int consumed = 0;

    if (minOffset != 0 && curOffset >= minOffset && curOffset <= maxOffset) {
          // If we have some scrolling range, and we're currently within the min and max
          // offsets, calculate a new offset
          newOffset = MathUtils.constrain(newOffset, minOffset, maxOffset);

          if (curOffset != newOffset) {
              setTopAndBottomOffset(newOffset);
              // Update how much dy we have consumed
              consumed = curOffset - newOffset;
          }
      }

      return consumed;
 }

我想在curOffset != newOffset 和注销curOffsetnewOffset 时记录案例

【问题讨论】:

  • 请提供具体细节。

标签: java android debugging logging libraries


【解决方案1】:

您可以在IDEA中通过在您感兴趣的行上设置断点来执行此操作,然后右键单击断点,取消选中Suspend选项并在Evaluate and log中填写Log.d(TAG, debugMessage)之类的内容

【讨论】:

    猜你喜欢
    • 2020-09-23
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    • 2016-06-12
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多