I see inside of the TODO Helper extension is this line:
var log = ko.logging.getLogger("ko.extensions.todo");
Where does this log get sent to? Is this inside pystderr.log or elsewhere? And is it possible to redirect it to its own file?
Thanks,
Brandon
var log = ko.logging.getLogger("ko.extensions.todo");
This logging output will go to pystderr.log.
There are no API methods to redirect the logging output, such as to a separate file, you could use your own file/log handler for dumping to a file (this would make a good enhancement request, as the logging handlers are wrappers around the base python logging module, which does have support file redirection).
A simplistic approach to using a file handle itself:
if (!window.gLogFile) {
var filename = "/home/toddw/tmp/file.log";
var fileSvc = Components.classes["@activestate.com/koFileService;1"].getService(Components.interfaces.koIFileService);
var koIFileEx = fileSvc.getFileFromURI(ko.uriparse.localPathToURI(filename));
// Initialize the file.
koIFileEx.open("w");
koIFileEx.close();
gLogFile = koIFileEx;
}
// Open for appending;
gLogFile.open("a");
gLogFile.puts(msg + "\n");
gLogFile.close();
}
log("Hello");
log("world!");
function log(msg) { if (!window.gLogFile) { var filename = "/home/toddw/tmp/file.log"; var fileSvc = Components.classes["@activestate.com/koFileService;1"].getService(Components.interfaces.koIFileService); var koIFileEx = fileSvc.getFileFromURI(ko.uriparse.localPathToURI(filename)); // Initialize the file. koIFileEx.open("w"); koIFileEx.close(); gLogFile = koIFileEx; } // Open for appending; gLogFile.open("a"); gLogFile.puts(msg + "\n"); gLogFile.close(); } log("Hello"); log("world!");Cheers,
Todd
Thanks for the advice & code.
I think the best way to approach logging to your own file would be to create the file either in the extensions dir or the hostUserDataDir where the other log files are. Getting the current hostUserDataDir is easy:
getService(Components.interfaces.koIDirs);
alert(dirs.hostUserDataDir);
I have some ( JS ) code to get the current directory of the extension, it is only slightly more painful, and uses koIDirs anyway:
var base = koDirs.hostUserDataDir;
var arr = [base, 'XRE', 'extensions', ext_name, 'scripts', 'runapplescript.sh'];
var ext_path = os.path.joinlist(arr.length, arr);
I use the code above to help me shell out to scripts located inside the extension directory.
--
JeffG