Beispiel #1
0
def add_errormator(app, config=None):
    """
        Adds Errormator to Flask,

        first looks at config var,then tries to read ERRORMATOR from app.config
    """
    if not config:
        config = app.config.get('ERRORMATOR')
    if not config:
        config = get_config()
    app.wsgi_app = make_errormator_middleware(app.wsgi_app, config)
    request_started.connect(populate_post_vars, app)
    got_request_exception.connect(log_exception, app)
    return app
def add_errormator(app, config=None):
    """
        Adds Errormator to Flask,

        first looks at config var,then tries to read ERRORMATOR from app.config
    """
    if not config:
        config = app.config.get("ERRORMATOR")
    if not config:
        config = get_config()
    app.wsgi_app = make_errormator_middleware(app.wsgi_app, config)
    request_started.connect(populate_post_vars, app)
    got_request_exception.connect(log_exception, app)
    return app
Beispiel #3
0
    def pserve(self, *args, **kwargs):
        argv = sys.argv
        quiet = False
        ini_path = os.environ.get('ERRORMATOR_INI')
        config = {}
        if not ini_path:
            print "ERRORMATOR_INI variable is missing from environment/run cmd"
        else:
            config = client.get_config(path_to_config=ini_path)
        if not config.get('errormator'):
            print 'WARNING Could not instantiate the client properly'
        else:
            client.Client(config)
        from pyramid.scripts import pserve

        command = pserve.PServeCommand(argv[1:], quiet=quiet)
        return command.run()
Beispiel #4
0
    def pserve(self, *args, **kwargs):
        argv = sys.argv
        quiet = False
        ini_path = os.environ.get('ERRORMATOR_INI')
        config = {}
        if not ini_path:
            print "ERRORMATOR_INI variable is missing from environment/run cmd"
        else:
            config = client.get_config(path_to_config=ini_path)
        if not config.get('errormator'):
            print 'WARNING Could not instantiate the client properly'
        else:
            client.Client(config)
        from pyramid.scripts import pserve

        command = pserve.PServeCommand(argv[1:], quiet=quiet)
        return command.run()
Beispiel #5
0
    def testini(cls, ini_name):
        print '\nCurrent directory: %s' % cwd
        ini_path = os.path.join(cwd, ini_name)
        config = client.get_config(path_to_config=ini_path)
        print 'INI file read - creating client'
        errormator_client = client.Client(config)
        print 'Client created, sending test entry'
        record = logging.makeLogRecord({'name': 'errormator.client.test',
                                        'message': 'Test entry'})

        errormator_client.py_log({}, [record])
        result = errormator_client.submit_data()
        if not result['logs']:
            print 'something went wrong, please check your API key'
            return False
        else:
            print 'Test entry transmitted correctly'
        return True
Beispiel #6
0
    def testini(cls, ini_name):
        print '\nCurrent directory: %s' % cwd
        ini_path = os.path.join(cwd, ini_name)
        config = client.get_config(path_to_config=ini_path)
        print 'INI file read - creating client'
        errormator_client = client.Client(config)
        print 'Client created, sending test entry'
        record = logging.makeLogRecord({
            'name': 'errormator.client.test',
            'message': 'Test entry'
        })

        errormator_client.py_log({}, [record])
        result = errormator_client.submit_data()
        if not result['logs']:
            print 'something went wrong, please check your API key'
            return False
        else:
            print 'Test entry transmitted correctly'
        return True
Beispiel #7
0
import datetime
import logging
import pkg_resources
import socket
import time
import unittest
import pprint
from errormator_client import client, make_errormator_middleware
from errormator_client.exceptions import get_current_traceback
from errormator_client.logger import register_logging
from errormator_client.wsgi import ErrormatorWSGIWrapper
from webob import Request

fname = pkg_resources.resource_filename('errormator_client',
                                        'templates/default_template.ini')
timing_conf = client.get_config(path_to_config=fname)
for k, v in timing_conf.iteritems():
    if 'errormator.timing' in k:
        timing_conf[k] = 0.0000001

client.Client(config=timing_conf)
from errormator_client.timing import local_timing, get_local_storage


def example_filter_callable(structure, section=None):
    return 'filtered-data'


TEST_ENVIRON = {
    'bfg.routes.matchdict': {'action': u'error'},
    'HTTP_COOKIE': 'country=US; http_referer="http://localhost:5000/"; test_group_id=5; sessionId=ec3ae5;',
Beispiel #8
0
import datetime
import logging
import socket
import pkg_resources
import time
from errormator_client import client, make_errormator_middleware
from errormator_client.exceptions import get_current_traceback
from errormator_client.logger import register_logging
from errormator_client.wsgi import ErrormatorWSGIWrapper


fname = pkg_resources.resource_filename('errormator_client',
                                        'templates/default_template.ini')
timing_conf = client.get_config(path_to_config=fname)
for k, v in timing_conf.iteritems():
    if 'errormator.timing' in k:
        timing_conf[k] = 0.00000001

client.Client(config=timing_conf)
from errormator_client.timing import local_timing, get_local_storage

import timeit
import jinja2

print 'traced', hasattr(jinja2.Template.render, '_e_attached_tracer')

s = """
template = jinja2.Template('''xxxxx {{1+2}} yyyyyy''')
template.render()
"""
print 'time', timeit.timeit(stmt=s, number=1500, setup="import jinja2")