Debugging ebase scripts

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

StuartF
Ebase User
Posts: 14
Joined: Thu Sep 26, 2013 11:35 am

Debugging ebase scripts

#1

Postby StuartF » Fri Oct 18, 2013 9:02 am

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.
0 x

Mark
Ebase User
Posts: 4
Joined: Tue Sep 24, 2013 1:22 pm
Location: Hatley St George
Contact:

#2

Postby Mark » Fri Oct 18, 2013 11:16 am

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:

Code: Select all

log 'The value is ' + FIELD_NAME;
Whereas with the new javascript you want to use this format:

Code: Select all

log('The value is ' + fields.FIELD_NAME.value);
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)
0 x
There are 10 type of people in this world; those that understand binary and those that don't.

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

#3

Postby alexmcclune » Fri Oct 18, 2013 12:51 pm

Hi,

Our server is running Tomcat as a service but unfortunately our execution log doesn't display anything - even when using log();

Edit - this is because I am using a second browser...apologies.
0 x

User avatar
dvanhussel
Ebase User
Posts: 161
Joined: Fri Oct 19, 2007 12:45 pm
Location: Haarlem, the Netherlands

#4

Postby dvanhussel » Sat Oct 19, 2013 4:32 pm

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.

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) {
			
		}
		
	}
}
Now, in the scripts you want to debug you can use it like this:

Code: Select all

logToFile('Field 1: '+fields.FIELD1.value, info);
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:

Code: Select all

logToFile('Field 1: '+fields.FIELD1.value, error);
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 :

Code: Select all

tail -f /logpath/logfile.log
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.
0 x


Who is online

Users browsing this forum: Google [Bot] and 7 guests