moonraker: enable debug logging via the command line
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
efb9a9f649
commit
973b1ffa7d
|
@ -10,7 +10,7 @@ import logging
|
|||
import tornado
|
||||
from inspect import isclass
|
||||
from tornado.routing import Rule, PathMatches, AnyMatches
|
||||
from utils import DEBUG, ServerError
|
||||
from utils import ServerError
|
||||
from websockets import WebsocketManager, WebSocket
|
||||
from authorization import AuthorizedRequestHandler, AuthorizedFileHandler
|
||||
from authorization import Authorization
|
||||
|
@ -115,7 +115,7 @@ class MoonrakerApp:
|
|||
|
||||
self.app = tornado.web.Application(
|
||||
app_handlers,
|
||||
serve_traceback=DEBUG,
|
||||
serve_traceback=args.debug,
|
||||
websocket_ping_interval=10,
|
||||
websocket_ping_timeout=30,
|
||||
enable_cors=False)
|
||||
|
|
|
@ -19,7 +19,7 @@ from tornado.ioloop import IOLoop, PeriodicCallback
|
|||
from tornado.util import TimeoutError
|
||||
from tornado.locks import Event
|
||||
from app import MoonrakerApp
|
||||
from utils import ServerError, DEBUG, MoonrakerLoggingHandler
|
||||
from utils import ServerError, MoonrakerLoggingHandler
|
||||
|
||||
INIT_MS = 1000
|
||||
|
||||
|
@ -426,6 +426,9 @@ def main():
|
|||
parser.add_argument(
|
||||
"-k", "--apikey", default="~/.moonraker_api_key",
|
||||
metavar='<apikeyfile>', help="API Key file location")
|
||||
parser.add_argument(
|
||||
"-d", "--debug", action='store_true',
|
||||
help="Enable Debug Logging")
|
||||
cmd_line_args = parser.parse_args()
|
||||
|
||||
# Setup Logging
|
||||
|
@ -435,7 +438,7 @@ def main():
|
|||
file_hdlr = MoonrakerLoggingHandler(
|
||||
log_file, when='midnight', backupCount=2)
|
||||
root_logger.addHandler(file_hdlr)
|
||||
if DEBUG:
|
||||
if cmd_line_args.debug:
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
else:
|
||||
root_logger.setLevel(logging.INFO)
|
||||
|
|
|
@ -7,8 +7,6 @@ import logging
|
|||
import os
|
||||
import subprocess
|
||||
|
||||
DEBUG = True
|
||||
|
||||
class ServerError(Exception):
|
||||
def __init__(self, message, status_code=400):
|
||||
Exception.__init__(self, message)
|
||||
|
|
|
@ -9,7 +9,7 @@ import tornado
|
|||
import json
|
||||
from tornado.ioloop import IOLoop
|
||||
from tornado.websocket import WebSocketHandler, WebSocketClosedError
|
||||
from utils import ServerError, DEBUG
|
||||
from utils import ServerError
|
||||
|
||||
class JsonRPC:
|
||||
def __init__(self):
|
||||
|
@ -30,8 +30,7 @@ class JsonRPC:
|
|||
logging.exception(msg)
|
||||
response = self.build_error(-32700, "Parse error")
|
||||
return json.dumps(response)
|
||||
if DEBUG:
|
||||
logging.info("Websocket Request::" + data)
|
||||
logging.debug("Websocket Request::" + data)
|
||||
if isinstance(request, list):
|
||||
response = []
|
||||
for req in request:
|
||||
|
@ -44,7 +43,7 @@ class JsonRPC:
|
|||
response = await self.process_request(request)
|
||||
if response is not None:
|
||||
response = json.dumps(response)
|
||||
logging.info("Websocket Response::" + response)
|
||||
logging.debug("Websocket Response::" + response)
|
||||
return response
|
||||
|
||||
async def process_request(self, request):
|
||||
|
|
Loading…
Reference in New Issue