【问题标题】:Is there a way to log everything from console.log in an Electron app using electon-log?有没有办法使用电子日志在电子应用程序中记录来自 console.log 的所有内容?
【发布时间】:2018-01-27 22:48:47
【问题描述】:

我的 Electron 应用程序的主进程中已经有大量的 console.log 语句,有没有办法将所有这些语句发送到 electron-log 或其他可以在应用程序打包后访问的日志?我打算通过脚本添加log.error,但希望有更好的方法。

console.log('this error', error)
log.error('this error:', error)

【问题讨论】:

    标签: node.js electron


    【解决方案1】:

    类似:

    console.log = function(){
       ...your code...
    };
    

    可以是一个想法吗?

    【讨论】:

    • 好吧,我笨,想多了,谢谢。我想我会为该函数使用不同的名称,只需将所有 console.log 替换为一个日志函数即可,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-04-24
    • 2021-01-01
    • 1970-01-01
    • 2018-02-10
    • 2018-06-08
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    相关资源
    最近更新 更多