utils

package
v0.0.0-...-acff829 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2025 License: GPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Access

func Access(format string, args ...any)

ACCESS LOGGING (special traffic / auth / API hits)

func Debug

func Debug(format string, args ...any)

DEBUG

func Error

func Error(format string, args ...any)

ERROR

func ExtractLogLabels

func ExtractLogLabels(meta *model.LogMeta) map[string]string

ExtractLogLabels builds labels from model.LogMeta.

func ExtractStandardLabels

func ExtractStandardLabels(meta *model.Meta) map[string]string

ExtractStandardLabels builds a consistent map of labels from model.Meta.

func Fatal

func Fatal(format string, args ...any)

FATAL

func GenerateEndpointID

func GenerateEndpointID(meta *model.Meta) string

GenerateEndpointID creates a unique identifier for an endpoint based on its metadata.

func GetClientIP

func GetClientIP(r *http.Request) string

func GetLocalIP

func GetLocalIP() string

GetLocalIP retrieves the local IP address of the machine running the gosight agent.

func GetNamespace

func GetNamespace(meta *model.Meta) string

GetNamespace returns the namespace for the endpoint based on its metadata.

func GetWorkingDir

func GetWorkingDir() string

GetWorkingDir returns the current working directory

func Info

func Info(format string, args ...any)

INFO (normal server app messages)

func InitLogger

func InitLogger(appLogFile, errorLogFile, accessLogFile, debugLogFile, logLevel string) error

InitLogger initializes the logging system with specified log files and log level.

func JSON

func JSON(w http.ResponseWriter, status int, data interface{})

func MatchAllLabels

func MatchAllLabels(required map[string]string, actual map[string]string) bool

MatchAllLabels returns true if all required Labels exist in actualLabels and match.

func MergeMaps

func MergeMaps(base, override map[string]string) map[string]string

func Must

func Must(label string, err error)

MUST (fatal init failures)

func NewUUID

func NewUUID() string

NewUUID returns a new UUID string.

func ParseIntOrDefault

func ParseIntOrDefault(input string, def int) int

func ParseTagString

func ParseTagString(input string) map[string]string

func SafeCopyLabels

func SafeCopyLabels(meta *model.Meta) map[string]string

SafeCopyLabels ensures that meta.Labels is never nil. It returns a non-nil map[string]string for Labels, even if it was nil originally.

func Truncate

func Truncate(s string, max int) string

Truncate safely trims a string to the given length in runes. If truncation occurs, it appends "…" (ellipsis).

func Warn

func Warn(format string, args ...any)

WARNING

func WriteJSON

func WriteJSON(filename string, v interface{}) error

WriteJSON dumps any value to a JSON file for inspection. filename is relative to current directory. Value must be JSON serializable.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL