Skip to content

Decorators

pedros ships four ready-to-use decorators, all built on wrapt so they preserve signatures and work transparently on sync and async functions, used bare (@timed) or configured (@timed(...)):

  • @timed: logs how long a function took to run
  • @safe: wraps a function in a try/except, with logging, callbacks, and optional re-raising
  • @trace: logs a function's arguments, return value, or raised exception, without ever suppressing the exception
  • @monitor: combines all three above with their defaults, no configuration of its own

Writing your own decorator with the same sync/async-safe shape? See the universal decorator template — it's the annotated skeleton @timed, @safe, and @trace are all built from. It's not part of the public API, so it's linked here rather than in the main nav.