Skip to content

Commit

Permalink
Added command-line option to redirect stdout/stderr to a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
matzman666 committed Dec 13, 2015
1 parent f9beaa2 commit 9e9a173
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pypipboyapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,20 @@ def setStyle(self, name):

# Main entry point
if __name__ == "__main__":
stdlogfile = None
i = 1
while i < len(sys.argv):
if sys.argv[i] == '--stdlog':
if i == len(sys.argv) -1 :
logging.error('Missing argument for --stdlog')
else:
i += 1
stdlogfile = sys.argv[i]
i += 1
if stdlogfile != None:
stdlog = open(stdlogfile, 'w')
sys.stdout = stdlog
sys.stderr = stdlog
try:
logging.config.fileConfig('logging.config')
except Exception as e:
Expand Down

0 comments on commit 9e9a173

Please sign in to comment.