Author Topic: Logging to Text File  (Read 673 times)

Is it possible for a plugin to log to it's own text log file?

I'm not sure what you really want to do, but you can maybe define your own log helpers to write inside a file.
I know that you can use a XMLHttpRequest to read or write a text file ('GET' method to read and 'PUT' method to write)
Something like:
Code: [Select]
    var read_request = new XMLHttpRequest();
    read_request.open("GET", file_path, false);
    read_request.send(null);
    // read_request.responseText should contain your file text
and
Code: [Select]
    var write_request = new XMLHttpRequest();
    write_request.open("PUT", file_path, false);
    write_request.send(your_log);

Is there anything that would cause this method to work in one plugin, and not another?

I'm parsing json files just fine with this method in one plugin.. and while developing another plugin, I can't get the exact same code to work. Even with the exact same json file. The XmlHttpResponse.responseText always returns a string with a length of 0 in the 2nd plugin, which of course throws a Json Parse error.