[IPython-user] Log options at ipython startup

Fernando Perez fperez.net@gmail....
Wed Jan 13 13:42:30 CST 2010


On Tue, Jan 12, 2010 at 2:37 PM, Gökhan Sever <gokhansever@gmail.com> wrote:
> Here is what I have in my ipy_user_conf.py file:
>
>
> def main():
>
>     try:
>         ldir = '/home/user/.ipython/'
>         filename = os.path.join(ldir, strftime('%Y-%m-%d')+".py")
>         notnew = os.path.exists(filename)
>         ip.IP.logger.logstart(logfname=filename, logmode='append')
>         if notnew:
>             ip.IP.logger.log_write("# =================================")
>         else:
>             ip.IP.logger.log_write("""#!/usr/bin/env python \n# %s.py \n#
> IPython automatic logging file""" % strftime('%Y-%m-%d'))
>         ip.IP.logger.log_write("""# %s \n#
> =================================""" % strftime('%H:%M'))
>         print " Logging to "+filename
>
>     except RuntimeError:
>         print " Already logging to "+ip.IP.logger.logfname
>
>
> I learnt this trick from Pierre Raybaut of PythonXY. There is a log file per
> day and time-stamping per session. I am sure it could easily modified to log
> everything in a file and with a time stamp if this is what you need.

Contribution to the cookbook?

http://ipython.scipy.org/moin/Cookbook

Thanks :)

f


More information about the IPython-user mailing list