import logbook

import sys

class SentryLogbookHandler(logbook.Handler):
    def emit(self, record):
        from sentry import capture

        # Avoid typical config issues by overriding loggers behavior
        if record.name == 'sentry.errors':
            print >> sys.stderr, "Recursive log message sent to SentryHandler"
            print >> sys.stderr, record.message
            return

        kwargs = dict(
            message=record.message,
            level=record.level,
            logger=record.channel,
            data=record.extra,
        )
        if record.exc_info:
            return capture('sentry.events.Exception', exc_inf=record.exc_info, **kwargs)
        return capture('sentry.events.Exception', **kwargs)


import logbook

from sentry import capture

class SentryLogbookHandler(logbook.Handler):
    def emit(self, record):

        # TODO: level should be a string
        tags = (('level', record.level), ('logger', record.channel))
        
        if record.exc_info:
            return capture('Exception', exc_info=record.exc_info, tags=tags)
        return capture('Message', message=record.mesage, tags=tags)


Clean up logbook handler to use correct params for capture()
Clean up logbook handler to use correct params for capture()
