Star us on GitHub
Star
Menu

Using highlight.io without a framework in Elixir

Learn how to set up highlight.io without a framework.

1

Configure client-side Highlight. (optional)

If you're using Highlight on the frontend for your application, make sure you've initialized it correctly and followed the fullstack mapping guide.

2

Install the Highlight Elixir SDK.

Add Highlight to your mix.exs file.

defp deps do [ ... {:highlight, "~> 0.1"} ] end
Copy
3

Initialize the Highlight Elixir SDK.

Highlight.init/0 initializes the SDK.

Highlight.init()
Copy
4

Record exceptions.

Highlight.record_exception/4 can be used to explicitly record any exception.

try do # some code that may raise an error rescue exception -> Highlight.record_exception(exception, %Highlight.Config{ project_id: "your_project_id", service_name: "your_service_name", service_version: "1.0.0" }, "session_12345", "request_67890") end
Copy
5

Verify your errors are being recorded.

Now that you've set up the SDK, you can verify that the backend error handling works by sending an error in. Visit the highlight errors page and check that backend errors are coming in.

6

Set up your highlight.io SDK.

First, make sure you've followed the backend getting started guide.

7

Import the Logger module.

Highlight works with the Logger module to make logging easier.

require Logger
Copy
8

Call the logging facades.

Highlight.init/0 automatically installs a logging backend, so you can call any of the Logger module's functions to emit logs.

Logger.debug("This is a debug!") Logger.info("This is an info!") Logger.notice("This is a notice!") Logger.warning("This is a warning!") Logger.error("This is an error!")
Copy
9

Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.