Commit 0a5dca82 authored by Guillaume Seguin's avatar Guillaume Seguin

WIP #561: restore stdstreams in printcore, don't butcher loggers

And move setup_logging to the main printcore app file. This way we don't
need to butcher loggers anymore
parent 0301ad79
...@@ -20,9 +20,11 @@ import getopt ...@@ -20,9 +20,11 @@ import getopt
import sys import sys
from printrun.printcore import printcore from printrun.printcore import printcore
from printrun.utils import setup_logging
from printrun import gcoder from printrun import gcoder
if __name__ == '__main__': if __name__ == '__main__':
setup_logging(sys.stderr)
baud = 115200 baud = 115200
loud = False loud = False
statusreport = False statusreport = False
......
...@@ -25,7 +25,9 @@ import time ...@@ -25,7 +25,9 @@ import time
import platform import platform
import os import os
import sys import sys
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
reload(sys).setdefaultencoding('utf8') reload(sys).setdefaultencoding('utf8')
sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr
import logging import logging
import traceback import traceback
import errno import errno
...@@ -34,11 +36,9 @@ import re ...@@ -34,11 +36,9 @@ import re
from functools import wraps from functools import wraps
from collections import deque from collections import deque
from printrun import gcoder from printrun import gcoder
from .utils import install_locale, decode_utf8, setup_logging from .utils import install_locale, decode_utf8
install_locale('pronterface') install_locale('pronterface')
setup_logging(sys.stderr)
def locked(f): def locked(f):
@wraps(f) @wraps(f)
def inner(*args, **kw): def inner(*args, **kw):
......
...@@ -51,7 +51,6 @@ def setup_logging(out, filepath = None): ...@@ -51,7 +51,6 @@ def setup_logging(out, filepath = None):
logger = logging.getLogger() logger = logging.getLogger()
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
formatter = LogFormatter("[%(levelname)s] %(message)s", "%(message)s") formatter = LogFormatter("[%(levelname)s] %(message)s", "%(message)s")
logger.handlers = []
logging_handler = logging.StreamHandler(out) logging_handler = logging.StreamHandler(out)
logging_handler.setFormatter(formatter) logging_handler.setFormatter(formatter)
logger.addHandler(logging_handler) logger.addHandler(logging_handler)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment