logz

package
v17.7.0-rc31 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 13 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 added in v17.5.0

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 added in v17.7.0

func EventHandler(name string) slog.Attr

func EventType added in v17.7.0

func EventType(typ string) slog.Attr

func FlowScript added in v17.7.0

func FlowScript(path string) slog.Attr

func FullReconciliationInterval added in v17.1.0

func FullReconciliationInterval(interval time.Duration) slog.Attr

func GRPCMethod

func GRPCMethod(method string) slog.Attr

func GRPCService

func GRPCService(service string) slog.Attr

func GatewayURL added in v17.1.0

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 IsWebSocket

func IsWebSocket(isWebSocket bool) slog.Attr

func K8sGroup

func K8sGroup(groupName string) slog.Attr

func K8sObjectName

func K8sObjectName(name string) slog.Attr

func K8sObjectNamespace added in v17.6.0

func K8sObjectNamespace(name string) slog.Attr

func K8sResource

func K8sResource(resourceName string) slog.Attr

func LabelSelector added in v17.2.0

func LabelSelector(selector string) slog.Attr

func LazyValue added in v17.2.0

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

func ListenerName added in v17.5.0

func ListenerName(name string) slog.Attr

func ModuleName

func ModuleName(name string) slog.Attr

GitLab-kas or agentk module name.

func Msg added in v17.4.0

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 added in v17.7.0

func NumberOfEventHandlers(n int) slog.Attr

func ObjectKey

func ObjectKey(objKey string) slog.Attr

func PartialReconciliationInterval added in v17.1.0

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 added in v17.1.0

func PodNamespace(podNamespace string) slog.Attr

func PodStatus

func PodStatus(podStatus string) slog.Attr

func PooledConnectionURL added in v17.5.0

func PooledConnectionURL(poolConnURL 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 ProjectsToReconcile

func ProjectsToReconcile(p []string) slog.Attr

func ProtoJSONValue

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

func Reason added in v17.4.0

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 Strings added in v17.2.0

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

func TargetNamespace

func TargetNamespace(namespace string) slog.Attr

func ToSlogAttr added in v17.2.0

func ToSlogAttr(field fieldz.Field) slog.Attr

func ToSlogAttrs added in v17.2.0

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 added in v17.2.0

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 added in v17.3.0

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 added in v17.2.0

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

LockedWriter serializes Write calls.

func (*LockedWriter) Write added in v17.2.0

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

type LogValuerFunc added in v17.2.0

type LogValuerFunc func() slog.Value

func (LogValuerFunc) LogValue added in v17.2.0

func (f LogValuerFunc) LogValue() slog.Value

Jump to

Keyboard shortcuts

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