opened
hqq2023623
username_0
- [ ] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索，没有重复的issue。

### 环境信息

* 分支 : master
* Arthas 版本 : 3.1.1-SNAPSHOT

### 重现问题的步骤

1. 启动demo.MathGame
2. 启动arthas
3. 执行命令 
  watch -E demo.MathGame print|primeFactors "{params,returnObj}" -x 1

### 期望的结果

What do you expected from the above steps？
希望在使用-E监听多个方法执行时能带上方法名：
比如：
``` java
public java.util.List demo.MathGame.primeFactors(int)
ts=2019-04-18 22:25:55; [cost=0.779152ms] result=@ArrayList[
    @Object[][isEmpty=false;size=1],
    @ArrayList[isEmpty=false;size=3],
]
public static void demo.MathGame.print(int,java.util.List)
ts=2019-04-18 22:25:55; [cost=0.251226ms] result=@ArrayList[
    @Object[][isEmpty=false;size=2],
    null,
]
public java.util.List demo.MathGame.primeFactors(int)
ts=2019-04-18 22:25:56; [cost=0.148582ms] result=@ArrayList[
    @Object[][isEmpty=false;size=1],
    null,
]

```


### 实际运行的结果

实际运行结果，最好有详细的日志，异常栈。尽量贴文本。

``` java
 $ watch -E demo.MathGame print|primeFactors "{params,returnObj}" -x 1
watch -E demo.MathGame print|primeFactors "{params,returnObj}" -x 1
Press Q or Ctrl+C to abort.
Affect(class-cnt:1 , method-cnt:2) cost in 12 ms.
ts=2019-04-18 22:04:14; [cost=0.084969ms] result=@ArrayList[
    @Object[][isEmpty=false;size=1],
    @ArrayList[isEmpty=false;size=2],
]
ts=2019-04-18 22:04:14; [cost=0.134199ms] result=@ArrayList[
    @Object[][isEmpty=false;size=2],
    null,
]
ts=2019-04-18 22:04:15; [cost=0.092992ms] result=@ArrayList[
    @Object[][isEmpty=false;size=1],
    null,
]
ts=2019-04-18 22:04:16; [cost=0.477355ms] result=@ArrayList[
    @Object[][isEmpty=false;size=1],
    @ArrayList[isEmpty=false;size=2],
]
```


### 解决方案
1、在WatchAdviceListener的85行输出结果的地方加上方法信息
``` java
private void watching(Advice advice) {
        try {
            // 本次调用的耗时
            double cost = threadLocalWatch.costInMillis();
            if (isConditionMet(command.getConditionExpress(), advice, cost)) {
                // TODO: concurrency issues for process.write
                Object value = getExpressionResult(command.getExpress(), advice, cost);
                String result = StringUtils.objectToString(
                        isNeedExpand() ? new ObjectView(value, command.getExpand(), command.getSizeLimit()).draw() : value);
                //增加方法的输出
                process.write(advice.getMethod() + "\n");
                process.write("ts=" + DateUtils.getCurrentDate() + "; [cost=" + cost + "ms] result=" + result + "\n");
                process.times().incrementAndGet();
                if (isLimitExceeded(command.getNumberOfLimit(), process.times().get())) {
                    abortProcess(process, command.getNumberOfLimit());
                }
            }
        } catch (Exception e) {
            logger.warn("watch failed.", e);
            process.write("watch failed, condition is: " + command.getConditionExpress() + ", express is: "
                          + command.getExpress() + ", " + e.getMessage() + ", visit " + LogUtil.LOGGER_FILE
                          + " for more details.\n");
            process.end();
        }
    }
```
WatchCommand结果输出优化
issue
created
hengyunabc
username_1
一个简单的解法是把 method入到 返回值表达式里。
comment
created
hqq2023623
username_0
把method加进去解决了
还有个点就是能否把express的key给带上，现在返回的ArrayList得按顺序去数才知道对应的结果
``` java
$ watch demo.MathGame * "{target,clazz,method,params,returnObj,throwExp,isReturn,isThrow,#cost}" -x 1
Press Q or Ctrl+C to abort.
Affect(class-cnt:1 , method-cnt:5) cost in 33 ms.
ts=2019-04-19 09:42:36; [cost=0.199626ms] result=@ArrayList[
    @MathGame[demo.MathGame@37f8bb67],
    @Class[class demo.MathGame],
    @ArthasMethod[public java.util.List demo.MathGame.primeFactors(int)],
    @Object[][isEmpty=false;size=1],
    null,
    @IllegalArgumentException[java.lang.IllegalArgumentException: number is: -108954, need >= 2],
    @Boolean[false],
    @Boolean[true],
    @Double[0.199626],
]
ts=2019-04-19 09:42:36; [cost=18.996848ms] result=@ArrayList[
    @MathGame[demo.MathGame@37f8bb67],
    @Class[class demo.MathGame],
    @ArthasMethod[public void demo.MathGame.run() throws java.lang.InterruptedException],
    @Object[][isEmpty=true;size=0],
    null,
    null,
    @Boolean[true],
    @Boolean[false],
    @Double[18.996848],
]

```
comment
created
hengyunabc
username_1
https://commons.apache.org/proper/commons-ognl/language-guide.html

```
#{ "foo" : "foo value", "bar" : "bar value" }
```
comment
created
hqq2023623
username_0
试了下，这几种方式都可以实现
1、 watch demo.MathGame * "#{'method':method}" -x 1
2、 watch demo.MathGame * #{\"params\":params} -x 1
3、 watch demo.MathGame * '#{"method":method}' -x 1
comment
closed
hengyunabc
username_1
issue