Archive: Simple Text File Logging Macro


Simple Text File Logging Macro
I just made my first contribution to the Wiki: a Simple Text File Logging Macro.

It also provides an example which shows the order in which sections and functions are executed by NSIS.

Since I'm really a newbie to NSIS, will you NSIS gurus take a second to look at my contribution and make any comments and/or suggestions so that I can improve the quality of my NSIS code and any potential future contributions to the wiki? Thanks in advance.


Seems fine, thanks for the contribution.

There are, however, a couple of problems. First of all, there's no need to put the page in those three categories. Logging Functions is a subcategory of Functions & Macros and Code Examples doesn't really fit as the example is just an example for the function.

Beside that, there's a little bug in the code. LOG_SET_FILE_NAME resets $__TextLogState, if the log is already open. I have added the following text to the documentation. It should explain the problem.

Note that macro insertion is not considered as one instruction when it comes to relative jumps. The macro is expanded before relative jumps are applied, and so relative jumps can jump into code inside an inserted macro. The following code, for example, will not skip the macro. It will show a message box.
!macro relative_jump_test
MessageBox MB_OK "first macro line"
MessageBox MB_OK "second macro line"
!macroend

Goto +2
!insertmacro relative_jump_test

Beside that, there's a little bug in the code. LOG_SET_FILE_NAME resets $__TextLogState, if the log is already open. I have added the following text to the documentation. It should explain the problem.
Thanks. And wow, I never would have thought of that, but now that you've explained it the problem is totally obvious.

I've rearchitected the include using what I've learned about NSIS and other's add-ons over the past several days, and the link is here: Logging: Simple Text File Logging Functions and Macros.

If you have time and don't mind, I would appreciate it you could eyeball this version too, for styles as well as for substance. I have other things I might be able to contribute, but I'd like to make sure I contribute things that are consistent with the coding-style representative of the NSIS community.

Nice,

I would however chance the Wiki example

Function .onInit
${LogSetFileName} "$INSTDIR\MyInstallLog.txt"

to write the file to the users temp directory since the log does not really belong to the installed program.

But hey, I'm a nitpicker ;)


A couple more: