- NSIS Discussion
- NSIS error description
Archive: NSIS error description
winman2004
13th October 2012 12:08 UTC
NSIS error description
I am using NSIS for my application. I want to track the errors which are occurred during the installation of my application and i want it it write to a log(a error log) so that i can know the errors occurred during installation in my customers place. How can i do it in NSIS.. Please reply me soon
Thank u
MSG
13th October 2012 15:25 UTC
Use the detailprint command to print debug information to the installation log. Then dump the log to a file in .onInstFailed / .onInstSucces / some other callback function.
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.14.3
http://nsis.sourceforge.net/Dump_log_to_file
Squirre1
15th October 2012 07:20 UTC
I created a macro for realtime logging... I am not sure if the others would call it clean but I tend to love it..
nsh
>var NOW
>!macro logme logpath logtext output
${If} ${output} == 's'
SetDetailsPrint both
DetailPrint "${logtext}"
SetDetailsPrint none
${ElseIf} ${output} == 'l'
${time::GetLocalTime} $NOW
nsislog
::log "${logpath}" "$NOW$\t${logtext}"
${ElseIf} ${output} == 'b'
${time::GetLocalTime} $NOW
nsislog::log "${logpath}" "$NOW$\t${logtext}"
SetDetailsPrint both
DetailPrint "${logtext}"
SetDetailsPrint none
${EndIf}
!macroend
!insertmacro logme ${INSTLOG} "This will log to the log file only" l
!insertmacro logme ${INSTLOG} "This will log to the screen only" s
!insertmacro logme ${INSTLOG} "This will log to both the screen and the log file" l
>
${INSTLOG} is just my path to the log file so just set that to whatever,
this is a sample output:
11.10.2012 16:06:05 *-----------------------------------------------------*
>11.10.2012 16:06:05 ### Cisco AnyConnect Secure Mobility Client 3.1.00495 Installation Starting
>11.10.2012 16:06:05 ### Build Verison: 1.0.0.1
>11.10.2012 16:06:05 ### Runtime: 10/11/2012 16:6:5
>11.10.2012 16:06:05 ### Switches: {none}
>11.10.2012 16:06:05 *-----------------------------------------------------*
>11.10.2012 16:06:05 Running Pre-installation Processes ... Please be Patient
11.10.2012 16
:06:05 Attempting to detect chassis type ... Please be Patient
11.10.2012 16:06:05 - Processing detected chassis type: 080041002
11.10.2012 16:06:05 - Processing detected chassis type:
>11.10.2012 16:06:05 - Processing detected chassis type:
>11.10.2012 16:06:23 Pre-installation Processes Complete
11.10.2012 16:06:23 Extracting Files for Installation ... Please be Patient
11.10.2012 16:06:24 Installing Cisco AnyConnect Secure Mobility Client 3.1.00495 Core Components ... Please be Patient
11.10.2012 16:06:25 Installing Cisco AnyConnect Secure Mobility Client 3.1.00495 NAM Components ... Please be Patient
11.10.2012 16:06:26 - Installer Returned Code: 1603
11.10.2012 16:06:26 - Installation Error: 1603
11.10.2012 16:06:30 Cleaning Up Temporary Files ... Please be Patient
11.10.2012 16:06:30 *** Cisco AnyConnect Secure Mobility Client 3.1.00495 Installation Ended in Error ***
>11.10.2012 16:06:30 *-----------------------------------------------------*
>11.10.2012 16:06:30 *-----------------------------------------------------*
>11.10.2012 16:06:30
>
As you can tell, I use mine when wrapping applications, but an installer would be good just the same... I believe logiclib is all you need if I remember right...
Afrow UK
15th October 2012 10:15 UTC
You should use compile-time !if rather than a run-time ${If}. At the moment it is compiling the whole macro on compile when only a single branch of it needs to be compiled.
Stu
winman2004
15th October 2012 10:33 UTC
Can i get any example of using these dumping log to a file in .onInstFailed / .onInstSucces / some other callback function?
MSG
15th October 2012 11:01 UTC
You can get info on the callback functions here: http://nsis.sourceforge.net/Docs/Chapter4.html#4.7.2
You can find a logdumper example on the 'dump to log file' page I linked. (Pro tip: Read the 'how to use'.)
winman2004
16th October 2012 10:46 UTC
Thank u all for your replies. Does dumb log to a file(http://nsis.sourceforge.net/Dump_log_to_file) gives only installation log(files copied during install) or errors occurred in installation also?
I want to get error found during installation.
MSG
16th October 2012 14:10 UTC
It simply saves whatever is in the installation details window. Like I said, you'll need to use the detailprint command to put extra details / error information in there.
winman2004
17th October 2012 06:00 UTC
Thank u MSG..Is there any method i can get error description for the error occurred.(For example during re install the some file is kept open in the installed path etc..).Can i get the error description and do error handling for that?
MSG
17th October 2012 08:56 UTC
You'll have to do your own error handling. Use ${If} ${Errors} a lot, and add extra commands where necessary to get more info. Also make sure to detailprint return codes if you use external applications / win32 api commands.
winman2004
17th October 2012 09:02 UTC
Don't i get any error description from NSIS itself? For example a copying file can fail because of so many reasons.So how i can know what exactly the error is?Is there any error description? What about error flag? Does it set to different value for different error?
MSG
17th October 2012 10:28 UTC
No, CopyFiles does not give specific error information. Both canceling and errors set the errorflag. If you want more specifics, you'll have to call the appropriate copying command directly through win32 API, using the system plugin.
winman2004
17th October 2012 11:47 UTC
What about using special builds?What does it do exactly?Can i get errors and its description by using it?
MSG
17th October 2012 15:22 UTC
No clue. Try the logging build.
winman2004
18th October 2012 09:01 UTC
thank u for your replies.I think i can't get error description from NSIS itself. But can i get in which line or where the error has occurred.Using iferrors in every case will make the coding more lengthy and difficult so i want to make it easy.So can i get errors occurred during error with line number or something else?
winman2004
18th October 2012 13:05 UTC
hey MSG you have also told to use Windows API,using system plugin to track errors.in this forum http://forums.winamp.com/showthread....hreadid=283735 it is mentioned to use System::Call kernel32::WriteFile(...)?e. But can u tell what are the parameters to be passed to Writefile() function?Does kernel32::WriteFile(...)?e will write errors to a file?
MSG
18th October 2012 17:49 UTC
No, no it will not. Kichik merely said that appending ?e to a function call through the system plugin will make it put the function's return code on the stack after calling.
winman2004
19th October 2012 05:57 UTC
thank u MSG..Do you have any example script where system plugin and writefile is used?Because it will help me more to understand it.
MSG
19th October 2012 12:32 UTC
Not myself. But if you google for 'nsis system:call writefile' you'll find some examples.
MSG
19th October 2012 13:13 UTC
But... Why would you want to use WriteFile? I thought you wanted to copy files?
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx