Howdy, Stranger!

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

Supported by

[open] switching between two log files

edited February 2015 in OpenSesame

Hi everyone,

Background:
I'm finishing up an experiment that investigates the effect of masked and unmasked cues. I'm already logging the experiment-related variables, like response_time, variables defined in loops, inline-script variables, etc. Tracking presentation timing is important to us, so I've started to log most of the time_ variables as well. Unfortunately, this is starting to make the log files very unwieldy. To simplify the files, I'd like to split log file into two separate log files -- one .csv where all the timing data will be recorded (which I will only sometimes use), another .csv where all the all experiment variables will be recorded (which I will always use).

Tl;dr question:
What I'd like to do is have two loggers and create two log files. At the conclusion of a trial sequence in my loop, I'd like to have logger #1 write to file #1, then logger #2 write to file #2. Then repeat across trials.

I'm not sure how to do this. I've been working with a mini-experiment to test out various things:

Here's the content of makePaths at the start of the experiment:

location = 'uci'
path_time = 'time_' + location + '_' + str(self.get('subject_nr')) + '.csv'
path_vars = 'vars_' + location + '_' + str(self.get('subject_nr')) + '.csv'

I've looked through the forum and found a lot of code like this:

import os
#close current logfile
exp._log.close()
#set new path
exp.logfile = path_NAME
#open new logfile
exp._log = None
exp.init_log()

so I've been working with this code in each setPath_ script (setPath_time uses path_time where path_NAME is, etc.).

If I run this as written above, then I only get information in the vars_uci_0.csv file, and only for the last trial. I've tried commenting out various lines in the setPath_ scripts, but can't get the functionality I'm looking for.

I need to find a way to leave both files open always, and just have the the loggers flexibly switch which file they're writing to. No idea how to do that though, if it's possible.

I appreciate any help you guys can provide!

--beth

(Also: I know I could use python to open two files, then write to each of them in turn, etc. However, with the number of variables I'd like to record, I think this would be a frustrating option.)

Comments

  • edited 3:59AM

    Hi Beth,

    That's an interesting question. What you could do is hack into the OpenSesame internals, and replace the logger's log() function by your own function. Let's assume that your logger is called custom_logger, then you could this as follows (at the beginning of the experiment):

    def my_custom_log(msg):
        # A function that logs text messages in a
        # customized way.
        print(msg)
    
    # Assign a custom `log` function
    exp.items['custom_logger'].log = my_custom_log
    

    Next, it would be a matter if implementing my_custom_log() such that it writes the data to the file of your choosing.

    Cheers!
    Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games