server/general: improve request logging
This commit is contained in:
parent
ac23067fdf
commit
af36c90618
|
@ -85,6 +85,7 @@ def create_app():
|
|||
middleware.ContextAdapter(),
|
||||
middleware.DbSession(),
|
||||
middleware.Authenticator(),
|
||||
middleware.RequestLogger(),
|
||||
])
|
||||
|
||||
app.add_error_handler(errors.AuthError, _on_auth_error)
|
||||
|
|
|
@ -5,3 +5,4 @@ from szurubooru.middleware.context_adapter import ContextAdapter
|
|||
from szurubooru.middleware.require_json import RequireJson
|
||||
from szurubooru.middleware.db_session import DbSession
|
||||
from szurubooru.middleware.cache_purger import CachePurger
|
||||
from szurubooru.middleware.request_logger import RequestLogger
|
||||
|
|
|
@ -12,5 +12,3 @@ class DbSession(object):
|
|||
|
||||
def process_response(self, _request, _response, _resource):
|
||||
db.session.remove()
|
||||
if config.config['debug']:
|
||||
logger.info('Executed %d queries', db.get_query_count())
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import logging
|
||||
from szurubooru import db
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class RequestLogger(object):
|
||||
def process_request(self, request, _response):
|
||||
pass
|
||||
|
||||
def process_response(self, request, _response, _resource):
|
||||
logger.info(
|
||||
'%s (user=%s, queries=%d)',
|
||||
request.url,
|
||||
request.context.user.name,
|
||||
db.get_query_count())
|
Loading…
Reference in New Issue