X-ChromeLogger-Data

788 阅读1分钟

需要在代码内内置chrome-logger类库,下面是链接 craig.is/writing/chr…

chrome console效果图:

chrome console需要 logger插件 chrome.google.com/webstore/de…

postman console效果图

postman在运行的时候需要先在tests运行以下代码

#####postman上面运行的代码##############

var chromelogger = pm.response.headers.get('X-ChromeLogger-Data')

if(chromelogger){
chromelogger = JSON.parse(atob(chromelogger));
if(chromelogger){

    // Native objects - well structured, but you have to expand all the rows every time... tedious!
    //console.log(chromelogger); 

    // Raw JSON - always visible but can be hard to read
    // console.log(atob(postman.getResponseHeader("X-ChromeLogger-Data"))); 

    // For known structures, you can display it yourself
    chromelogger.rows.forEach( row => {
        console.log(row[1]); // display source line
        row[0].forEach(log => {
            console.log(log);
        })
    })
}
}