Search documentation of grizzly

# View Source Grizzly.Trace (grizzly v7.4.2)

Module that tracks the commands that are sent and received by Grizzly

The trace will hold in memory the last 300 messages. If you want to generate a log file of the trace records you use `Grizzly.Trace.dump/1`.

The log format is:

    timestamp source destination sequence_number command_name command_parameters

If you want to list the records that are currently being held in memory you can use `Grizzly.Trace.list/0`.

If you want to start traces from a fresh start you can call `Grizzly.Trace.clear/0`.

# Summary

## Types

dest()
format()
log_opt()
src()
trace_opt()

## Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

clear(name \\ __MODULE__)

Reset the trace buffer.

dump(file, format \\ :text)

Dump trace records into a file. See `format/2` for the available formats.

format(records, format \\ :text)

Serialize a list of trace records into a binary. The format can be one of

list(name \\ __MODULE__)

List all records in the trace buffer.

log(binary, opts \\ [])

See `log/3`

log(name, binary, opts)

Add a record to the trace buffer.

print()
print(records)
print(records, fmt)

Write trace records to standard out. See `format/2` for the available formats.

record_keepalives(name \\ __MODULE__, enabled? \\ true)

Enable or disable logging of keepalive frames.

resize(name \\ __MODULE__, size)

Change the max size of the trace buffer from the default of 300.

start_link(opts \\ [])

Start the trace server

# Types

Link to this type

# dest()

View Source

    @type dest() :: String.t()

Link to this type

# format()

View Source

    @type format() :: :text | :term

Link to this type

# log_opt()

View Source

    @type log_opt() :: {:src, src()} | {:dest, dest()}

Link to this type

# src()

View Source

    @type src() :: String.t()

Link to this type

# trace_opt()

View Source

    @type trace_opt() ::
      {:name, atom()} | {:size, pos_integer()} | {:record_keepalives, boolean()}

# Functions

Link to this function

# child_spec(init_arg)

View Source

Returns a specification to start this module under a supervisor.

See `Supervisor`.

Link to this function

# clear(name \\ __MODULE__)

View Source

    @spec clear(GenServer.name()) :: :ok

Reset the trace buffer.

Link to this function

# dump(file, format \\ :text)

View Source

    @spec dump(binary(), format()) :: :ok | {:error, atom()}

Dump trace records into a file. See `format/2` for the available formats.

Link to this function

# format(records, format \\ :text)

View Source

    @spec format([Grizzly.Trace.Record.t()], format()) :: binary()

Serialize a list of trace records into a binary. The format can be one of:

- `:text` - Each record is on a new line and is formatted as `timestamp source destination sequence_number command_name command_binary`. This is the default format.

- `:raw` - Each record is on a new line and is formatted as `timestamp source -> destination: binary`.

- `:term` - The trace is serialized as a list of `Record.t()` structs in Erlang external term format. This is useful if you want to load the trace on another machine.

Link to this function

# list(name \\ __MODULE__)

View Source

    @spec list(GenServer.name()) :: [Grizzly.Trace.Record.t()]

List all records in the trace buffer.

Link to this function

# log(binary, opts \\ [])

View Source

    @spec log(binary(), [log_opt()]) :: :ok

See `log/3`

Link to this function

# log(name, binary, opts)

View Source

    @spec log(GenServer.name(), binary(), [log_opt()]) :: :ok

Add a record to the trace buffer.

Link to this function

# print()

View Source

    @spec print() :: :ok

Link to this function

# print(records)

View Source

    @spec print([Grizzly.Trace.Record.t()] | format()) :: :ok

Link to this function

# print(records, fmt)

View Source

    @spec print([Grizzly.Trace.Record.t()], format()) :: :ok

Write trace records to standard out. See `format/2` for the available formats.

Link to this function

# record_keepalives(name \\ __MODULE__, enabled? \\ true)

View Source

    @spec record_keepalives(GenServer.name(), boolean()) :: :ok

Enable or disable logging of keepalive frames.

Link to this function

# resize(name \\ __MODULE__, size)

View Source

    @spec resize(GenServer.name(), pos_integer()) :: :ok

Change the max size of the trace buffer from the default of 300.

Link to this function

# start_link(opts \\ [])

View Source

    @spec start_link([trace_opt()]) :: GenServer.on_start()

Start the trace server