> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Log messages

> Subscribe to Solana program log messages with addLog() — filter by program ID and message kind.

<h4 id="add-log">
  `addLog(options)`
</h4>

Get log messages emitted by some *or all* programs in the network. `options` has the following structure:

```typescript theme={"system"}
{
  // data requests
  where?: {
    programId?: string[]
    kind?: ('log' | 'data' | 'other')[]
  }

  // related data retrieval
  include?: {
    transaction?: boolean
    instruction?: boolean
  }

  range?: {
    from: number,
    to?: number
  }
}
```

Data requests:

* `programId`: the set of addresses of programs emitting the logs. Leave it undefined to subscribe to logs from all programs in the network.
* `kind`: the set of values of `kind`.

With `transaction = true` the processor will retrieve all parent transactions and add them to the `transactions` iterable within the [block data](./context-interfaces). You can also call `augmentBlock()` from `@subsquid/solana-objects` on the block data to populate the convenience reference fields like `log.transaction`. Similarly, `instruction = true` retrieves the instructions that emitted the matching logs.

Note that logs can also be requested by the other `DataSourceBuilder` methods as related data.

Selection of the exact fields to be retrieved for each log and its optional parent transaction is done with the `setFields()` method documented on the [Field selection](./field-selection) page.

## Examples

Fetch all log messages emitted by the Pyth push oracle program, together with the instructions that emitted them:

```typescript theme={"system"}
const dataSource = new DataSourceBuilder()
  .setPortal('https://portal.sqd.dev/datasets/solana-mainnet')
  .addLog({
    where: {
      programId: [PYTH_PUSH_ORACLE_PROGRAM_ID]
    },
    include: {
      instruction: true
    },
    range: {
      from: 241_000_000
    }
  })
  .build()
```
