logging

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Copyright 2025 HAProxy Technologies LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	LogCategoryKey = "category"
)

Variables

View Source
var (
	DefaultLogLevelPerCategory = map[v3.Category]slog.Level{
		LogCategoryK8s:           slog.LevelWarn,
		LogCategoryGate:          slog.LevelInfo,
		LogCategoryApp:           slog.LevelInfo,
		LogCategoryHaproxyCfgMgr: slog.LevelInfo,
		LogCategoryBatch:         slog.LevelInfo,
		LogCategoryStatus:        slog.LevelInfo,
		LogCategoryHugService:    slog.LevelInfo,
		LogCategoryCertsStorage:  slog.LevelInfo,
		LogCategoryMapsStorage:   slog.LevelInfo,
	}
	DefaultLevel = slog.LevelInfo
)
View Source
var (
	LogCategoryK8s           v3.Category = "k8s"
	LogCategoryGate          v3.Category = "gate"
	LogCategoryStatus        v3.Category = "status"
	LogCategoryHaproxyCfgMgr v3.Category = "haproxycfg"
	LogCategoryApp           v3.Category = "app"
	LogCategoryBatch         v3.Category = "batch"
	LogCategoryReloadMgr     v3.Category = "reloadmgr"
	LogCategoryCertsStorage  v3.Category = "certs-storage"
	LogCategoryMapsStorage   v3.Category = "maps-storage"
	LogCategoryHugService    v3.Category = "hugservice"
)

Functions

func GetLogSettings

func GetLogSettings() (slog.Level, map[v3.Category]slog.Level)

func LogAttrBackendName

func LogAttrBackendName(name string) slog.Attr

func LogAttrBatch

func LogAttrBatch(id, length int) slog.Attr

func LogAttrCategory

func LogAttrCategory(category v3.Category) slog.Attr

func LogAttrCommand added in v0.9.0

func LogAttrCommand(command string) slog.Attr

func LogAttrDuration

func LogAttrDuration(duration time.Duration) slog.Attr

func LogAttrError

func LogAttrError(err error) slog.Attr

func LogAttrEventType

func LogAttrEventType(t string) slog.Attr

func LogAttrFileSource

func LogAttrFileSource(file string, line int) slog.Attr

func LogAttrFrontendName

func LogAttrFrontendName(name string) slog.Attr

func LogAttrGVK

func LogAttrGVK(gvk schema.GroupVersionKind) slog.Attr

func LogAttrInstalledVersions

func LogAttrInstalledVersions(versions map[string]int) slog.Attr

func LogAttrKey

func LogAttrKey(key client.ObjectKey) slog.Attr

func LogAttrKeyGVK

func LogAttrKeyGVK(key client.ObjectKey, gvk schema.GroupVersionKind) slog.Attr

func LogAttrLogLevel

func LogAttrLogLevel(level slog.Level) slog.Attr

func LogAttrLogSettings

func LogAttrLogSettings(level slog.Level, settings map[v3.Category]slog.Level) slog.Attr

func LogAttrMapFileContent added in v0.9.1

func LogAttrMapFileContent(path string) slog.Attr

func LogAttrMapFilePath added in v0.9.1

func LogAttrMapFilePath(path string) slog.Attr

func LogAttrNsName

func LogAttrNsName(nsName types.NamespacedName) slog.Attr

func LogAttrObjectKey

func LogAttrObjectKey(obj client.Object) slog.Attr

func LogAttrReloadMgrAction

func LogAttrReloadMgrAction(state bool, reason string, args ...any) slog.Attr

func LogAttrResource

func LogAttrResource(obj client.Object, gvk schema.GroupVersionKind) slog.Attr

func LogAttrRouteGroupKinds

func LogAttrRouteGroupKinds(routesGK []gatewayv1.RouteGroupKind) slog.Attr

func LogAttrServerName

func LogAttrServerName(name string) slog.Attr

func LogAttrVirtualListenerName added in v0.9.0

func LogAttrVirtualListenerName(name string) slog.Attr

func LogLevelString2SlogLevel

func LogLevelString2SlogLevel(level string) slog.Level

Types

type CategoryFilterHandler

type CategoryFilterHandler struct {
	// contains filtered or unexported fields
}

CategoryFilterHandler filters log records by level and key-value category.

func NewCategoryFilterHandler

func NewCategoryFilterHandler(params CategoryFilterHandlerParams) *CategoryFilterHandler

NewCategoryFilterHandler wraps an existing handler and filters by level and category.

func (*CategoryFilterHandler) Enabled

func (*CategoryFilterHandler) Handle

func (*CategoryFilterHandler) ReconcileLogSettings

func (*CategoryFilterHandler) ReconcileLogSettings(aLevel slog.Level, categories map[v3.Category]slog.Level) bool

func (*CategoryFilterHandler) ResetToDefaults

func (h *CategoryFilterHandler) ResetToDefaults()

func (*CategoryFilterHandler) WithAttrs

func (h *CategoryFilterHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*CategoryFilterHandler) WithGroup

func (h *CategoryFilterHandler) WithGroup(name string) slog.Handler

type CategoryFilterHandlerParams

type CategoryFilterHandlerParams struct {
	Base                  slog.Handler
	DefaultCategoryLevels map[v3.Category]slog.Level
	CategoryKey           string
	DefaultLevel          slog.Level
}

type ContextKey

type ContextKey string
const (
	LevelNone               slog.Level = 100
	CallerAdditionalSkipKey ContextKey = "callerSkip"
)

type LogHandlerType

type LogHandlerType string
const (
	LogHandlerTypeJSON LogHandlerType = "json"
	LogHandlerTypeText LogHandlerType = "text"
)

Jump to

Keyboard shortcuts

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