How to implement logging functionality in a chrome extension

倾然丶 夕夏残阳落幕 提交于 2020-01-03 17:09:37

问题


I'm working on an extension and have a need for logging -- not as in console-based logging, but in the traditional sense of a logfile (the extension monitors for certain events and logs them to the filesystem).

First, I tried the filesystem API calls. In general this seems to be the right API, but the issue is that I need to provide the OS-level path to the generated log file to the user of my extension, and I can't see a way to do that. I can find the physical sandboxed file (in ~/Library/Application Support/Google/Chrome/Default/File System/003/p/00/00000000), but I'm not sure how to get that value programatically (nor if I should).

I also tried the FileSaver.js implementation by Eli Grey (using Blob and saveAs()). This does let me save a file to the filesystem (and specify the filename), but it requires writing the entire file every time, obviously not a good idea for a log file.

Is there a better way to accomplish what I'm asking? I know there is the other answer of NPAPI, but I don't have the skills nor the build infrastructure to use it.

Thanks!

来源:https://stackoverflow.com/questions/12134696/how-to-implement-logging-functionality-in-a-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!