Announcement

Collapse
No announcement yet.

NSIS error description

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.


    Comment


    • #3
      I created a macro for realtime logging... I am not sure if the others would call it clean but I tend to love it..

      PHP Code:
      !include LOGICLIB.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" 
      ${INSTLOG} is just my path to the log file so just set that to whatever,

      this is a sample output:

      PHP Code:
      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 type080041002
      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 Code1603
      11.10.2012 16
      :06:26    Installation Error1603
      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...

      Comment


      • #4
        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

        Comment


        • #5
          Can i get any example of using these dumping log to a file in .onInstFailed / .onInstSucces / some other callback function?

          Comment


          • #6
            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'.)

            Comment


            • #7
              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.

              Comment


              • #8
                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.

                Comment


                • #9
                  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?

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      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?
                      Last edited by winman2004; 17 October 2012, 09:16.

                      Comment


                      • #12
                        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.

                        Comment


                        • #13
                          What about using special builds?What does it do exactly?Can i get errors and its description by using it?

                          Comment


                          • #14
                            No clue. Try the logging build.

                            Comment


                            • #15
                              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?

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎