本文整理汇总了Python中raven.Client方法的典型用法代码示例。如果您正苦于以下问题:Python raven.Client方法的具体用法?Python raven.Client怎么用?Python raven.Client使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raven
的用法示例。
在下文中一共展示了raven.Client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _install_sentry
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def _install_sentry():
if "AVALON_SENTRY" not in Session:
return
try:
from raven import Client
from raven.handlers.logging import SentryHandler
from raven.conf import setup_logging
except ImportError:
# Note: There was a Sentry address in this Session
return log.warning("Sentry disabled, raven not installed")
client = Client(Session["AVALON_SENTRY"])
# Transmit log messages to Sentry
handler = SentryHandler(client)
handler.setLevel(logging.WARNING)
setup_logging(handler)
self._sentry_client = client
self._sentry_logging_handler = handler
log.info("Connected to Sentry @ %s" % Session["AVALON_SENTRY"])
示例2: __init__
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def __init__(self, plugin):
self._mutex = threading.RLock()
self.plugin = plugin
self.__items__ = dict()
import raven
self.sentry = raven.Client(
'https://2b979afa37f849c1af93bcc9c88aded8:dea2054d56014d53b59376084b23e142@sentry.thespaghettidetective.com/5?verify_ssl=0',
release=plugin._plugin_version
)
try:
self.config_path = self.plugin.get_plugin_data_folder() + "/.config.yaml"
self._logger = logging.getLogger('octoprint.plugins.anywhere')
self.load_config()
except:
self.sentry.captureException()
import traceback; traceback.print_exc()
示例3: init_logging
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def init_logging(level='INFO'):
root = logging.getLogger()
root.setLevel(0)
patch_gevent_hub_print_exception()
if State.config.get('sentry'):
hdlr = SentryHandler(raven.Client(State.config['sentry'], transport=GeventedHTTPTransport))
hdlr.setLevel(logging.ERROR)
root.addHandler(hdlr)
fmter = ServerLogFormatter()
hdlr = logging.StreamHandler(sys.stdout)
hdlr.setLevel(getattr(logging, level))
hdlr.setFormatter(fmter)
root.addHandler(hdlr)
root.info(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
root.info('==============================================')
示例4: sentrytest
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def sentrytest(self):
"""return true if we managed to send a sample raven exception"""
if not (self.config.sentry and self.config.sentry.dsn):
raise SentryConfigurationError('sentry dsn not configured')
try:
version = raven.fetch_package_version('crontabber')
except Exception:
version = None
self.config.logger.warning(
'Unable to extract version of crontabber',
exc_info=True
)
client = raven.Client(
dsn=self.config.sentry.dsn,
release=version
)
identifier = client.captureMessage(
'Sentry test sent from crontabber'
)
self.config.logger.info(
'Sentry successful identifier: %s', identifier
)
return True
示例5: __init__
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def __init__(self, bot):
self.bot = bot
self.settings = dataIO.load_json('data/sentry/settings.json')
if self.settings['dsn'] is None:
log.warning('Sentry: DSN key is not set. Not sending logs!')
else:
if self.settings['ssl'] is False:
self.raven = Client(self.settings['dsn'] + '?verify_ssl=0')
else:
self.raven = Client(self.settings['dsn'])
self.handler = SentryHandler(self.raven)
self.handler.setLevel(self.settings['level'])
self.logger = logging.getLogger("red").addHandler(self.handler)
setup_logging(self.handler)
# --- Raven settings
self.raven.tags = self.settings['tags']
if self.settings['name'] is not None:
self.raven.name = self.settings['name']
if self.settings['environment'] is not None:
self.raven.environment = self.settings['environment']
if self.settings.get('ignore'):
self.raven.ignore = self.settings['ignore']
示例6: configure_logger
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def configure_logger(verbose):
def set_raven_client():
from polyaxon_cli.managers.cli import CliConfigManager
cli_config = CliConfigManager.get_config()
if cli_config and cli_config.log_handler and cli_config.log_handler.decoded_dsn:
import raven
client = raven.Client(
dsn=cli_config.log_handler.decoded_dsn,
release=cli_config.current_version,
environment=cli_config.log_handler.environment,
tags=cli_config.log_handler.tags,
processors=('raven.processors.SanitizePasswordsProcessor',))
client.error_logger.disabled = True
return client
return None
set_raven_client()
log_level = logging.DEBUG if verbose else logging.INFO
logging.basicConfig(format='%(message)s', level=log_level, stream=sys.stdout)
示例7: test_will_alert
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def test_will_alert(self, node, rule, testapp):
match = RuleMatch(
rule=rule,
node=node.to_dict(),
result={
'name': 'foo',
'action': 'added',
'timestamp': dt.datetime.utcnow(),
'columns': {'boo': 'baz', 'kung': 'bloo'},
}
)
with mock.patch.object(raven.Client, 'captureMessage', return_value=None) as pmock:
alerter = SentryAlerter(self.config)
alerter.handle_alert(node.to_dict(), match)
assert pmock.called
_, kwargs = pmock.call_args
assert kwargs['message'] == rule.template.safe_substitute(
match.result['columns'],
**node.to_dict()
).rstrip()
示例8: setup
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def setup(self):
sentry_config = self.container.config.get('SENTRY')
sentry_config = sentry_config or {}
dsn = sentry_config.get('DSN', None)
kwargs = sentry_config.get('CLIENT_CONFIG', {})
self.client = Client(dsn, transport=EventletHTTPTransport, **kwargs)
report_expected_exceptions = sentry_config.get(
'REPORT_EXPECTED_EXCEPTIONS', True
)
user_type_context_keys = sentry_config.get(
'USER_TYPE_CONTEXT_KEYS', USER_TYPE_CONTEXT_KEYS
)
tag_type_context_keys = sentry_config.get(
'TAG_TYPE_CONTEXT_KEYS', TAG_TYPE_CONTEXT_KEYS
)
self.report_expected_exceptions = report_expected_exceptions
self.user_type_context_keys = user_type_context_keys
self.tag_type_context_keys = tag_type_context_keys
示例9: main
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def main():
"""Wrapper around run() to setup sentry"""
sentry_dsn = os.environ.get('POLYSH_SENTRY_DSN')
if sentry_dsn:
from raven import Client
client = Client(
dsn=sentry_dsn,
release='.'.join(map(str, VERSION)),
ignore_exceptions=[
KeyboardInterrupt
]
)
try:
run()
except Exception:
client.captureException()
else:
run()
示例10: __init__
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def __init__(self, server, sock):
"""
Initialize a Client object
:param server: server object
:param sock: socket connection object
:return:
"""
self.__timestamp = time.time()
self.__readbuffer = ""
self.__writebuffer = ""
self.__sentPing = False
self.__handleCommand = self.passHandler
self.server = server
self.socket = sock
(self.ip, self.port) = sock.getpeername()
self.IRCUsername = ""
self.banchoUsername = ""
self.supposedUsername = ""
self.supposedUserID = 0
self.joinedChannels = []
示例11: disconnect
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def disconnect(self, quitmsg = "Client quit", callLogout = True):
"""
Disconnects this client from the IRC server
:param quitmsg: IRC quit message. Default: 'Client quit'
:param callLogout: if True, call logoutEvent on bancho
:return:
"""
# Send error to client and close socket
self.message("ERROR :{}".format(quitmsg))
self.socket.close()
log.info("[IRC] Disconnected connection from {}:{} ({})".format(self.ip, self.port, quitmsg))
# Remove socket from server
self.server.removeClient(self, quitmsg)
# Bancho logout
if callLogout and self.banchoUsername != "":
chat.IRCDisconnect(self.IRCUsername)
示例12: __init__
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def __init__(self, *, dsn, environment):
try:
from raven import Client
except ImportError as e:
raise ImportWarning(
'You must install raven in order to use the sentry logger'
) from e
self.raven = Client(dsn, environment=environment)
self.raven.transaction.clear()
示例13: init_logging
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def init_logging(gn_env: GNEnvironment) -> None:
if len(gn_env.config) == 0 or gn_env.config.get(ConfigKeys.TESTING, False):
# assume we're testing
return
logging_type = gn_env.config.get(ConfigKeys.TYPE, domain=ConfigKeys.LOGGING, default='logger')
if logging_type is None or len(logging_type.strip()) == 0 or logging_type in ['logger', 'default', 'mock']:
return
if logging_type != 'sentry':
raise RuntimeError('unknown logging type %s' % logging_type)
dsn = gn_env.config.get(ConfigKeys.DSN, domain=ConfigKeys.LOGGING, default='')
if dsn is None or len(dsn.strip()) == 0:
logger.warning('sentry logging selected but no DSN supplied, not configuring senty')
return
import raven
import socket
from git.cmd import Git
home_dir = os.environ.get('DINO_HOME', default=None)
if home_dir is None:
home_dir = '.'
tag_name = Git(home_dir).describe()
gn_env.sentry = raven.Client(
dsn=dsn,
environment=os.getenv(ENV_KEY_ENVIRONMENT),
name=socket.gethostname(),
release=tag_name
)
def capture_exception(e_info) -> None:
try:
gn_env.sentry.captureException(e_info)
except Exception as e2:
logger.exception(e_info)
logger.error('could not capture exception with sentry: %s' % str(e2))
gn_env.capture_exception = capture_exception
示例14: init_app
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def init_app(self, app):
dsn = app.config.get('SENTRY_DSN')
if dsn:
config = app.config.get_namespace('SENTRY_')
self.client = raven.Client(**config)
handler = SentryHandler(self.client)
handler.setLevel(logging.ERROR)
setup_logging(handler)
try:
from raven.contrib.celery import (
register_signal, register_logger_signal)
register_logger_signal(self.client)
register_signal(self.client)
except ImportError:
pass
示例15: __init__
# 需要导入模块: import raven [as 别名]
# 或者: from raven import Client [as 别名]
def __init__(self, config):
self.config = config
self.logger = logging.getLogger(__name__)
#client_id_file_path = os.path.join(_base_dir, 'data', 'client_id')
#saved_info = shelve.open(client_id_file_path)
#if saved_info.has_key('client_id'):
# self.client_id = saved_info['client_id']
#else:
# client_uuid = uuid.uuid4()
# self.client_id = str(client_uuid)
# saved_info['client_id'] = self.client_id
#saved_info.close()
client_uuid = uuid.uuid4()
self.client_id = str(client_uuid)
# UniversalAnalytics can be reviewed here:
# https://github.com/analytics-pros/universal-analytics-python
if self.config.health_record:
self.logger.info('Health check is enabled. For more information:')
self.logger.info('https://github.com/PokemonGoF/PokemonGo-Bot/tree/dev#analytics')
self.client = Client(
dsn='https://8abac56480f34b998813d831de262514:196ae1d8dced41099f8253ea2c8fe8e6@app.getsentry.com/90254',
name='PokemonGof-Bot',
processors = (
'raven.processors.SanitizePasswordsProcessor',
'raven.processors.RemoveStackLocalsProcessor'
),
install_logging_hook = False,
hook_libraries = (),
enable_breadcrumbs = False,
logging = False,
context = {}
)
self.heartbeat_wait = 15*60 # seconds
self.last_heartbeat = time.time()