我的目标是调用ipython,同时还将所有输入/输出记录到IPython,并看到类似以下内容的内容:
stu@stumac ~ $ ipython
In [1]: exit
stu@stumac ~ $
如果我设置了横幅,则可以轻松删除该横幅
c.TerminalIPythonApp.display_banner = False
在我的 ~/.ipython/profile-default/ipython_config.py档案中。
但是,如何在记录日志的同时清除启动程序呢?
在全新安装中,如果我不使用任何参数启动IPython,则会看到:
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 ~ $
如果我logfile=logfile.txt在调用IPython时传递了一个参数,则会看到:
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 ~ $
如何在不增加终端混乱的情况下使用日志记录:
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
在其他机器上,我将IPython配置为通过.ipython/profile_default/startup/01-log-everything.py包含包含以下行的来自动记录事物:
这导致与我添加时相同的混乱 --logfile=logfile.txt
任何有关如何正确执行此操作的帮助将不胜感激。如果没有别的办法,我可以重定向sys.stdout,配置日志记录,然后重设sys.stdout,但我希望有一个更简单的解决方案。
白衣染霜花
相关分类