def setUp(self): self.sender = raygunprovider.RaygunSender('invalidapikey') self.handler = raygunprovider.RaygunHandler('testkey', 'v1.0')
import sys, logging, os from raygun4py import raygunprovider logger = logging.getLogger("mylogger") rgHandler = raygunprovider.RaygunHandler("paste_your_api_key_here") logger.addHandler(rgHandler) def log_exception(exc_type, exc_value, exc_traceback): logger.error("A python error occurred", exc_info=(exc_type, exc_value, exc_traceback)) print "Logging: %s" % exc_value sys.excepthook = log_exception def buggyMethod(): raise StandardError("Test exception sent via built-in handler") buggyMethod()
app.register_blueprint(ares, url_prefix='/radio') app.config['PYSTMARK_API_KEY'] = environ.get('POSTMARK_API_TOKEN') app.config['PYSTMARK_DEFAULT_SENDER'] = '*****@*****.**' pystmark = Pystmark(app) Bootstrap(app) connect('sdf', host=environ.get('MONGOLAB_URI'), read_preference=read_preferences.ReadPreference.PRIMARY) app.config['SECRET_KEY'] = environ.get('SECRET_KEY') logger = logging.getLogger("mylogger") rgHandler = raygunprovider.RaygunHandler(environ.get('RAYGUN_APIKEY')) raygun = raygunprovider.RaygunSender(environ.get('RAYGUN_APIKEY')) logger.addHandler(rgHandler) def log_exception(exc_type, exc_value, exc_traceback): print "Logging: %s" % exc_value logger.error("A python error occurred", exc_info = (exc_type, exc_value, exc_traceback)) sys.excepthook = log_exception @app.route('/') def hello_world(): return render_template('home.html') @app.errorhandler(404)
import base64 import facebook import base64 from functions import * from google.appengine.api import urlfetch from google.appengine.ext import ndb from settings import SETTINGS from settings import SECRET_SETTINGS from settings import SAFEBOX_LOCATIONS from settings import DEPPO from settings import RAYGUN_API_KEY from raygun4py import raygunprovider logger = logging.getLogger("mylogger") rgHandler = raygunprovider.RaygunHandler(RAYGUN_API_KEY) cl = raygunprovider.RaygunSender(RAYGUN_API_KEY) logger.addHandler(rgHandler) jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader( os.path.dirname(__file__)), autoescape=True) def login_required(fn): '''So we can decorate any RequestHandler with #@login_required''' def wrapper(self, *args): if not self.user: self.redirect(self.uri_for('www-front', referred=self.request.path)) else:
def test_log_without_sending(self): logger = logging.getLogger("mylogger") rgHandler = raygunprovider.RaygunHandler(self.apiKey) logger.addHandler(rgHandler) self.assertEquals(0, self.log_nosend(logger))