Commit 68759f29 authored by ale's avatar ale

add a handler for gunicorn

parent 8a219c7a
import functools
import json
import logging
import logging.handlers
import re
import urllib
import uuid
......@@ -182,6 +183,14 @@ def create_app(config_file=None, config={}):
else:
app.config.from_envvar('APP_CONFIG', silent=True)
# Optionally enable Sentry.
if 'SENTRY_DSN' in app.config:
try:
from raven.contrib.flask import Sentry
sentry = Sentry(app)
except ImportError:
pass
# Check configuration for required attributes.
required_attrs = ['SSO_DOMAIN', 'SSO_SECRET_KEY', 'SSO_PUBLIC_KEY',
'SSO_AUTH_MODULE']
......@@ -194,3 +203,11 @@ def create_app(config_file=None, config={}):
return app
def setup_syslog(level=logging.INFO):
root_logger = logging.getLogger()
root_logger.setLevel(level)
syslog_handler = logging.handlers.SysLogHandler(address='/dev/log')
syslog_handler.setFormatter(
logging.Formatter('sso_server: %(name)s: %(levelname)s %(message)s'))
root_logger.addHandler(syslog_handler)
......@@ -29,13 +29,12 @@ __version__ = '0.3'
import errno
import logging
import logging.handlers
import os
import optparse
import signal
import socket
import sys
from sso_server import application
from sso_server import application, setup_syslog
log = logging.getLogger(__name__)
......@@ -45,12 +44,7 @@ def setup_logging(opts):
if opts.logtostderr:
logging.basicConfig(level=level)
else:
root_logger = logging.getLogger()
root_logger.setLevel(level)
syslog_handler = logging.handlers.SysLogHandler(address='/dev/log')
syslog_handler.setFormatter(
logging.Formatter('sso_server: %(name)s: %(levelname)s %(message)s'))
root_logger.addHandler(syslog_handler)
setup_syslog(level)
def autodetect_fastcgi():
......
# Entry point for gunicorn and mod_wsgi.
import os
from sso_server import application, setup_syslog
setup_syslog()
app = application.create_app(
os.getenv('APP_CONFIG', '/etc/sso/config'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment