想法是以静默模式运行 NSIS 脚本到远程机器,一旦安装成功完成,然后将日志文件返回到主机。
我有很多Detailprint
显示脚本进度的命令消息。现在的问题是我如何将这些消息保存到日志文件中。我正在查看这个http://nsis.sourceforge.net/Dump_log_to_file但它说它在静默模式下不起作用。
我使用这种方法来保存日志。我不知道这是否是最好的方法,但对我来说效果很好。
!ifndef DEBUG_MODE
!define DEBUG_MODE true
!endif
!define LOGFILE "$TEMP\my_logfile.log"
!if ${DEBUG_MODE} == true
!define DetailPrint '!insertmacro _debugMsg'
!else
!define DetailPrint '!insertmacro _nodebugMsg'
!endif
!macro _debugMsg MSG
push $3
push $2
push $1
push $0
push $R0
strcpy $R0 "${MSG}"
ClearErrors
FileOpen $1 ${LOGFILE} a
FileSeek $1 0 END
IfErrors +8
${GetTime} "" "L" $0 $0 $0 $0 $0 $2 $3
FileWrite $1 "$0:$2:$3$\t"
FileWrite $1 "${__FUNCTION__}$\t"
FileWrite $1 "$R0"
FileWrite $1 "$\t(${__FILE__},${__FUNCTION__},${__LINE__})"
FileWrite $1 "$\n"
FileClose $1
pop $R0
pop $0
pop $1
pop $2
pop $3
!macroend
!macro _nodebugMsg _MSG
;you can put here nothing or you can put the regular DetailPrint
DetailPrint "${MSG}"
!macroend
Run Code Online (Sandbox Code Playgroud)
之后你只需要找到并用 ${DetailPrint} 替换 DetailPrint
归档时间: |
|
查看次数: |
3696 次 |
最近记录: |