使用electron桌面應(yīng)用打印移動(dòng)端log
- 對(duì)于移動(dòng)端真機(jī)測(cè)試來(lái)說(shuō)糯彬,想看見(jiàn)log是一件很困擾的事情凭语,所以我寫了這個(gè)項(xiàng)目來(lái)幫助自己
- 項(xiàng)目中我輸出了請(qǐng)求的內(nèi)容,時(shí)間撩扒,和它的級(jí)別
- debug (對(duì)應(yīng)level為1)
- info (對(duì)應(yīng)level為2)
- warn (對(duì)應(yīng)level為3)
- error (對(duì)應(yīng)level為4)
- fatal (對(duì)應(yīng)level為5)
git地址
https://github.com/wujiabao123/desk-logger.git
使用時(shí)需要調(diào)用相應(yīng)的函數(shù)
export default testElectron = {
debug: function (data, date) {
fetch('http://localhost:3000/log', {
credentials: 'include',
mode: 'no-cors',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({ "level": 1, date, message: data })
})
},
info: function (data, date) {
fetch('http://localhost:3000/log', {
credentials: 'include',
mode: 'no-cors',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({ "level": 2, date, message: data })
})
},
warn: function (data, date) {
fetch('http://localhost:3000/log', {
credentials: 'include',
mode: 'no-cors',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({ "level": 3, date, message: data })
})
},
error: function (data, date) {
fetch('http://localhost:3000/log', {
credentials: 'include',
mode: 'no-cors',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({ "level": 4, date, message: data })
})
},
fatal: function (data, date) {
fetch('http://localhost:3000/log', {
credentials: 'include',
mode: 'no-cors',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({ "level": 5, date, message: data })
})
}
}