Need to have an OpenSesame expert by your side 24/7? Subscribe to Sigmund!
Log functions
instance log
The log
object provides data logging. A log
object is created
automatically when the experiment starts.
Example
# Write one line of text
log.write('My custom log message')
# Write all variables
log.write_vars()
close()
Closes the current log.
Example
log.close()
open(path)
Opens the current log. If a log was already open, it is closed automatically, and re-opened.
Parameters
- path: The path to the current logfile. In most cases (unless) a custom log back-end is used, this will be a filename.
Example
# Open a new log
log.open('/path/to/new/logfile.csv')
write(msg, newline=True)
Write one message to the log.
Parameters
- msg: A text message. When using Python 2, this should be either
unicode
or a utf-8-encodedstr
. When using Python 3, this should be eitherstr
or a utf-8-encodedbytes
. - newline: Indicates whether a newline should be written after the message.
Example
# Write a single string of text
log.write(f'time = {clock.time()}')
write_vars(var_list=None)
Writes variables to the log.
Parameters
- var_list: A list of variable names to write, or None to write all variables that exist in the experiment.
Example
# Write all variables to the logfile
log.write_vars()