utils

package
v0.0.0-...-520c4d9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: GPL-3.0 Imports: 13 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

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

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

func JSON

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

func MatchAllTags

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

MatchAllTags returns true if all required tags exist in actualTags 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 ParseIntOrDefault

func ParseIntOrDefault(input string, def int) int

func ParseTagString

func ParseTagString(input string) map[string]string

func SafeCopyTags

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

SafeCopyTags ensures that meta.Tags is never nil. It returns a non-nil map[string]string for tags, 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