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
import time
import platform
import os
import sys
reload(sys).setdefaultencoding('utf8')
import logging
import traceback
import errno
import socket
......@@ -31,11 +34,10 @@ import re
from functools import wraps
from collections import deque
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')
import logging
logging.basicConfig(format = "%(levelname)s: %(message)s")
setup_logging(sys.stderr)
def locked(f):
@wraps(f)
......
......@@ -19,6 +19,7 @@ import gettext
import datetime
import subprocess
import shlex
import logging
# Set up Internationalization using gettext
# searching for installed locales on /usr/share; uses relative folder if not
......@@ -32,6 +33,13 @@ def install_locale(domain):
else:
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):
if hasattr(sys, "frozen") and sys.frozen == "windows_exe":
return sys.executable
......
......@@ -30,7 +30,8 @@ import logging
from . import pronsole
from . import printcore
from printrun.printrun_utils import install_locale, RemainingTimeEstimator
from printrun.printrun_utils import install_locale, \
RemainingTimeEstimator, setup_logging
install_locale('pronterface')
try:
......@@ -64,6 +65,7 @@ class Tee(object):
def __init__(self, target):
self.stdout = sys.stdout
sys.stdout = self
setup_logging(sys.stdout)
self.target = target
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