#INCLUDE COMUN.H

Define Class logBaseController As Session
	cLog = ''
	cOutputFile = ''
	lAdditive = .T.

	********************************************************************
	Procedure Init
		Lparameters tcOutputfile, tlAdditive

		If !Empty(tcOutputfile) And Type('tcOutputFile') = 'C'
			This.cOutputFile = tcOutputfile
		Endif
		If Pcount() = 2 And Type('tlAdditive') = 'L'
			This.lAdditive = tlAdditive
		Endif

		This.Log()
	Endproc
	********************************************************************
	Procedure Log
		Lparameters tcMessage, tcProgram
		Local lcLog
		If Pcount() = 0 Or Type('tcMessage') # 'C' Or Empty(tcMessage)
			lcLog = CRLF
		Else
			lcLog = Ttoc(Datetime()) + ' ' + Sys(0) + CRLF + tcMessage + CRLF
		Endi
		This.cLog = This.cLog + lcLog
		This.WRITELOG()
	Endproc
	********************************************************************
	Procedure ResetLog
		This.cLog = ''
	Endproc
	********************************************************************
	Procedure WRITELOG
		Lparameters tcMessage, tcOutputfile, tlAdditive
		Local lcOutputfile, llAdditive, lcLog
		If !Empty(tcOutputfile) And Type('tcOutputFile') = 'C'
			lcOutputfile = tcOutputfile
		Else
			lcOutputfile = This.cOutputFile
		Endif
		If Pcount() < 3 Or Type('tlAdditive') # 'L'
			llAdditive = This.lAdditive
		Else
			llAdditive = tlAdditive
		Endif
		If Type('tcMessage') = 'C'
			If Empty(tcMessage)
				lcLog = CRLF
			Else
				lcLog = Ttoc(Datetime()) + ' ' + Sys(0) + CRLF + tcMessage + CRLF
			Endif
		Else
			lcLog = This.cLog
		Endif
		If !Empty(lcOutputfile)
			Strtofile(lcLog, lcOutputfile, llAdditive)
		Endif
	Endproc
	********************************************************************
Enddefine
*
