[IPython-User] Logging in new IPython
Sat Aug 6 16:59:24 CDT 2011
On Sat, Aug 6, 2011 at 14:43, Gökhan Sever <firstname.lastname@example.org> wrote:
> You already have logging option in IPython. I forgot mentioning of
> this functionality before. When I look into the sqlite database, I
> couldn't see timestamps associated with commands. However the
> classical logging in IPython allows timestamping of commands.
I've never used the IPython logging output, so I didn't know it had a
You are right that there are not timestamps associated with individual
commands in the sqlite history, they are only associated with sessions as a
whole. It would probably be valuable to add timestamps to individual
commands as well. I believe I asked for this, but was outvoted, since it
would add cost to each execution, and people would rarely be interested in
the extra information.
> So far, the following options seems the best scenario for me for
> logging the activity in IPython.
> %logstart -t -r "ipy_log.txt" global
> What is the right place to put this magic just before I start typing?
The right place is InteractiveShellApp.exec_lines in a config file:
c.InteractiveShellApp.exec_lines = ["%logstart -t -r 'ipy_log.txt' "] # or
append, if you already have other lines
> Also, can I get the same behavior via the command line interface?
There's approximately nothing you can do in a config file that you can't on
the command-line. The easiest way to start IPython with logging immediately
from the command-line is:
ipython -i --c="%logstart -t -r 'ipy_log.txt'"
'-c' is a shortcut for appending a single line to the end of exec_lines.
The '-i' prevents IPython from exiting after running the command.
(you will get the natural '-c cmd' syntax back when PR #74 reinstates
argparse for parsing)
> On Wed, Aug 3, 2011 at 10:03 PM, Gökhan Sever <email@example.com>
> > Hello,
> > Finally, I get the new Ipython running. qtconsole is up too. I
> > installed v0.11 The very first thing I have noticed is there is not
> > .ipython folder under my home directory.
> > ipython -help and ipython -help-all provides a lot of reading for
> tomorrow :)
> > I have an alias in .bashrc as:
> > # fixed after getting a single dash deprecation warning for pylab
> > alias ii='ipython --pylab'
> > Now typing "ii"
> > WARNING: `-pylab` flag has been deprecated.
> > Use `--pylab` instead, or `--pylab=foo` to specify a backend.
> > Is this warning temporary?
> > Thanks for all your efforts and especially well-documenting the new
> > More testing comes later...
> > On Wed, Aug 3, 2011 at 3:16 PM, Gökhan Sever <firstname.lastname@example.org>
> >> Hi,
> >> I tend to log my sessions and index them via full-text searching tool
> >> "recoll" along with many other files (indeed tons of them). Being able
> >> have IPython history in the form of text would make my life easier since
> >> recoll can easily crawl text files. In addition, recoll has a command
> >> tool to dump xapian database into a text file with some basic text
> >> statistics options. This way, I can easily get statistics about my most
> >> Python commands and such.
> >> I plan to upgrade my beloved IPython v0.10 to the new release tonight. I
> >> will let you know how my experience goes with the new one. Hopefully, I
> >> figure out a way to get text outputs from the sqlite saved logs.
> >> Thanks,
> >> On Wed, Aug 3, 2011 at 9:30 AM, Thomas Kluyver <email@example.com>
> >>> On 3 August 2011 16:02, Gökhan Sever <firstname.lastname@example.org> wrote:
> >>>> Thanks for the answer Thomas. Is there a way to dump the sqlite
> >>>> to a text file? Since time-stamping automatically added in the
> database, I
> >>>> don't see a particular reason for using another logging mechanism.
> >>> There's no tool for that at present, but if you feel like writing one,
> >>> shouldn't be too complex. The file is
> >>> .ipython/profile_default/history.sqlite. You can extract timestamps
> from the
> >>> session table, and then use the session number to select rows from the
> >>> history table (and the output_history table if you've turned on output
> >>> logging as well). In fact, you might be able to import
> >>> to handle loading the database.
> >>> Thanks,
> >>> Thomas
> >> --
> >> Gökhan
> > --
> > Gökhan
> IPython-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User