Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debug statements in OScript

Status
Not open for further replies.

madhuusa

IS-IT--Management
Oct 5, 2006
93
US
Hi All,
I got a module from a vendor (who is no longer in business) and i need to debug it.

I can setup break points and debug it.

But I am wondering whether there is any way in which I can debug using System.out.println kind of statement in OScript so that it writes to a output file.

I tried using Echo but it comes only in debug window and not in any log file. My debug level is 2 and wantLogs and wantVerbose mode are true.

Madhu
 
just create a simple function to output to a log file .In oscript there is not a logger that is supplied by OT.All of us creates simple functions for it.In my ospace I create a utils object and then I create the function and promote it to global.
That way I can call it form ll my objects.
An example
Code:
function LogWrite(String path, \
	String	mesg	 )


    String logpath = $Kernel.SystemPreferences.GetPrefGeneral( 'Logpath' )
	String logFileName=logpath+'alitekcustom\'+Date.DateToString( Date.Now(), "%m%d%Y%H%M" )+'_eventscript.log'
	String	msg = Str.ValueToString( Date.Now() ) + " - " + mesg
	
	if length(path) == 0
	path=logFileName
	else
	logFileName=logpath+'camali\'+path+'_eventscript.log'
	end
	
	if !File.Exists( path)
		 File.Create( path )
	end
	
	
	File f = File.Open( logFileName, File.AppendMode )
	
	if ( f )
		File.Write( f, msg )
		File.Close( f )
	else
		echo( "Error opening file: ", f )
	end
	
end


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer and probably certfiable,Livelink ECM Champion 2008

 
Awesome AppNair. Thanks for the snippet. Works like charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top