Commit 25adff51 authored by Guillaume Seguin's avatar Guillaume Seguin

Setup a logging handler to log to stdout

parent e47bc618
...@@ -25,6 +25,9 @@ import time ...@@ -25,6 +25,9 @@ import time
import sys import sys
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
...@@ -32,9 +35,11 @@ import re ...@@ -32,9 +35,11 @@ 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')
setup_logging(sys.stdout)
def locked(f): def locked(f):
@wraps(f) @wraps(f)
def inner(*args, **kw): def inner(*args, **kw):
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import os import os
import sys import sys
import gettext import gettext
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
...@@ -29,6 +30,13 @@ def install_locale(domain): ...@@ -29,6 +30,13 @@ def install_locale(domain):
else: else:
gettext.install(domain, './locale', unicode = 1) gettext.install(domain, './locale', unicode = 1)
def setup_logging(stdout):
logger = logging.getLogger()
logger.handlers.clear()
logging_handler = logging.StreamHandler(stdout)
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
......
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