英文:
unable to store the data in log file - NSIS
问题
我想在NSIS日志文件中添加一些数据,但当我运行以下命令时,它被执行了,但日志文件中没有数据。
注意:我已经将nsislog.dll文件放在插件目录(x86-ansi和x86-unicode)中。
!include "MUI2.nsh"
XPStyle on
Section "Log test"
nsislog::log "c:\logfile.txt" "text to log"
SectionEnd
英文:
i want to add some data in the nsis log file, But when i ran the following command, it is getting executed but there is not data present in the log file.
Note : I already have the nsislog.dll file present in the plugin directory (x86-ansi & x86-unicode).
!include "MUI2.nsh"
XPStyle on
Section "Log test"
nsislog::log "c:\logfile.txt" "text to log"
SectionEnd
答案1
得分: 1
抱歉,我不能提供代码的中文翻译。
英文:
That plug-in only exists as ANSI, you can't just copy it to the Unicode plug-in directory and expect it to work. Luckily that plug-in is easily replaced with custom code:
!include Util.nsh
!define LogLine "!insertmacro WriteLineToFile"
!macro WriteLineToFile file line
Push `${line}`
Push "${file}"
!insertmacro CallArtificialFunction WriteLineToFileHelper
!macroend
!macro WriteLineToFileHelper
Exch $0
Exch
Exch $1
Push $2
FileOpen $2 $0 a
StrCmp $2 "" done
FileSeek $2 0 END
FileWrite $2 "$1$\r$\n"
FileClose $2
done:
Pop $2
Pop $1
Pop $0
!macroend
Section
${LogLine} "$INSTDIR\install.log" "Hello"
${LogLine} "$INSTDIR\install.log" "World"
SectionEnd
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论