Macaca Macaca 框架 log 级别如何控制???

sruru · 2017年02月21日 · 906 次阅读

如上图所示,我在运行 macaca 框架的时候,会输出大量的这种类型的 log,实在是影响查看关键信息,我查了下 macaca 代码,应该是在 System.out.println 输出的,想问下,这种 log 输出能否重新处理下,用 common-logging, slf4j 之类的来处理

public Object postRequest(String method, JSONObject jsonBody) throws Exception {
    JSONObject tempObj = new JSONObject();
    for (String key : jsonBody.keySet()) {
        String value = jsonBody.get(key).toString();
        if (method.contains(":" + key)) {
            method = method.replace(":" + key, value);
        } else {
            tempObj.put(key, jsonBody.get(key));
        }
    }

    try {
        String url = Constants.SUFFIX.replace("${host}", driver.getHost()).replace("${port}", driver.getPort()) + method;
        httppost = new HttpPost(url);
        if (jsonBody != null) {
            stringEntity = new StringEntity(tempObj.toString(), "utf-8");
            stringEntity.setContentEncoding("utf-8");
            stringEntity.setContentType("application/json");
            httppost.setEntity(stringEntity);
        }
        response = httpclient.execute(httppost);
        entity = response.getEntity();
        System.out.println(response.getStatusLine().getStatusCode());
        if (entity != null) {
            stringResponse = EntityUtils.toString(entity);
            System.out.println("Response content:" + stringResponse);
            jsonResponse = JSON.parseObject(stringResponse);
            handleStatus(jsonResponse.getInteger("status"));
            return jsonResponse;
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册