summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cramer <dcramer@gmail.com>2016-07-22 13:37:30 -0700
committerDavid Cramer <dcramer@gmail.com>2016-07-22 13:38:32 -0700
commit79aa83245343e21496e489bd36b94124706085e4 (patch)
tree920bf07bfc4996a1e14ae28be40ed7defc4b114d
parentc3e170312df8d5efd64d33a55b7f66496117a86e (diff)
downloadraven-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.py13
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)