FixAlchemy.MessageLog (FIXAlchemy v0.2.4)

View Source

A bounded record of the raw messages a session sent and received.

The log is off unless a session is started with message_log: true, and costs nothing while off. When on, a session keeps its most recent limit/0 messages in each direction combined, oldest discarded first, so the memory a session can hold is fixed no matter how long it runs.

Entries are the bytes as they went on and came off the wire, with SOH intact. Use entries/1 to read them newest first.

Summary

Functions

Discard what connection_id holds, without stopping the recording.

Stop recording for connection_id and discard what it held.

Begin recording for connection_id, discarding anything already held.

Whether connection_id is recording.

The messages held for connection_id, newest first.

How many messages a session retains.

Render an entry's bytes with SOH shown as |, for display.

Record one message for connection_id.

Types

direction()

@type direction() :: :in | :out

entry()

@type entry() :: %{
  direction: direction(),
  raw: binary(),
  at: DateTime.t(),
  session_name: FixAlchemy.SessionConfig.name()
}

Functions

clear(connection_id)

@spec clear(binary()) :: :ok

Discard what connection_id holds, without stopping the recording.

disable(connection_id)

@spec disable(binary()) :: :ok

Stop recording for connection_id and discard what it held.

enable(connection_id)

@spec enable(binary()) :: :ok

Begin recording for connection_id, discarding anything already held.

enabled?(connection_id)

@spec enabled?(binary()) :: boolean()

Whether connection_id is recording.

entries(connection_id)

@spec entries(binary()) :: [entry()]

The messages held for connection_id, newest first.

limit()

@spec limit() :: pos_integer()

How many messages a session retains.

printable(raw)

@spec printable(binary()) :: binary()

Render an entry's bytes with SOH shown as |, for display.

record(connection_id, direction, raw, session_name)

@spec record(binary() | nil, direction(), binary(), FixAlchemy.SessionConfig.name()) ::
  :ok

Record one message for connection_id.

A no-op when the log holds nothing for the connection, which is the case unless the session enabled it.