package
0.20.2
Repository: https://github.com/axiomhq/axiom-go.git
Documentation: pkg.go.dev

# README

Axiom Go Adapter for log/slog

Adapter to ship logs generated by slog to Axiom.

Quickstart

Follow the Axiom Go Quickstart to install the Axiom Go package and configure your environment.

Import the package:

// Imported as "adapter" to not conflict with the "log/slog" package.
import adapter "github.com/axiomhq/axiom-go/adapters/slog"

You can also configure the adapter using options passed to the New function:

handler, err := adapter.New(
    adapter.SetDataset("AXIOM_DATASET"),
)

To configure the underlying client manually either pass in a client that was created according to the Axiom Go Quickstart using SetClient or pass client options to the adapter using SetClientOptions.

import (
    "github.com/axiomhq/axiom-go/axiom"
    adapter "github.com/axiomhq/axiom-go/adapters/slog"
)

// ...

handler, err := adapter.New(
    adapter.SetClientOptions(
        axiom.SetPersonalTokenConfig("AXIOM_TOKEN", "AXIOM_ORG_ID"),
    ),
)

[!IMPORTANT] The adapter uses a buffer to batch events before sending them to Axiom. This buffer must be flushed explicitly by calling Close. Checkout the example.