add api debug flag

This commit is contained in:
j 2017-06-14 13:08:22 +02:00
parent aae3407860
commit ca3909abed
2 changed files with 5 additions and 1 deletions

View file

@ -19,6 +19,7 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def json_response(data=None, status=200, text='ok'): def json_response(data=None, status=200, text='ok'):
if not data: if not data:
data = {} data = {}
@ -76,6 +77,7 @@ def defaultcontext():
@run_async @run_async
def api_task(context, request, callback): def api_task(context, request, callback):
import settings
if context == None: if context == None:
context = defaultcontext context = defaultcontext
action = request.arguments.get('action', [None])[0].decode('utf-8') action = request.arguments.get('action', [None])[0].decode('utf-8')
@ -89,7 +91,8 @@ def api_task(context, request, callback):
'doc': actions.doc(f).replace('\n', '<br>\n')}) 'doc': actions.doc(f).replace('\n', '<br>\n')})
response = json_response(api) response = json_response(api)
else: else:
logger.debug('API %s %s', action, data) if settings.DEBUG_API:
logger.debug('API %s %s', action, data)
f = actions.get(action) f = actions.get(action)
if f: if f:
with context(): with context():

View file

@ -87,5 +87,6 @@ VERSION = "%s.%s" % (NODE_PROTOCOL, MINOR_VERSION)
USER_AGENT = 'OpenMediaLibrary/%s' % VERSION USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
DEBUG_HTTP = server.get('debug_http', False) DEBUG_HTTP = server.get('debug_http', False)
DEBUG_API = server.get('debug_api', False)
DB_VERSION = 13 DB_VERSION = 13