OpenLog - Feature Request: OpenLogJavaScript comments should be moved to it's own libraryCreated on |
Jun 4, 2009 |
Created by |
John Smart |
Status |
Submitted |
The bottom of OpenLogJavaScript library's comments give an example beforeLogError function.
I wrapped the code within an if statement to not prompt for an ExtraMessage value if one was already set. This allowed me to, when I wanted to simply log something without prompting the user, create my openLogObject, then call
myOpenLogObject.postParamList["ExtraMessage"] = 'submitted automatically'
before calling myOpenLogObject.logError()
Also, I think the code should be moved to it's own JavaScript library, just like the MailLogSubclass, called OpenLogJavaScript.SampleExtension. Example:
/******************************************
This library shows how you can extend the OpenLogJavaScript library.
When logging an error, if a beforeLogError method exists on the openLogObject, that method will be called before the error is sent to the server.
By including this script AFTER the OpenLogJavaScript, every new openLogObject will have a beforeLogError method on it.
******************************************/
if (openLogObject) openLogObject.prototype.beforeLogError = function() {
if (!this.postParamList["ExtraMessage"]) {
// this adds some user-supplied text to the error message we got
var answer = prompt("The error \"" + this.msg + "\" just occurred.\nWhat were you doing?", "");
this.msg += "\n\nAt the time of the error, the user was doing this:\n" + answer;
// and this adds a new POST parameter to the packet that is sent to the
// server, which will in turn create a new field called "ExtraMessage" on
// the OpenLog document that is created
this.postParamList["ExtraMessage"] = answer;
}
}
Taken Actions by OwnersNo actions have been taken yet.