Categorygithub.com/botchris/go-auditrail
modulepackage
0.0.4
Repository: https://github.com/botchris/go-auditrail.git
Documentation: pkg.go.dev

# README

Go Auditrail

go test golangci-lint

Provides a simple interface for logging audit events in Go with support for multiple backends such as file, Elasticsearch, and more.

Installation

go get github.com/auditrail/go-auditrail

Usage

package main

import (
    "context"
    "fmt"
    "os"

    "github.com/botchris/go-auditrail"
)

func main() {
    // Create a new client
    client := auditrail.NewFileLogger(os.Stdout)

    // Log a message
    entry := auditrail.NewEntry("john", "order.deleted", "ordersService")

    if err := client.Log(context.TODO(), entry); err != nil {
        fmt.Println(err.Error())
    }

}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewBreakerStrategy returns a breaker that will backoff after the threshold has been tripped.
NewDiscardLogger returns a logger that discards all log entries.
NewElasticLogger creates a new ElasticSearch logger.
NewEntry creates a new log entry with the given actor, action, and module.
NewExponentialBackoff returns an exponential backoff strategy with the desired config.
NewFileLogger builds a new logger that writes log entries to the given file descriptor.
NewFilePathLogger builds a new logger that writes log entries to a file at the given path.
NewKinesisLogger builds a new logger that writes log entries to a Kinesis stream as JSON objects separated by newlines.
NewMemoryLogger creates a new MemoryLogger.
NewQueue builds a new logger queue which provides a buffer for entries to be processed asynchronously.
NewRetryer creates a new retryer that will retry failed log writes using the provided strategy.
WithQueueDropHandler sets a function that will be called when a message is dropped.
WithQueueThroughput controls the number of concurrent workers that will process messages from the queue.
WithQueueTimeout controls the maximum amount of time a worker will wait for the target logger to process a message.
WithRetryDropHandler configures the drop handler for the retryer.
WithRetryStrategy configures the retry strategy for the retryer.

# Variables

DefaultExponentialBackoffConfig provides a default configuration for exponential backoff.
ErrTrailClosed is returned when the queue is closed.

# Structs

Entry
Entry represents an audit log event.
ExponentialBackoffConfig configures backoff parameters.
MemoryLogger is a test spy that records all the logs it receives for later inspection.

# Interfaces

KinesisAPI captures the kinesis client part that we need.
Logger trail logger to which audit logs are written.
RetryStrategy defines a strategy for retrying trail writes.

# Type aliases

DropHandlerFunc is a function that will be called when a message is dropped from the queue.
QueueOption is a function that configures a queue.
RetryerOption is a function that configures a retryer.