Skip to content

Commit

Permalink
Handle print() messages when not frozen and in debug. We only want to…
Browse files Browse the repository at this point in the history
… exclude handling stacktraces, so the IDE gets clickable line numbers.
  • Loading branch information
Ebag333 committed Feb 11, 2017
1 parent 3b185e1 commit 441b3f1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pyfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,19 @@ def flush(self):

with logging_setup.threadbound():
# Don't redirect if frozen
if not hasattr(sys, 'frozen') and not options.debug:
if not hasattr(sys, 'frozen'):
# Output all stdout (print) messages as warnings
try:
sys.stdout = LoggerWriter(pyfalog.warning)
except ValueError, Exception:
pyfalog.critical("Cannot access log file. Continuing without writing stdout to log.")
# Output all stderr (stacktrace) messages as critical
try:
sys.stderr = LoggerWriter(pyfalog.critical)
except ValueError, Exception:
pyfalog.critical("Cannot access log file. Continuing without writing stderr to log.")

if not options.debug:
# Output all stderr (stacktrace) messages as critical
try:
sys.stderr = LoggerWriter(pyfalog.critical)
except ValueError, Exception:
pyfalog.critical("Cannot access log file. Continuing without writing stderr to log.")

pyfalog.info("Starting Pyfa")
pyfalog.info("Running in logging mode: {0}", logging_mode)
Expand Down

0 comments on commit 441b3f1

Please sign in to comment.