My objective is to call ipython
, while also logging all input/output to IPython, and see something like:
stu@stumac ~ $ ipython
In [1]: exit
stu@stumac ~ $
The banner can be easily removed if I set
c.TerminalIPythonApp.display_banner = False
in my
~/.ipython/profile-default/ipython_config.py
file.
But how do I get this clean of a startup while also logging things?
On a fresh install, if I start IPython with no parameters I see:
sente@og ~ $ ipython
Python 2.7.3 (default, Jun 20 2013, 12:50:58)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: exit
sente@og ~ $
If I pass a logfile=logfile.txt
argument when invoking IPython I see:
sente@og ~ $ ipython --logfile=logfile.txt
Activating auto-logging. Current session state plus future input saved.
Filename : logfile.txt
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
Python 2.7.3 (default, Jun 20 2013, 12:50:58)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: exit
sente@og ~ $
How can I use logging without adding the extra clutter to my terminal:
Activating auto-logging. Current session state plus future input saved.
Filename : logfile.txt
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
On other machines I have IPython configured to automatically log things by having a .ipython/profile_default/startup/01-log-everything.py
which contains the lines:
from time import strftime
import os.path
ip = get_ipython()
ldir = ip.profile_dir.log_dir
fname = strftime('%Y-%m-%d-%H-%M-%S') + ".py"
filename = os.path.join(ldir, fname)
ip.run_line_magic('logstart', '-o %s append' % filename)
which results in the same clutter as when I add --logfile=logfile.txt
Any help on how to properly do this would be appreciated. I could if nothing else redirect sys.stdout, configure logging and then reset sys.stdout but I'm hoping there's a less hackish solution.