ring_logger v0.8.1 RingLogger.Client View Source

Interact with the RingLogger

Link to this section Summary

Functions

Attach the current IEx session to the logger. It will start printing log messages.

Returns a specification to start this module under a supervisor.

Fetch the current client configuration.

Update the client configuration.

Detach the current IEx session from the logger.

Helper method for formatting log messages per the current client's configuration.

Run a regular expression on each entry in the log and print out the matchers.

Get the next set of the messages in the log.

Reset the index into the log for tail/1 to the oldest entry.

Format and save all log messages to the specified path.

Start up a client GenServer. Except for just getting the contents of the ring buffer, you'll need to create one of these. See configure/2 for information on options.

Stop a client.

Get the last n messages.

Link to this section Functions

Specs

attach(GenServer.server()) :: :ok

Attach the current IEx session to the logger. It will start printing log messages.

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

config(pid()) :: [RingLogger.client_option()]

Fetch the current client configuration.

Link to this function

configure(client_pid, config)

View Source

Specs

configure(GenServer.server(), [RingLogger.client_option()]) :: :ok

Update the client configuration.

Options include:

  • :io - Defaults to :stdio
  • :colors -
  • :metadata - A KV list of additional metadata
  • :format - A custom format string, or a {module, function} tuple (see https://hexdocs.pm/logger/master/Logger.html#module-custom-formatting)
  • :level - The minimum log level to report.
  • :module_levels - a map of log level overrides per module. For example, %{MyModule => :error, MyOtherModule => :none}
  • :application_levels - a map of log level overrides per application. For example, %{:my_app => :error, :my_other_app => :none}. Note log levels set in :module_levels will take precedence.
Link to this function

configure_module_levels(config)

View Source

Specs

detach(GenServer.server()) :: :ok

Detach the current IEx session from the logger.

Link to this function

format(client_pid, message)

View Source

Specs

format(GenServer.server(), RingLogger.entry()) :: :ok

Helper method for formatting log messages per the current client's configuration.

Link to this function

grep(client_pid, regex_or_string, opts \\ [])

View Source

Specs

grep(GenServer.server(), String.t() | Regex.t(), [RingLogger.client_option()]) ::
  :ok | {:error, term()}

Run a regular expression on each entry in the log and print out the matchers.

Supported options:

  • :pager - an optional 2-arity function that takes an IO device and what to print
Link to this function

next(client_pid, opts \\ [])

View Source

Specs

next(GenServer.server(), keyword()) :: :ok | {:error, term()}

Get the next set of the messages in the log.

Supported options:

  • :pager - an optional 2-arity function that takes an IO device and what to print

Specs

reset(GenServer.server()) :: :ok

Reset the index into the log for tail/1 to the oldest entry.

Specs

save(GenServer.server(), Path.t()) :: :ok | {:error, term()}

Format and save all log messages to the specified path.

Link to this function

start_link(config \\ [])

View Source

Specs

start_link(keyword()) :: GenServer.on_start()

Start up a client GenServer. Except for just getting the contents of the ring buffer, you'll need to create one of these. See configure/2 for information on options.

Specs

stop(GenServer.server()) :: :ok

Stop a client.

Link to this function

tail(client_pid, n, opts \\ [])

View Source

Get the last n messages.

Supported options:

  • :pager - an optional 2-arity function that takes an IO device and what to print