Browse Source

allow sysaudit.subscribe as a decorator

pull/1/head
Brett Langdon 5 years ago
parent
commit
2a85707a42
Signed by: brettlangdon GPG Key ID: A70042D88B95AA2B
1 changed files with 13 additions and 1 deletions
  1. +13
    -1
      sysaudit/__init__.py

+ 13
- 1
sysaudit/__init__.py View File

@ -96,7 +96,19 @@ def _subscription_hook(event, args):
hook(args)
def subscribe(event, hook):
def subscribe(event, hook=None):
# No hook provided, return a decorator
# @sysaudit.subscribe("event.name")
# def event_name_hook(args):
# pass
if not hook:
def decorator(fn):
subscribe(event, fn)
return fn
return decorator
global _subscriptions
global _subscription_hook_active


Loading…
Cancel
Save