logz

package
v18.0.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: MIT Imports: 15 Imported by: 0

README

The logz package

The logz package should be used to re-use existing log attributes (slog.Attr) and helpers. New log fields can be added in case they don't drag in any new dependency. In case the log field requires a new dependency, you should define the log field name in fields.go and define the slog.Attr helper in the module where it's used.

Log field names

Log field names must be in snake_case.

Documentation

Index

Constants

View Source
const (
	AgentConfig = "agent_config"
	ApplyEvent  = "apply_event"
)

Variables

This section is empty.

Functions

func AgentID

func AgentID(agentID int64) slog.Attr

func Attempt

func Attempt(attempt int) slog.Attr

func CommitID

func CommitID(commitID string) slog.Attr

func DurationInMilliseconds

func DurationInMilliseconds(duration time.Duration) slog.Attr

func Error

func Error(err error) slog.Attr

func EventHandler

func EventHandler(name string) slog.Attr

func EventID

func EventID(id string) slog.Attr

func EventType

func EventType(typ string) slog.Attr

func FlowScript

func FlowScript(path string) slog.Attr

func FullReconciliationInterval

func FullReconciliationInterval(interval time.Duration) slog.Attr

func GRPCMethod

func GRPCMethod(method string) slog.Attr

func GRPCService

func GRPCService(service string) slog.Attr

func GV

func GV(gvr schema.GroupVersion) slog.Attr

func GVR

func GatewayURL

func GatewayURL(gatewayURL string) slog.Attr

func GitRepositoryURL

func GitRepositoryURL(url string) slog.Attr

func InventoryName

func InventoryName(name string) slog.Attr

func InventoryNamespace

func InventoryNamespace(namespace string) slog.Attr

func IsScriptPrint

func IsScriptPrint() slog.Attr

func IsWebSocket

func IsWebSocket(isWebSocket bool) slog.Attr

func K8sObjectName

func K8sObjectName(name string) slog.Attr

func K8sObjectNamespace

func K8sObjectNamespace(name string) slog.Attr

func LabelSelector

func LabelSelector(selector string) slog.Attr

func LazyValue

func LazyValue(key string, val func() slog.Value) slog.Attr

func ListenerName

func ListenerName(name string) slog.Attr

func ModuleName

func ModuleName(name string) slog.Attr

GitLab-kas or agentk module name.

func Msg

func Msg(msg string) slog.Attr

func NamespacedName

func NamespacedName(n string) slog.Attr

func NetAddress

func NetAddress(listenAddress string) slog.Attr

func NetAddressFromAddr

func NetAddressFromAddr(addr net.Addr) slog.Attr

func NetNetwork

func NetNetwork(listenNetwork string) slog.Attr

func NetNetworkFromAddr

func NetNetworkFromAddr(addr net.Addr) slog.Attr

func NumberOfEventHandlers

func NumberOfEventHandlers(n int) slog.Attr

func ObjectKey

func ObjectKey(objKey string) slog.Attr

func PartialReconciliationInterval

func PartialReconciliationInterval(interval time.Duration) slog.Attr

func PayloadSizeInBytes

func PayloadSizeInBytes(size int) slog.Attr

func PodName

func PodName(podName string) slog.Attr

func PodNamespace

func PodNamespace(podNamespace string) slog.Attr

func PodStatus

func PodStatus(podStatus string) slog.Attr

func ProjectID

func ProjectID(projectID string) slog.Attr

ProjectID is the human-readable GitLab project path (e.g. gitlab-org/gitlab).

func ProjectIDN

func ProjectIDN(projectID int64) slog.Attr

ProjectIDN is the human-readable GitLab project numeric ID.

func ProjectsToReconcile

func ProjectsToReconcile(p sets.Set[string]) slog.Attr

func ProtoJSONValue

func ProtoJSONValue(key string, value proto.Message) slog.Attr

func Reason

func Reason(reason string) slog.Attr

func RedisKey

func RedisKey(key []byte) slog.Attr

Use for any keys in Redis.

func RemovedHashKeys

func RemovedHashKeys(n int) slog.Attr

func RequestID

func RequestID(requestID string) slog.Attr

func StatusCode

func StatusCode(code int32) slog.Attr

func StringSet

func StringSet(key string, val sets.Set[string]) slog.Attr

func Strings

func Strings(key string, val []string) slog.Attr

func TargetNamespace

func TargetNamespace(namespace string) slog.Attr

func ToSlogAttr

func ToSlogAttr(field fieldz.Field) slog.Attr

func ToSlogAttrs

func ToSlogAttrs(fields []fieldz.Field, extraAttrs ...slog.Attr) []any

ToSlogAttrs converts fieldz.Field to slog.Attr This function is useful to easily log all fieldz.Field. The fieldz.AgentIDFieldName is ignored because our loggers are already equipped with agent ids and we do not want to duplicate the key in the log message. Returns []any and not []slog.Attr so that the result can be used as a vararg to the logger call.

func TokenLimit

func TokenLimit(limit uint64) slog.Attr

Use for any integer counters.

func TraceID

func TraceID(traceID trace.TraceID) slog.Attr

func TraceIDFromContext

func TraceIDFromContext(ctx context.Context) slog.Attr

func TrimSourceFilePath

func TrimSourceFilePath(attr slog.Attr) slog.Attr

func TunnelsByAgent

func TunnelsByAgent(numTunnels int) slog.Attr

func U64Count

func U64Count(count uint64) slog.Attr

Use for any integer counters.

func URL

func URL(url string) slog.Attr

func URLPath

func URLPath(url string) slog.Attr

func URLPathPrefix

func URLPathPrefix(urlPrefix string) slog.Attr

func VulnerabilitiesCount

func VulnerabilitiesCount(n int) slog.Attr

func WatchID

func WatchID(id string) slog.Attr

func WorkspaceDataCount

func WorkspaceDataCount(count int) slog.Attr

func WorkspaceName

func WorkspaceName(name string) slog.Attr

func WorkspaceNamespace

func WorkspaceNamespace(namespace string) slog.Attr

Types

type LockedWriter

type LockedWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

LockedWriter serializes Write calls.

func (*LockedWriter) Write

func (w *LockedWriter) Write(data []byte) (int, error)

type LogValuerFunc

type LogValuerFunc func() slog.Value

func (LogValuerFunc) LogValue

func (f LogValuerFunc) LogValue() slog.Value

Jump to

Keyboard shortcuts

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