diff options
| author | David Cramer <dcramer@gmail.com> | 2016-07-22 13:37:30 -0700 |
|---|---|---|
| committer | David Cramer <dcramer@gmail.com> | 2016-07-22 13:38:32 -0700 |
| commit | 79aa83245343e21496e489bd36b94124706085e4 (patch) | |
| tree | 920bf07bfc4996a1e14ae28be40ed7defc4b114d | |
| parent | c3e170312df8d5efd64d33a55b7f66496117a86e (diff) | |
| download | raven-feature/default-client.tar.gz | |
Default Raven instancefeature/default-client
This creates a default client instance at runtime which eliminates the need to do anything other than 'import raven' if SENTRY_DSN is set.
We can also leverage this to move more towards setters rather than client instantiation going forward.
@getsentry/python
| -rw-r--r-- | raven/base.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/raven/base.py b/raven/base.py index bae7584..c65e776 100644 --- a/raven/base.py +++ b/raven/base.py @@ -44,7 +44,7 @@ from raven.transport.registry import TransportRegistry, default_transports import raven.events # NOQA -__all__ = ('Client',) +__all__ = ('Client', 'Raven') __excepthook__ = None @@ -55,7 +55,7 @@ SDK_VALUE = { 'version': raven.VERSION, } -# singleton for the client +# Singleton for Client Raven = None @@ -137,7 +137,8 @@ class Client(object): def __init__(self, dsn=None, raise_send_errors=False, transport=None, install_sys_hook=True, install_logging_hook=True, - hook_libraries=None, enable_breadcrumbs=True, **options): + hook_libraries=None, enable_breadcrumbs=True, + _check_enabled_status=True, **options): global Raven o = options @@ -182,7 +183,7 @@ class Client(object): self.module_cache = ModuleProxyCache() - if not self.is_enabled(): + if _check_enabled_status and not self.is_enabled(): self.logger.info( 'Raven is not configured (logging is disabled). Please see the' ' documentation for more information.') @@ -847,3 +848,7 @@ class DummyClient(Client): "Sends messages into an empty void" def send(self, **kwargs): return None + + +# Bind default client at runtime +Raven = Client(_check_enabled_status=False) |
