Hi, I have never had any ebase training although I am an experienced programmer helping out on an ebase project, so apologies in advance.
We would like to debug a script but our attempts so far have never returned anything at all (log field1 etc) can anyone tell me the correct syntax/method for debugging a script.
Debugging ebase scripts
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 4
- Joined: Tue Sep 24, 2013 1:22 pm
- Location: Hatley St George
- Contact:
Stuart,
The method of debugging will depend on the type of scripting you are using.
With the FPL scripting you need to use the format:
Whereas with the new javascript you want to use this format:
If you have run the form from the designer then you can view these log messages from View > Execution log, otherwise you'll have to look through the console or the server logs (if you have Ufs.logInfo=true in the UFSSetup.properties file)
The method of debugging will depend on the type of scripting you are using.
With the FPL scripting you need to use the format:
Code: Select all
log 'The value is ' + FIELD_NAME;
Code: Select all
log('The value is ' + fields.FIELD_NAME.value);
0 x
There are 10 type of people in this world; those that understand binary and those that don't.
-
- Ebase User
- Posts: 95
- Joined: Wed Feb 27, 2013 5:16 pm
- dvanhussel
- Ebase User
- Posts: 161
- Joined: Fri Oct 19, 2007 12:45 pm
- Location: Haarlem, the Netherlands
Hi,
What I use for this is a simple logging function. It is in a global script that I add to the 'Shared functions' on the 'Events tab' of the form properties.
Now, in the scripts you want to debug you can use it like this:
The function checks if 'Development' is in the name of the server, this way, you don't have to remove the log entries from your script when you move to production. If you explicitly want to log an error (i.e. in a catch-block) you can do it like this:
These error messagages will be logged in any environment.
De default type if the logtype is not provided is 'error'.
The entries will be loged in a separate file for each form per date, in the provided log folder.
We run ebase on Linux, so a :
in a ssh session gives us 'realtime logging' which is a lot more convenient than having to refresh the execution log in the designer every time.
What I use for this is a simple logging function. It is in a global script that I add to the 'Shared functions' on the 'Events tab' of the form properties.
Code: Select all
const info = 'info';
const error = 'error';
const logPath = 'C:\\ebaseXi\\UfsServer\\generatedfiles\\log\\';
const serverModeIsDevelopment = system.systemName.indexOf('Development')!=-1;
/**
* createFilename()
* @return string fileName
**/
function createFileName(){
// create filename based on formID and currentDate (YYYYMD)
var date = new Date();
var formatedDate= date.getFullYear()+''+(date.getMonth()+1)+date.getDate();
var fileName = logPath+system.variables.$FORMID+'_'+formatedDate+'.log';
return fileName;
}
/**
* logToFile(string, string)
* @param string message, text to write
* @param string type, type of log (info,error)
* Append to existing file or create when file doesnt exist
**/
function logToFile(message,type){
if(typeof(message) =='undefined'){
message = '';
}
if(typeof(type) == 'undefined'){
type='error';
}
var time = new Date().toLocaleTimeString();
var session = '';
if (client.httpSession!=null){
session = client.httpSession.id+ ' '+client.formSession.formSessionId; // http sessionID and unique formsessionID
} else {
session = 'scheduled task';
}
var eventText = event.eventDescription;
if (type=='error' || (serverModeIsDevelopment && type=='info')){
var fileName = createFileName();
try {
fileWriter = new java.io.FileWriter(fileName, true);
fileWriter.write(time+' '+session+' '+eventText+' '+type+': '+message+'\r\n');
fileWriter.close();
} catch (err) {
}
}
}
Code: Select all
logToFile('Field 1: '+fields.FIELD1.value, info);
Code: Select all
logToFile('Field 1: '+fields.FIELD1.value, error);
De default type if the logtype is not provided is 'error'.
The entries will be loged in a separate file for each form per date, in the provided log folder.
We run ebase on Linux, so a :
Code: Select all
tail -f /logpath/logfile.log
0 x
Who is online
Users browsing this forum: No registered users and 28 guests