# `Mobius.EventLog`
[🔗](https://github.com/mobius-home/mobius/blob/v0.8.0/lib/mobius/event_log.ex#L1)

API for working with the event log

# `opt`

```elixir
@type opt() ::
  {:from, integer()}
  | {:to, integer()}
  | {:instance, Mobius.instance()}
  | {:group, atom()}
```

Options to query the event log

* `:from` - the unix timestamp (in seconds) to start listing events from
* `:to` - the unix timestamp (in seconds) to list events until
* `:instance` - the Mobius instance to query (defaults to `:mobius`)
* `:group` - only list events that belong to this event group

# `serialize_opt`

```elixir
@type serialize_opt() :: {:compression_level, 0..9}
```

Options for serializing the event log

* `:compression_level` - the zlib level (`0..9`) used to compress the payload,
  defaults to `9`. `0` disables compression.

# `clear`

```elixir
@spec clear([opt()]) :: :ok
```

Clear the event log

Empties the in-memory event log and removes the persisted event log file
for the instance.

# `events_to_binary`

```elixir
@spec events_to_binary([Mobius.Event.t()], [serialize_opt()]) :: binary()
```

Turn a list of Events into a binary

# `list`

```elixir
@spec list([opt()]) :: [Mobius.Event.t()]
```

List the events in the event log

# `parse`

```elixir
@spec parse(binary()) :: {:ok, [Mobius.Event.t()]} | {:error, atom()}
```

Parse the Mobius binary formatted event log

# `save`

```elixir
@spec save([opt()]) :: :ok | {:error, reason :: term()}
```

Save the current state of the event log to disk

The configured compression level for the instance is applied by the events
server when it writes the file.

# `to_binary`

```elixir
@spec to_binary([opt() | serialize_opt()]) :: binary()
```

Return the event log in the Mobius binary format

---

*Consult [api-reference.md](api-reference.md) for complete listing*
