LogflareEx.Client (logflare_ex v0.2.0-dev.980340db)

A LogflareEx.Client contains all configuration used for making API requests, whether batched or not.

Application-level Configuration

Application-wide configuration can be set in config.exs:

config :logflare_ex,
  api_key: "...",
  source_token: "..."

Runtime Configuration

All configuration options can be overridden at runtime. This is through the use of the LogflareEx.Client struct.

To create a new client with a custom configuration, use LogflareEx.client/1:

# To create a client from the application-level configuration.
iex> default_client = LogflareEx.client()
%LogflareEx.Client{...}

# To create a client with runtime overrides
iex> client = LogflareEx.client(source_token: "...")
%LogflareEx.Client{...}

# use the runtime client
iex> LogflareEx.send_batched_event(client, %{...})
:ok

Options

For every configuration, either :source_token or :source_name must be provided.

  • :api_key: Required. Public API key.
  • :api_url: Custom Logflare endpoint, for self-hosting. Defaults to https//api.logflare.app.
  • :source_token: Source UUID. Mutually exclusive with :source_name
  • :source_name: Source name. Mutually exclusive with :source_token
  • :on_error: mfa callback for handling API errors. Must be 1 arity.
  • :auto_flush: Used for batching. Enables automatic flushing. If disabled, LogflareEx.flush/1 must be called.
  • :flush_interval: Used for batching. Flushes cached events at the provided interval.
  • :batch_size: Used for batching. It is the maximum number of events send per API request.

Summary

Types

t()

Logflare client

Types

@type t() :: %LogflareEx.Client{
  api_key: String.t(),
  api_url: String.t(),
  auto_flush: :boolean,
  batch_size: non_neg_integer(),
  flush_interval: non_neg_integer(),
  on_error: list() | mfa(),
  source_name: String.t() | nil,
  source_token: String.t() | nil,
  tesla_client: Tesla.Client.t()
}

Logflare client

Functions

Link to this function

get_config_value(key)

Link to this function

new(opts \\ [])

@spec new(opts()) :: t()
Link to this function

validate_client(arg1)