Documentation ¶
Overview ¶
Package apex provides an adapter for the popular github.com/apex/log logging library.
Example ¶
package main import ( "github.com/apex/log" adapter "github.com/axiomhq/axiom-go/adapters/apex" ) func main() { // Export "AXIOM_DATASET" in addition to the required environment variables. handler, err := adapter.New() if err != nil { log.Fatal(err.Error()) } defer handler.Close() log.SetHandler(handler) log.WithField("mood", "hyped").Info("This is awesome!") log.WithField("mood", "worried").Warn("This is no that awesome...") log.WithField("mood", "depressed").Error("This is rather bad.") }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMissingDatasetName = errors.New("missing dataset name")
ErrMissingDatasetName is raised when a dataset name is not provided. Set it manually using the SetDataset option or export "AXIOM_DATASET".
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements a log.Handler used for shipping logs to Axiom.
func New ¶
New creates a new handler that ingests logs into Axiom. It automatically takes its configuration from the environment. To connect, export the following environment variables:
- AXIOM_TOKEN
- AXIOM_ORG_ID (only when using a personal token)
- AXIOM_DATASET
The configuration can be set manually using options which are prefixed with "Set".
An API token with "ingest" permission is sufficient enough.
A handler needs to be closed properly to make sure all logs are sent by calling Handler.Close.
type Option ¶
An Option modifies the behaviour of the Axiom handler.
func SetClient ¶ added in v0.4.0
SetClient specifies the Axiom client to use for ingesting the logs.
func SetClientOptions ¶ added in v0.4.0
SetClientOptions specifies the Axiom client options to pass to axiom.NewClient which is only called if no axiom.Client was specified by the SetClient option.
func SetDataset ¶ added in v0.4.0
SetDataset specifies the dataset to ingest the logs into. Can also be specified using the "AXIOM_DATASET" environment variable.
func SetIngestOptions ¶ added in v0.4.0
SetIngestOptions specifies the ingestion options to use for ingesting the logs.