Add optional logging to sentry (www.getsentry.com)

master
Nick Groenen 2012-10-06 23:15:54 +02:00
parent 3f6e482c33
commit e6693d8c7d
2 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,11 @@ BOT_LOG_LEVEL = logging.INFO
# set the log file, None = console only, be sure the user of the bot can write there
BOT_LOG_FILE = '/var/log/err/err.log'
# Enable logging to sentry (find out more about sentry at www.getsentry.com).
BOT_LOG_SENTRY = False
SENTRY_DSN = ''
SENTRY_LOGLEVEL = BOT_LOG_LEVEL
# Base configuration (Jabber mode)
BOT_IDENTITY = {
'username' : 'err@localhost', # JID of the user you have created for the bot

View File

@ -85,7 +85,7 @@ def main(bot_class):
from errbot.utils import PLUGINS_SUBDIR
from errbot import holder
from config import BOT_IDENTITY, BOT_LOG_LEVEL, BOT_DATA_DIR, BOT_LOG_FILE
from config import BOT_IDENTITY, BOT_LOG_LEVEL, BOT_DATA_DIR, BOT_LOG_FILE, BOT_LOG_SENTRY
if BOT_LOG_FILE:
hdlr = logging.FileHandler(BOT_LOG_FILE)
@ -93,6 +93,12 @@ def main(bot_class):
logger.addHandler(hdlr)
logger.setLevel(BOT_LOG_LEVEL)
if BOT_LOG_SENTRY:
from raven.handlers.logging import SentryHandler
from config import SENTRY_DSN, SENTRY_LOGLEVEL
sentryhandler = SentryHandler(SENTRY_DSN, level=SENTRY_LOGLEVEL)
logger.addHandler(sentryhandler)
d = path.dirname(BOT_DATA_DIR)
if not path.exists(d):
raise Exception('The data directory %s for the bot does not exist' % BOT_DATA_DIR)