Installing the Client

The Llama Logs client can be installed directly through hex.

Add the following code to your mix.exs file for newest version of the client

{:llama_logs, "~> 0.1.4"}

Then run

mix deps.get

Once installed, Llama Logs should be added to the supervision tree in order to be initialized

Add this line to your children list in application.ex with your account key and graph name

{LlamaLogs, ["your_account_key", "your_graph_name"]}

There is also a third optional boolean param if you wish to disable Llama Logs. This is useful for restricting logs to only certain environments.

{LlamaLogs, ["your_account_key", "your_graph_name", true]}

The client library can then be referenced directly under the LlamaLogs namespace in your Elixir program.

No import statement is needed.

.init(paramsObject)

Description

Can be used to reset the accountKey and graphName to be used as defaults for all future calls.

Params

Method takes a single object as a param with the following fields.

Field Name Required Type Value Description
account_key No string Account key from Llama Logs home page
graph_name No string Name of graph to be used in account
disabled No string Shuts off all Llama Log functionality.
Useful for disabling in certain environments.

Returns

:ok

Example

LlamaLogs.init(%{account_key: "abc123", graph_name: "myGraph", disabled: false})

.log(paramsObject)

Description

Logs an event that will be sent to the visual Llama Log graph on the website.

Logs are aggregated client side and then sent in as a batch to the server on a repeating interval.

Params

Method takes a single object as a param with the following fields.

Field Name Required Type Value Description
sender Yes string The name of the component to show the event originating from in the graph
receiver Yes string The name of the component to show the event going to in the graph
message No string Arbitrary string message that can be attached to a log. A random sampling of the messages will be displayed when a log is hovered in the graph.
is_error No boolean A boolean expression that is evaluated at runtime to determine if the log should be recorded as an error or regular log event.
account_key No string Can pass in accountKey directly if not set in the init function
graph_name No string Can pass in graphName directly if not set in the init function

Returns

:ok

Examples

LlamaLogs.log(%{sender: "User", receiver: "Web Server", message: "request params: 123"})
LlamaLogs.log(%{sender: "Server", receiver: "Database", graph_name: "secondary-sub-graph"})

.force_send()

Description

A synchronous method to make an https request to send the aggregated logs and stats into the Llama Logs server.

This should be used to send in data in cases where the interval timer might not be called.

Such as at the end of a cloud function, or in the case of a caught process error.

Each account has rate limits so forcing sends in a loop will trigger the limits.

Params

None

Returns

:ok

Examples

LlamaLogs.force_send()