问题
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