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 #77master
parent
7e595b27ed
commit
8543d628b5
|
@ -509,11 +509,20 @@ class Server():
|
||||||
"when": "D",
|
"when": "D",
|
||||||
"backupCount": "1",
|
"backupCount": "1",
|
||||||
"filename": os.path.join(settings().getBaseFolder("logs"), "octoprint.log")
|
"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": {
|
"loggers": {
|
||||||
"octoprint.gcodefiles": {
|
"SERIAL": {
|
||||||
"level": "DEBUG"
|
"level": "DEBUG",
|
||||||
|
"handlers": ["serialFile"],
|
||||||
|
"propagate": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import re
|
||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
import Queue as queue
|
import Queue as queue
|
||||||
|
import logging
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
|
@ -143,6 +144,9 @@ class MachineCom(object):
|
||||||
STATE_CLOSED_WITH_ERROR = 10
|
STATE_CLOSED_WITH_ERROR = 10
|
||||||
|
|
||||||
def __init__(self, port = None, baudrate = None, callbackObject = None):
|
def __init__(self, port = None, baudrate = None, callbackObject = None):
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._serialLogger = logging.getLogger("SERIAL")
|
||||||
|
|
||||||
if port == None:
|
if port == None:
|
||||||
port = settings().get(["serial", "port"])
|
port = settings().get(["serial", "port"])
|
||||||
if baudrate == None:
|
if baudrate == None:
|
||||||
|
@ -422,6 +426,7 @@ class MachineCom(object):
|
||||||
|
|
||||||
def _log(self, message):
|
def _log(self, message):
|
||||||
self._callback.mcLog(message)
|
self._callback.mcLog(message)
|
||||||
|
self._serialLogger.debug(message)
|
||||||
try:
|
try:
|
||||||
self._logQueue.put(message, False)
|
self._logQueue.put(message, False)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in New Issue