PrettyStackTrace允许Swift命令行程序在引发终止信号时打印执行行为踪迹

网友投稿 729 2022-11-01

PrettyStackTrace允许Swift命令行程序在引发终止信号时打印执行行为踪迹

PrettyStackTrace允许Swift命令行程序在引发终止信号时打印执行行为踪迹

PrettyStackTrace

PrettyStackTrace allows Swift command-line programs to print a trace of execution behaviors when a terminating signal is raised, such as a fatal error.

To use it, wrap your actions in a call to trace(_:). This will register an entry in the stack trace and (if your process fatal errors) will print breadcrumbs to stderr describing what was going on when you crashed.

Installation

PrettyStackTrace is available from the Swift package manager. Add

.package(url: "https://github.com/llvm-swift/PrettyStackTrace.git", from: "0.0.1")

to your Package.swift file to use it.

Example

trace("doing first task") { print("I'm doing the first task!") trace("doing second task") { print("I'm doing the second task!") fatalError("error on second task!") }}

This will output:

I'm doing the first task!I'm doing the second task!Fatal error: error on second taskStack dump:-> While doing second task (func main(), in file file.swift, on line 3)-> While doing first task (func main(), in file file.swift, on line 1)

Authors

Harlan Haskins (@harlanhaskins)

Robert Widmann (@CodaFi)

License

PrettyStackTrace is released under the MIT license, a copy of which is available in this repository.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:PATDroid - 用于分析Android应用程序和系统本身的工具和数据结构集合
下一篇:django-simple-task在Django 3中运行后台任务,而无需其他服务和工作程序
相关文章

 发表评论

暂时没有评论,来抢沙发吧~