【发布时间】:2019-04-05 00:17:20
【问题描述】:
我有一个电子应用程序,它使用electron-log 来处理为应用程序创建一些调试信息。默认情况下,它会将文件保存到每个模块的以下位置:
**on macOS:** ~/Library/Logs/<app name>/log.log
**on Windows:** %USERPROFILE%\AppData\Roaming\<app name>\log.log
我在菜单中添加了“查看调试信息”选项。我的目标是将此日志读入文本区域(在渲染器上),以便他们可以在需要时提供支持。
在我的渲染器中,我使用fs 来访问文件系统,但我在process.env 中找不到指向这些位置的任何内容,所以我认为它们是自定义的?
我是否缺少包含操作系统上这些路径的变量?
const fs = require('fs');
if(process.platform == 'darwin'){
// Path is ~/Library/Logs/<app name>/log.log
// Read the file into the textarea
}else{
// Path is %USERPROFILE%\AppData\Roaming\<app name>\log.log
// Read the file into the textarea
}
【问题讨论】: