Swiftpack.co - grigorye/GETracing as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by grigorye.
grigorye/GETracing 0.1.2
Seamless tracing for Swift.
⭐️ 1
🕓 2 weeks ago
.package(url: "https://github.com/grigorye/GETracing.git", from: "0.1.2")

Actions Status

GETracing

Easily trace value and literal of a Swift expression right at the point of evaluation.

If the built-in dump could capture the literal of the expression that produces the value on the caller side*, this whole thing would likely not exist.

Why

  • Avoid repeating yourself.
  • Avoid introducing variables just to keep a value of expression (otherwise re-evaluated) for logging. Evaluate just once, whether there's tracing or not.
  • Get the expression literals traced in addition to the values.
  • Keep the code changes to the minimum. Make tracing (and reverting from tracing) as seamless as possible.

What

Any Swift expression

expr

that needs tracing is replaced with

x$(expr)

and that's it. Nested expressions might be traced as well.

Configration

x$ alternative might be defined as necessary by the client.

Logging implementation should be defined by the client.

Reverting

Tracing might be reverted by removal of x$() or even removal of x$, leaving () in place.

Alternatively, tracing might be disabled per-block.

Current Limitations

It's required to bundle the corresponding source files together with the modules, if you want to see the expression literals for the traced stuff, as they're looked up at runtime. It might be improved later. For now, for performance reasons, it's possible to disable the lookup completely. (Theoretically) it's possible to recover the literals given the traced output with lookups disabled.

Related Projects

Tuna Xcode Plugin

--

* Long live #__VA_ARGS___ and C-preprocessor!

GitHub

link
Stars: 1
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

3 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics