New serial log at ~/.octoprint/logs/serial.log

Logs the same content as the terminal tab and is restricted to 2MB in size (hopefully).

Closes #77
master
Gina Häußge 2013-03-16 02:24:33 +01:00
parent 7e595b27ed
commit 8543d628b5
2 changed files with 16 additions and 2 deletions

View File

@ -509,11 +509,20 @@ class Server():
"when": "D",
"backupCount": "1",
"filename": os.path.join(settings().getBaseFolder("logs"), "octoprint.log")
},
"serialFile": {
"class": "logging.handlers.RotatingFileHandler",
"level": "DEBUG",
"formatter": "simple",
"maxBytes": 2 * 1024 * 1024, # let's limit the serial log to 2MB in size
"filename": os.path.join(settings().getBaseFolder("logs"), "serial.log")
}
},
"loggers": {
"octoprint.gcodefiles": {
"level": "DEBUG"
"SERIAL": {
"level": "DEBUG",
"handlers": ["serialFile"],
"propagate": False
}
},
"root": {

View File

@ -9,6 +9,7 @@ import re
import traceback
import threading
import Queue as queue
import logging
import serial
@ -143,6 +144,9 @@ class MachineCom(object):
STATE_CLOSED_WITH_ERROR = 10
def __init__(self, port = None, baudrate = None, callbackObject = None):
self._logger = logging.getLogger(__name__)
self._serialLogger = logging.getLogger("SERIAL")
if port == None:
port = settings().get(["serial", "port"])
if baudrate == None:
@ -422,6 +426,7 @@ class MachineCom(object):
def _log(self, message):
self._callback.mcLog(message)
self._serialLogger.debug(message)
try:
self._logQueue.put(message, False)
except: