Installing the Client

The Llama Logs client can be installed directly from github.

Add the following package to your import statement and run go get

import (
  "github.com/llamalogs/llamalogs-go/llamalogs"
)

.Init(InitArgs{})

Description

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

Also starts the timer to automatically send data into the Llama Logs server on a recurring basis.

Params

Method takes an instance of InitArgs as a param.

InitArgs{} can be set with the following fields.

Param Required Type Value Description
AccountKey No string Account key from Llama Logs home page
GraphName 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

nil

Example

llamalogs.Init(InitArgs{AccountKey: "account_key_123", GraphName: "myGraph", Disabled: false})

.Log(LogArgs{})

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 an instance of LogArgs as a param.

LogArgs{} can be set 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.
IsError 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.
AccountKey No string Can pass in accountKey directly if not set in the init function
GraphName No string Can pass in graphName directly if not set in the init function

Returns

nil

Examples

llamalogs.Log(llamalogs.LogArgs{Sender: "User", Receiver: "Web Server", Message: "request params: 123"})
llamalogs.Log(llamalogs.LogArgs{Sender: "Server", Receiver: "Database", GraphName: "dbGraph", IsError: dbResponseError != nil})

.ForceSend()

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 other short lived processes.

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

Params

None

Returns

Void

Examples

llamalogs.ForceSend()