Define Class log_mesaje As Relation

	cLogFile = "c:\log.txt"
	lLogging = .F.

	&& ------------------------------INCEPUT: Init ------------------------------ 
	*!* Procedura:  Init
	*!* Parametri: 
	*!* Data/Ora generarii: 20/02/2004 12:41:53
	*!* Autor: MARIUS.MUTU
	Procedure  Init
		Lparameters tcLogFile, tlAdditive

		Local lLog, llAdditive, cLogFile
		lLog = Iif(File(Addbs(Justpath(Sys(16, 0))) + "LOG.txt"), .T., .F.) && daca exista fisierul log
		This.lLogging = lLog Or This.lLogging && creez log daca exista in directorul aplicatiei fisierul <log.txt> sau daca proprietatea lLogging =  .T.

		If !This.lLogging
			Return
		Endif

		Set Console Off
		Set Talk Off

		cLogFile = Iif(Empty(tcLogFile), Addbs(Justpath(Sys(16, 0))) + "LOG.txt", m.tcLogFile)
		This.cLogFile = cLogFile

		If Parameters() < 2
			llAdditive = Iif(File(cLogFile), .T., .F.)
		Else
			llAdditive = tlAdditive
		Endif

		If llAdditive
			Set Textmerge On To (cLogFile) Additive
		Else
			Set Textmerge On To (cLogFile)
		Endif


		\<<Datetime()>> <<Sys(0)>> <<Iif(Type('GCS')='C',GCS,'')>>

		Set Textmerge To



	Endproc
	&& ------------------------------SFARSIT: Init ------------------------------ 

	&& ------------------------------INCEPUT: Log ------------------------------ 
	*!* Procedura:  Log
	*!* Parametri: tcText
	*!* Data/Ora generarii: 20/02/2004 12:48:57
	*!* Autor: MARIUS.MUTU
	Procedure  Log
		Lparameters tcText, tcProgram

		If !This.lLogging
			Return
		Endif

		Local lcText, lcLogFile

		Set Console Off
		Set Talk Off

		lcText = Iif(Empty(tcText), "", Alltrim(tcText))
		lcProgram = Iif(Empty(tcProgram), "", Alltrim(tcProgram))
		lcSpatiu = Space(10)

		lcLogFile = This.cLogFile
		lcAddText = Ttoc(Datetime()) + " " + Sys(0) + Iif(Type('GCS') = 'C', " " + GCS, "") + Chr(13) + Chr(10) + ;
			Iif(!Empty(lcProgram), lcSpatiu + lcProgram, "") + Iif(!Empty(lcText), lcSpatiu + lcText, "")

		Set Textmerge On To (lcLogFile) Additive

\ <<lcAddText>>

		Set Textmerge To

	Endproc
	&& ------------------------------SFARSIT: Log ------------------------------ 

Enddefine &&  log_mesaje