luup.log output

Is it possible to have a seperate log file to monitor certain steps in the program.
Now you create an luup.log() message in to the log file.
If the file is getting to big it is overwritten by a new one,
so to look for certain step what happend a few ours ago is not possible

Thanks
Rgds
Huib

You’d have to do it manually, with:
lua-users wiki: Io Library Tutorial

@guessed
Could you give some guidance

Do you make the file once and update it with a txt message
Do close it after adding
Where it is stored, or can you direct it to a ceftain location
How to make a time stamp

Pls advise
Rgds
Huib

I would try to keep the file open for as short a period as possible, so [roughly]:

  • format the message
  • open the file for append
  • write the message
  • close

For timestamps, look at [tt]os.time()[/tt] and it’s formatting options.

With help of a frend i am using the following function as log
to log i use

FileLog(“text”) and FileLog(data)
in the first option the message text is logged
in the second case the value of data is logged

function FileLog(Logtext) local filelog = "/etc/cmh/WHR930Comm.log" local outf = io.open(filelog, "a") outf:write(os.date('%Y-%m-%d %H:%M:%S ' .. "Send Command = " .. Logtext)) outf:write("\n") outf:close() end

rgds
Huib

I have further changed the luup.log outputfunction:

In the start up function i have made the following section

		local filelog = "/etc/cmh/AAxxx.log"
		local outf = io.open(filelog, "a")
		outf:write(os.date('%Y-%m-%d %H:%M:%S '.. "Relais: Start Up Completed "))		
		local filesize = outf:seek("end")
		outf:write(filesize)	
		outf:write("\n")		
		outf:close()
		
		if filesize > (25000) then 
			local filelog = "/etc/cmh/AAxxx.log"
			local outf = io.open(filelog, "w+")		
			outf:write(os.date('%Y-%m-%d %H:%M:%S '.. "File Deleted and File renewed: Start Up Completed "))
			outf:write("\n")
			outf:close()
		end

if the file is getting to big it is deleted and a new file is created

further the following function is made

	function FileLog(Logtext)
		local filelog = "/etc/cmh/AAxxx.log"
		local outf = io.open(filelog, "a")
		outf:write(os.date('%Y-%m-%d %H:%M:%S ' .. "Started = " .. Logtext .. "  " ))
		local filesize = outf:seek("end")
		outf:write(filesize)	
		outf:write("\n")
		outf:close()
	end

further in the requested function the following instruction is entered

FileLog("tekst")

with this i can log the different steps as i want over a longer periode without being removed by the system

during the reboot it does not disapear

rgds
Huib