Archive: DumpLog produces empty file


DumpLog produces empty file
I have tried calling the DumpLog function (provided in the manual) from inside of all of my already exising sections as well as creating a new hidden section and calling it from there like this:
Section "-a hidden section"
Push "file.log"
Call DumpLog
SectionEnd

No matter what I do it always produces an empty log file. What am I doing wrong or missing?


Are you sure it creates the file you're looking at? Try specifying a full path so you'll be sure which file it updates.


I tried several different paths as well as several different names. It does produce file in the location I tell it to but the file is always empty.


Is that section the first section? Is your installer running in silent mode? Can you attach a complete example? It's a guessing game without a complete example.


Sorry about that. Sample is attached.


You're calling DumpLog on your second section. Nothing is printed to log at that point. Call it on the last section when everything is already printed to the log.


Ok, that worked - thanks.

2 related questions:
- I'd like to write other information either to that log or to the log window like the date and time of install. Is there an quick way to make that happen?
- I'd also like to capture the uninstall information to that file. Is there an easy way to do that?


Open this file as it's opened in the function and add whatever information you want into it (using FileOpen, FileWrite and FileClose).

This function might help:
http://nsis.sourceforge.net/wiki/Sim...e_text_to_file

To dump the uninstaller log, simply call that function for the uninstaller as well. Make sure you change the file open mode from "w" to "a" so it appends instead of replacing.


I have it writing the log to a file. And I am able to append information to the end of the file using the WriteToFile function. I switched the write mode to "a" in the DumpLog function in hopes of appending to the file. It appears that what its doing is writing to the same place in the file leaving everything below what it wrote intact. So if the file says this:

log start
line2
line3
line4
log stop
my extra text

After I uninstall then install again, it then says this:

log start
line2
line3
line4
log stop
my extra text
my extra text

So it doesn't appear to be apending, it appears to be putting a pointer at the beginning of the file, writing the log out and if there is anything left if the file after the pointer (which is at the end of the log output) that stays. Is there a way to make the file look like this:

log start
line2
line3
line4
log stop
my extra text
<2nd install>
log start
line2
line3
line4
log stop
my extra text


You should also seek to the end of the file after opening it in append mode. Use:

FileSeek $0 0 END
Where $0 should be the open file handle, of course.

Ok so I have everything working but the uninstaller portion. In the past, I have just named all functions that I'm using in the uninstaller by un.<function name>. However in this case I have a function that needs to be used elsewhere. Is there a way to refer to the same function in both uninstall and non-uninstall sections (without simply copying the function and renaming it)?


Put the function's code inside a macro and then insert that macro into two functions, one for the installer and one for the uninstaller.

!macro funccode UN
Function ${UN}func
# ... some code...
FunctionEnd
!macroend

!insertmacro funccode ""
!insertmacro funccode "un."

Ok, got that working. Note that I had to remove Function and EndFunction from within the macro to make it work. So using your example it worked when I made it look like this:


!macro funccode UN
# ... some code...
!macroend

!insertmacro funccode ""
!insertmacro funccode "un."


Neat idea by the way.

Now my problem is, I call the GetTime Macro in order to write the time to the uninstall log file. This works fine in the installer, but it coughs in the uninstaller because it contains stuff that doesn't start with "un.". I tried the same trick as above but didn't work. Any ideas?

!macro IncludeGetTime UN
Function ${UN}GetTime
...
FunctionEnd
!macroend

!insertmacro IncludeGetTime ""
!insertmacro IncludeGetTime "un."

!macro GetTime ...
Call GetTime
Pop ...
!macroend

!macro un.GetTime ...
Call un.GetTime
Pop ...
!macroend

-Stu


Actually, I found un.GetTime and called it instead.

Thanks (again) guys for the help. I've got it all working how I want it now.