Here's the relevant part of my ~/.ipython/ipy_user_conf.py
file on a system running IPython .10.1:
import IPython.ipapi
ip = IPython.ipapi.get()
import os
from time import strftime
def main():
try:
basedir = '/home/stu/.ipython/log/'
logdir = strftime('%Y-%m-%d')
directory = os.path.join(basedir, logdir)
if not os.path.exists(directory):
os.mkdir(directory)
logfilename = strftime("%s") + ".log"
filename = os.path.join(directory, logfilename)
ip.IP.logger.logstart(logfname=filename, logmode='append')
except RuntimeError:
print "something went wrong!"
main()
This logs all input during interactive sessions to files of the form: /home/stu/.ipython/log/2012-04-26/1335454387.log
How can I configure IPython 0.12 to create logs in this manner?
Is it ideal to create a ~/.ipython/profile_default/startup/00-logstuff.py
file for this?
Does anyone have a set of ~.ipython/<profile>/startup/
scripts which could serve as good practical examples?
Thanks
Have a look at this recipe. You can modify it to do folder-per-day rather than file-per-day easily enough.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.