无法将数据存储在日志文件中 – NSIS

huangapple go评论51阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年7月31日 22:40:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804685.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定