def emit(self, record): from arecibo import post msg = self.format(record) if hasattr(record, 'request_repr'): request_repr = record.request_repr else: request_repr = "Request repr() unavailable" if hasattr(record, 'url'): url = record.url else: url = '' try: arecibo = post() arecibo.server(url=self.server) arecibo.set("account", self.account) arecibo.set("status", "500") arecibo.set("url", url) arecibo.set("traceback", msg) arecibo.send() except: # squelching exceptions sucks, but 500-ing because of a logging error sucks more pass
def report(msg, status=400, name=None, tb=None, req=None, priority=None, req_body=None, uri=None): """Generic Error notification""" import boto from datetime import datetime arecibo = None if boto.config.get('arecibo', 'public_key'): try: from arecibo import post arecibo = post() arecibo.server(url=boto.config.get('arecibo', 'url')) arecibo.set('account', boto.config.get('arecibo', 'public_key')) except: arecibo = None method = '' remote_ip = '' path = uri if req: uri = req.real_path_url path = req.path_info req_body = req.body remote_ip = req.headers.get('X-Forwarded-For', req.remote_addr) method = req.method if arecibo: log.info('Arecibo Log: %s' % msg) try: arecibo.set('status', status) arecibo.set('msg', msg) arecibo.set('server', boto.config.get('Instance', 'public-ipv4')) arecibo.set('timestamp', datetime.utcnow().isoformat()); if name: arecibo.set('type', name) if priority: arecibo.set('priority', str(priority)) if uri: arecibo.set('url', uri) if req_body: arecibo.set('request', req_body) if tb: arecibo.set('traceback', tb) if req: if req.user: arecibo.set('username', req.user.username) if req.environ.has_key('HTTP_USER_AGENT'): arecibo.set('user_agent', req.environ['HTTP_USER_AGENT']) if remote_ip: arecibo.set('ip', remote_ip) arecibo.send() except Exception, e: log.critical('Exception sending to arecibo: %s' % e)
def report(msg, status=400, name=None, tb=None, req=None, priority=None, req_body=None, uri=None): """Generic Error notification""" import boto from datetime import datetime arecibo = None if boto.config.get("arecibo", "public_key"): try: from arecibo import post arecibo = post() arecibo.server(url=boto.config.get("arecibo", "url")) arecibo.set("account", boto.config.get("arecibo", "public_key")) except: arecibo = None method = "" remote_ip = "" path = uri if req: uri = req.real_path_url path = req.path_info req_body = req.body remote_ip = req.headers.get("X-Forwarded-For", req.remote_addr) method = req.method if arecibo: log.info("Arecibo Log: %s" % msg) try: arecibo.set("status", status) arecibo.set("msg", msg) arecibo.set("server", boto.config.get("Instance", "public-ipv4")) arecibo.set("timestamp", datetime.utcnow().isoformat()); if name: arecibo.set("type", name) if priority: arecibo.set("priority", str(priority)) if uri: arecibo.set("url", uri) if req_body: arecibo.set("request", req_body) if tb: arecibo.set("traceback", tb) if req: if req.user: arecibo.set("username", req.user.username) if req.environ.has_key("HTTP_USER_AGENT"): arecibo.set("user_agent", req.environ['HTTP_USER_AGENT']) if remote_ip: arecibo.set("ip", remote_ip) arecibo.send() except Exception, e: log.critical("Exception sending to arecibo: %s" % e)
def report(self, exc_info, environ): supplement = Supplement(self, environ) report = arecibo.post() report.server(url=self.url) report.set("account", self.account) report.set("status", "500") report.set("url", supplement.source_url) report.set("user_agent", environ.get("HTTP_USER_AGENT")) report.set("ip", remote_address(environ)) report.set("type", exc_info[0].__name__) if "REMOTE_USER" in environ: report.set("username", environ["REMOTE_USER"]) self.addRequestInfo(report, supplement) report.set("traceback", traceback.format_exc(exc_info[2])) report.send()
def report(msg, status=400, name=None, tb=None, req=None, priority=None, req_body=None, uri=None): """Generic Error notification""" import boto from datetime import datetime arecibo = None if boto.config.get('arecibo', 'public_key'): try: from arecibo import post arecibo = post() arecibo.server(url=boto.config.get('arecibo', 'url')) arecibo.set('account', boto.config.get('arecibo', 'public_key')) except: arecibo = None method = '' remote_ip = '' path = uri if req: uri = req.real_path_url path = req.path_info req_body = req.body remote_ip = req.headers.get('X-Forwarded-For', req.remote_addr) method = req.method if arecibo: log.info('Arecibo Log: %s' % msg) try: arecibo.set('status', status) arecibo.set('msg', msg) arecibo.set('server', boto.config.get('Instance', 'public-ipv4')) arecibo.set('timestamp', datetime.utcnow().isoformat()) if name: arecibo.set('type', name) if priority: arecibo.set('priority', str(priority)) if uri: arecibo.set('url', uri) if req_body: arecibo.set('request', req_body) if tb: arecibo.set('traceback', tb) if req: if req.user: arecibo.set('username', req.user.username) if req.environ.has_key('HTTP_USER_AGENT'): arecibo.set('user_agent', req.environ['HTTP_USER_AGENT']) if remote_ip: arecibo.set('ip', remote_ip) arecibo.send() except Exception, e: log.critical('Exception sending to arecibo: %s' % e)
def report(msg, status=400, name=None, tb=None, req=None, priority=None, req_body=None, uri=None): """Generic Error notification""" import boto from datetime import datetime arecibo = None if boto.config.get("arecibo", "public_key"): try: from arecibo import post arecibo = post() arecibo.server(url=boto.config.get("arecibo", "url")) arecibo.set("account", boto.config.get("arecibo", "public_key")) except: arecibo = None method = "" remote_ip = "" path = uri if req: uri = req.real_path_url path = req.path_info req_body = req.body remote_ip = req.headers.get("X-Forwarded-For", req.remote_addr) method = req.method if arecibo: log.info("Arecibo Log: %s" % msg) try: arecibo.set("status", status) arecibo.set("msg", msg) arecibo.set("server", boto.config.get("Instance", "public-ipv4")) arecibo.set("timestamp", datetime.utcnow().isoformat()) if name: arecibo.set("type", name) if priority: arecibo.set("priority", str(priority)) if uri: arecibo.set("url", uri) if req_body: arecibo.set("request", req_body) if tb: arecibo.set("traceback", tb) if req: if req.user: arecibo.set("username", req.user.username) if req.environ.has_key("HTTP_USER_AGENT"): arecibo.set("user_agent", req.environ['HTTP_USER_AGENT']) if remote_ip: arecibo.set("ip", remote_ip) arecibo.send() except Exception, e: log.critical("Exception sending to arecibo: %s" % e)