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__)
def json_response(data=None, status=200, text='ok'):
if not data:
data = {}
@ -76,6 +77,7 @@ def defaultcontext():
@run_async
def api_task(context, request, callback):
import settings
if context == None:
context = defaultcontext
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')})
response = json_response(api)
else:
logger.debug('API %s %s', action, data)
if settings.DEBUG_API:
logger.debug('API %s %s', action, data)
f = actions.get(action)
if f:
with context():

View file

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