TCL::来自另一个进程的进程名称
为了打造更强大的tcl计划,我想在tcl中详细说明proc名称。我在stackoverflow中讨论了一些问题,其中谈到了同样的问题,并据此构建了以下内容:TCL::来自另一个进程的进程名称,tcl,Tcl,为了打造更强大的tcl计划,我想在tcl中详细说明proc名称。我在stackoverflow中讨论了一些问题,其中谈到了同样的问题,并据此构建了以下内容: proc logInfo { {type DEBUG} {msg "This is a debug statement"} } { set timeStampLog [clock format [clock seconds] -format "%m/%d/%y::%H:%M:%S"] puts "${timeStampLog}::'[l
proc logInfo { {type DEBUG} {msg "This is a debug statement"} } {
set timeStampLog [clock format [clock seconds] -format "%m/%d/%y::%H:%M:%S"]
puts "${timeStampLog}::'[lindex [info level [info level]] 0]'::$type - $msg"
}
proc test { } {
logInfo Warning "This is a test proc only"
}
我希望proc在调用时显示以下内容-
tclsh> test
08/05/15::09:41:48::'test'::Warning - This is a test proc only
tclsh>
这就是我看到的-
tclsh> test
08/05/15::09:41:48::'logInfo'::Warning - This is a test proc only
tclsh>
有没有办法指向当前进程名
谢谢“当前”有时是一个棘手的概念,因为当您运行
logInfo
时,它实际上是当前的过程。您需要当前过程的调用者;使用info level[info level]
,而不是info level-1
(正数从堆栈底部开始计数,零和负数从堆栈的深端开始计数)
这实际上简化了代码
proc logInfo { {type DEBUG} {msg "This is a debug statement"} } {
set timeStampLog [clock format [clock seconds] -format "%m/%d/%y::%H:%M:%S"]
puts "${timeStampLog}::'[lindex [info level -1] 0]'::$type - $msg"
}
“当前”有时是一个棘手的概念,因为当您运行
logInfo
时,它实际上是当前过程。您需要当前过程的调用者;使用info level[info level]
,而不是info level-1
(正数从堆栈底部开始计数,零和负数从堆栈的深端开始计数)
这实际上简化了代码
proc logInfo { {type DEBUG} {msg "This is a debug statement"} } {
set timeStampLog [clock format [clock seconds] -format "%m/%d/%y::%H:%M:%S"]
puts "${timeStampLog}::'[lindex [info level -1] 0]'::$type - $msg"
}
非常感谢@Donal一如既往的详细解释。感谢您在支持tcl社区方面的帮助。我以同样的方式更新了我的程序。帮助我更详细地调试和理解问题。非常感谢@Donal一如既往地提供详细解释。感谢您在支持tcl社区方面的帮助。我以同样的方式更新了我的程序。帮助我调试并更详细地理解问题。