[IPython-dev] Logging commands using the %logstart magic

Phil Elson pelson.pub at gmail.com
Tue Nov 18 12:53:43 EST 2014


Thanks Wes,

I explicitly am not asking about the notebook, which I know does this
admirably (and is what I would use too).
I've been asked for command line behaviour from the (I)Python terminal
which records input and output in an almost exact fashion to that of
"%logstart", except logstart does not store stdout, only IPython displayed
output.

I haven't yet dug into the possibility of redirecting stdout to IPython
out, or indeed directly out to file with the associated input, but I
imagine there will be some buffering issues that I'd like not to have to
deal with, if the functionality already exists in IPython.

Cheers,

On 18 November 2014 07:28, Wes Turner <wes.turner at gmail.com> wrote:

> IPython notebook format docs:
>
>
> IPython notebook nbformat v4 JSONSchema:
>> https://github.com/minrk/ipython/blob/nbformat4/IPython/nbformat/v4/nbformat.v4.schema.json
>> Metadata Documentation:
>> https://github.com/minrk/ipython/blob/nbformat4/docs/source/notebook/nbformat.rst#metadata
>> JSON-LD JSONSchema:
>> https://github.com/json-ld/json-ld.org/blob/master/schemas/jsonld-schema.json
>
>
> ( https://youtrack.jetbrains.com/issue/PY-14326 )
>
> On Mon, Nov 17, 2014 at 10:47 AM, Phil Elson <pelson.pub at gmail.com> wrote:
>
>> I'm trying to replicate functionality found in IDL which generates
>> something called "journal" files. Journal files in IDL are essentially a
>> log of commands alongside the (commented out) output and themselves produce
>> valid code.
>>
>> IPython's %logstart with the "-o" flag is almost exactly what I need,
>> except it doesn't seem to record standard out (only IPython out):
>>
>> > ipython
>> Python 2.7.6
>> IPython 2.2.0 -- An enhanced Interactive Python.
>>
>> In [1]: %logstart -o testing_logging.py
>> Activating auto-logging. Current session state plus future input saved.
>> Filename       : testing_logging.py
>> Mode           : backup
>> Output logging : True
>> Raw input log  : False
>> Timestamping   : False
>> State          : active
>>
>> In [2]: print 'Hello logging world non-IPython out!'
>> Hello logging world non-IPython out!
>>
>> In [3]: 'Hello logging world IPython out!'
>> Out[3]: 'Hello logging world IPython out!'
>>
>> In [4]: exit
>>
>> The resulting file looks like:
>>
>> # IPython log file
>>
>> print 'Hello logging world non-IPython out!'
>> 'Hello logging world IPython out!'
>> #[Out]# 'Hello logging world IPython out!'
>> exit()
>>
>> Essentially I'd like the contents of the second input to be recorded as
>> it is for the third.
>>
>> Before I go hacking around with the magic and sys.stdout, does anybody
>> have a quick solution to this?
>>
>> Thanks,
>>
>> Phil
>>
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
>
> --
> Wes Turner
> https://westurner.github.io/
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20141118/bdc5d73d/attachment.html>


More information about the IPython-dev mailing list