# Detailed log files

**Log files** are created as you begin to run a protocol, and record the timing of every event in the study session. One of the steps before running a protocol is to [specify](../../running-protocols/how-to-run-a-protocol#saving-the-event-log-file) the save location and name of the log file for that session.

## What is in a log file?

### Header section

The first portion of any log file contains information about the session, most of it [input by the experimenter](../../running-protocols/how-to-run-a-protocol#filling-in-session-information) in the blanks for subject number, date of birth, experimenter name/initials, and comments. It also indicates which version of BITTSy was used to run the protocol, the name and location of the protocol file, and the test date and run time. This information is saved to the log file immediately upon clicking to run the protocol.

An example of the header section of a log file is below (personal information has been replaced with ▢ symbols).

![](https://2713219577-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpdVQ3UaqxmZSuMoje5%2F-MB1R6H9qrreaIAf7US5%2F-MB4mGh-rGKfDwqlgy4J%2Flog_header.png?alt=media\&token=a60aa5fb-d208-4d96-a483-65eebc2f0f4e)

### Experiment settings

The next section of a log file records the [experiment settings](../creating-protocols/optional-experiment-settings) that are important for analyzing looking time and habituation. These can be a useful reference, especially when default values are used for some settings, as they may or may not be explicitly stated in the protocol file itself.

In the example below, the protocol did not specify any changes from the default settings. None of the [habituation-specific settings](../creating-protocols/habituation/setting-criteria) were utilized in this study, but their values are consistently recorded in log files.

![](https://2713219577-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpdVQ3UaqxmZSuMoje5%2F-MB1R6H9qrreaIAf7US5%2F-MB4nCH9d1d86P4bDAWG%2Flog_settings.png?alt=media\&token=185ddb17-d109-40c9-a7a8-24e7c6c7fe87)

### Experiment events

The main contents of the log file follow these two opening sections, and detail _what_ happened in the study session and _when_.&#x20;

The example log below is from the start of a headturn preference study similar to [this example protocol](../creating-protocols/example-protocols/headturn-preference-paradigm-example).&#x20;

![](https://2713219577-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpdVQ3UaqxmZSuMoje5%2F-MB1R6H9qrreaIAf7US5%2F-MB4qU_IZtxQnK1AwQ2d%2Flog_main.png?alt=media\&token=e3a4757d-2c13-41b6-a5ea-8524a05f3d61)

Every line in a log file begins with a timestamp, accurate to the nearest millisecond. These are used by the [reporting module](the-reporting-module) to generate [summaries](standard-reports) of the events in the study session and calculate looking times. Some lines (particularly those for beginning the presentation of stimuli) also end in a number denoting the elapsed milliseconds since the start of the experiment, with an even higher degree of accuracy.

As soon as the protocol file begins execution, we define the start of a phase (called "Train"), and start the center light blinking. This continues until the experimenter presses the key C. (In the log below, you can see that it takes the infant a few seconds to orient - note the gap in timestamps between the first "stimuli light blink" line and "C pressed".) Then the center light is turned off, and we randomly select a side (LEFT or RIGHT) from a group called `trainingsides`, and start to blink the light on that side (here, LEFT was chosen).

There are a _lot_ of events to log in a typical study - in the example above, we logged 20 before even starting the first trial! BITTSy does not make any assumptions about what information will be important or unimportant for later analyses, so we opt for logging all possible information. As a consequence, log files often are quite long, and not terribly human-readable. This is why we supply a set of [standard reporting functions](standard-reports) that read log files and output commonly-used measures suitable for analyzing HPP, preferential looking, central fixation, and habituation studies.

## Important notes about log files

While you'll most often be working with summary reports rather than looking at log files directly, there are some important things to understand about how log files are generated and what they record.

1. **Log files remain open throughout a session, and events are written to the log in real time (or with a slight delay).**\
   Writing to log files _as_ events happen, rather than generating a full log file after the run, helps ensure that as much information on a study session as possible is available in case something unexpected occurs, such as encountering an error. Sometimes the most recent few long lines are held in a "buffer" and written to the log file in batches. The log file is not finished and closed until execution ends. This means it is important to always end execution properly (by pressing Escape) before closing out of BITTSy - it ensures that the final batch of lines can be written to the log.\

2. **Header information is written immediately, and cannot subsequently be changed within the user interface's text boxes.**\
   The text fields on the user interface for the subject number, date of birth, experimenter, and comments should all be filled in with any necessary information _prior_ to running the study so that they are included in the log file.\

3. **The last lines of a log file denote how execution stopped (**_**ended**_**, by reaching the end of the protocol;&#x20;**_**prematurely**_**, by the experimenter** **pressing the Escape key; or&#x20;**_**unexpectedly**_**, by BITTSy encountering an error)**\
   This can be reviewed to verify that an experiment ran fully to completion, especially in the case of missing lab-internal notes from an experimenter about how a session went. Note that the line specifying an _unexpected_ end can only be written by BITTSy if the error is not so critical that it causes the program to close or lose access to the log file. Execution errors will typically end in BITTSy displaying a pop-up with an explanation of the error as the session is ended. (For example, this will occur if your protocol attempts to make a selection from a group in which no items are eligible for selection.) However, issues such as closing out of BITTSy without first ending the experiment, having your computer suddenly shut down due to power loss, or encountering an [uncaught validation error](../../running-protocols/how-to-run-a-protocol#validating-a-protocol) that causes BITTSy to crash can result in this final line not being written to the log (see #1 above). Any log file that is missing a line denoting how the experiment ended should be assumed to be _unexpected,_ and may be additionally missing experiment events that happened immediately beforehand.
