Skip to content

Commit

Permalink
Bring flask logging to structlog
Browse files Browse the repository at this point in the history
  • Loading branch information
brutasse committed Mar 21, 2014
1 parent bca2344 commit dfa272e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Graphite-API releases
----------------------------

* ``time_zone`` set to UTC by default instead of Europe/Berlin.
* Properly log app exceptions.

1.0.0 -- 2014-03-20
-------------------
Expand Down
9 changes: 9 additions & 0 deletions graphite_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from io import StringIO, BytesIO

from flask import Flask, jsonify
from structlog import get_logger

from .config import configure
from .encoders import JSONEncoder
Expand All @@ -20,6 +21,8 @@
from .render.grammar import grammar
from .utils import RequestParams

logger = get_logger()


class Graphite(Flask):
@property
Expand All @@ -34,6 +37,12 @@ def searcher(self):
def functions(self):
return self.config['GRAPHITE']['functions']

@property
def logger(self):
# Flask has its own logger that doesn't get any handler if we use
# dictconfig(). Replace it with our structlog logger.
return logger


app = Graphite(__name__)
configure(app)
Expand Down

0 comments on commit dfa272e

Please sign in to comment.