Skip to content

Commit

Permalink
Merge pull request #73 from cybem/log-exceptions
Browse files Browse the repository at this point in the history
Log exceptions
  • Loading branch information
brutasse committed Feb 12, 2015
2 parents 3f6fe02 + d7b4253 commit c9b9605
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions graphite_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .search import IndexSearcher
from .storage import Store
from . import DEBUG
from flask.signals import got_request_exception

try:
from logging.config import dictConfig
Expand Down Expand Up @@ -82,6 +83,10 @@ def load_by_path(path):
return getattr(finder, klass)


def log_exception(sender, exception, **extra):
logger.error('Exception', exception=exception)


def configure(app):
config_file = os.environ.get('GRAPHITE_API_CONFIG',
'/etc/graphite-api.yaml')
Expand All @@ -96,6 +101,8 @@ def configure(app):

configure_logging(config)

got_request_exception.connect(log_exception, app)

for key, value in list(default_conf.items()):
config.setdefault(key, value)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'six',
'structlog',
'tzlocal',
'blinker',
]

if sys.version_info < (2, 7):
Expand Down

0 comments on commit c9b9605

Please sign in to comment.