electron桌面应用打印移动端log(代码已优化)

使用electron桌面应用打印移动端log

  • 对于移动端真机测试来说,想看见log是一件很困扰的事情,所以我写了这个项目来帮助自己
  • 项目中我输出了请求的内容,时间,和它的级别
  • debug (对应level为1)
  • info (对应level为2)
  • warn (对应level为3)
  • error (对应level为4)
  • fatal (对应level为5)

git地址

https://github.com/wujiabao123/desk-logger.git

使用时需要调用相应的函数

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 })
})
}
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。