Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Multiple Log files

Hi all,

Is there an easy way to create multiple loggers using the "log" object in opensesame? I use python scripting, and right now the log is automatically initialized and then I can output data to it using the "log.write_vars" function.

My issue is the following: Within an experiment, I would like to give a survey, then run a task, then give another survey. I would like for there to be 3 logs upon completion – 1 for each of the surveys and 1 for the task data. I could of course create csv's and write them out with python functions, but I was wondering if there is another way to do it more conveniently using opensesame's functionality.

Any help would be appreciated!

Best,
Nate

Comments

  • Hi Nate,

    Yes, that's possible. You can create multiple log objects that each write to a different. For example like so:

    from openexp.log import log as log_factory
    
    custom_log_1 = log_factory(exp, path='custom_log_1.csv')
    custom_log_1.write_vars()
    
    custom_log_2 = log_factory(exp, path='custom_log_2.csv')
    custom_log_2.write_vars()
    

    Here, custom_log_1 and custom_log_2 are both regular log objects as documented here:

    Does that answer your question?

    Cheers,
    Sebastiaan

  • Hi Sebastiaan,

    Thanks so much for the quick response! And yes, this is exactly what I was looking for. I figured that it could be done in OpenSesame – this will be much cleaner than trying to do it with standard python libraries. :smile:

    Best,
    Nate

Sign In or Register to comment.