log

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package log wrappers slog for the kwok and kwokctl

Index

Constants

This section is empty.

Variables

View Source
var IsTerminal = term.IsTerminal

Functions

func NewContext

func NewContext(ctx context.Context, logger *Logger) context.Context

Types

type KMetadata

type KMetadata interface {
	GetName() string
	GetNamespace() string
}

KMetadata is a subset of the kubernetes k8s.io/apimachinery/pkg/apis/meta/v1.Object interface this interface may expand in the future, but will always be a subset of the kubernetes k8s.io/apimachinery/pkg/apis/meta/v1.Object interface

type Level

type Level = slog.Level
const (
	DebugLevel Level = slog.DebugLevel
	InfoLevel  Level = slog.InfoLevel
	WarnLevel  Level = slog.WarnLevel
	ErrorLevel Level = slog.ErrorLevel
)

type Logger

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

func FromContext

func FromContext(ctx context.Context) *Logger

func InitFlags

func InitFlags(ctx context.Context, flags *pflag.FlagSet) (context.Context, *Logger)

func NewLogger

func NewLogger(w io.Writer, level slog.Level) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

func (*Logger) Error

func (l *Logger) Error(msg string, err error, args ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) Log

func (l *Logger) Log(level Level, msg string, args ...any)

func (*Logger) LogDepth

func (l *Logger) LogDepth(calldepth int, level Level, msg string, args ...any)

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

func (*Logger) WithGroup

func (l *Logger) WithGroup(name string) *Logger

type ObjectRef

type ObjectRef struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace,omitempty"`
}

ObjectRef references a kubernetes object

func KObj

func KObj[T KMetadata](obj T) ObjectRef

KObj returns ObjectRef from ObjectMeta

func KObjs

func KObjs[S ~[]T, T KMetadata](s S) []ObjectRef

KObjs returns slice of ObjectRef from an slice of ObjectMeta

func KRef

func KRef(namespace, name string) ObjectRef

KRef returns ObjectRef from name and namespace

func (ObjectRef) String

func (ref ObjectRef) String() string

Jump to

Keyboard shortcuts

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