Skip to main content
Use the @trail decorator to audit any function in your codebase — not just framework calls.

Setup

When process_payment is called, ProvenLog automatically logs:
  • action_type — always CUSTOM
  • action_name — the name you provide (defaults to the function name)
  • action_input — the function arguments
  • action_output — the return value (wrapped as {"return": ...})
  • action_statussuccess or error (based on whether the function raises)
  • duration_ms — how long the function took

Parameters

Error handling

If the decorated function raises an exception, ProvenLog logs the event with:
  • action_status set to "error"
  • error_message set to the exception string
The exception is then re-raised — ProvenLog never swallows errors.

Async support

The decorator works with both sync and async functions:

Prerequisites

The @trail decorator requires a ProvenLogClient to be active. When using auto-instrumentation (plog run or import provenlog.auto), a client is created automatically and registered as the default. For explicit setup, create a client before calling any decorated functions:
You can also pass a client explicitly: