Commit 9fd1aa6a authored by Guillaume Seguin's avatar Guillaume Seguin

Merge branch 'loggerfix'

Conflicts:
	printrun/printcore.py
	printrun/printrun_utils.py
parents 1395a013 0d7b62fa
...@@ -24,6 +24,9 @@ from Queue import Queue, Empty as QueueEmpty ...@@ -24,6 +24,9 @@ from Queue import Queue, Empty as QueueEmpty
import time import time
import platform import platform
import os import os
import sys
reload(sys).setdefaultencoding('utf8')
import logging
import traceback import traceback
import errno import errno
import socket import socket
...@@ -31,11 +34,10 @@ import re ...@@ -31,11 +34,10 @@ import re
from functools import wraps from functools import wraps
from collections import deque from collections import deque
from printrun.GCodeAnalyzer import GCodeAnalyzer from printrun.GCodeAnalyzer import GCodeAnalyzer
from printrun.printrun_utils import install_locale, decode_utf8 from printrun.printrun_utils import install_locale, decode_utf8, setup_logging
install_locale('pronterface') install_locale('pronterface')
import logging setup_logging(sys.stderr)
logging.basicConfig(format = "%(levelname)s: %(message)s")
def locked(f): def locked(f):
@wraps(f) @wraps(f)
......
...@@ -19,6 +19,7 @@ import gettext ...@@ -19,6 +19,7 @@ import gettext
import datetime import datetime
import subprocess import subprocess
import shlex import shlex
import logging
# Set up Internationalization using gettext # Set up Internationalization using gettext
# searching for installed locales on /usr/share; uses relative folder if not # searching for installed locales on /usr/share; uses relative folder if not
...@@ -32,6 +33,13 @@ def install_locale(domain): ...@@ -32,6 +33,13 @@ def install_locale(domain):
else: else:
gettext.install(domain, './locale', unicode = 1) gettext.install(domain, './locale', unicode = 1)
def setup_logging(out):
logger = logging.getLogger()
logger.handlers = []
logging_handler = logging.StreamHandler(out)
logging_handler.setFormatter(logging.Formatter("[%(levelname)s] %(message)s"))
logger.addHandler(logging_handler)
def iconfile(filename): def iconfile(filename):
if hasattr(sys, "frozen") and sys.frozen == "windows_exe": if hasattr(sys, "frozen") and sys.frozen == "windows_exe":
return sys.executable return sys.executable
......
...@@ -30,7 +30,8 @@ import logging ...@@ -30,7 +30,8 @@ import logging
from . import pronsole from . import pronsole
from . import printcore from . import printcore
from printrun.printrun_utils import install_locale, RemainingTimeEstimator from printrun.printrun_utils import install_locale, \
RemainingTimeEstimator, setup_logging
install_locale('pronterface') install_locale('pronterface')
try: try:
...@@ -64,6 +65,7 @@ class Tee(object): ...@@ -64,6 +65,7 @@ class Tee(object):
def __init__(self, target): def __init__(self, target):
self.stdout = sys.stdout self.stdout = sys.stdout
sys.stdout = self sys.stdout = self
setup_logging(sys.stdout)
self.target = target self.target = target
def __del__(self): def __del__(self):
......
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