klog

package
v0.0.0-...-b7b0d94 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(args ...any)

Error is a convenience that calls the same method documented on api.Klog.

Note: See Info for unit test and benchmarking impact.

Example
package main

import (
	"fmt"

	"sigs.k8s.io/kube-scheduler-wasm-extension/guest/klog"
)

func main() {
	metricName := "scheduler_framework_extension_point_duration_milliseconds"
	err := fmt.Errorf("metric %q not found", metricName)
	klog.Error(err)

}
Output:

func ErrorS

func ErrorS(err error, msg string, keysAndValues ...any)

ErrorS is a convenience that calls the same method documented on api.Klog.

Note: See Info for unit test and benchmarking impact.

Example
package main

import (
	"fmt"

	"sigs.k8s.io/kube-scheduler-wasm-extension/guest/klog"
)

func main() {
	bucketSize := 32
	histBucketSize := 16
	index := 2
	err := fmt.Errorf("found different bucket size: expect %v, but got %v at index %v", bucketSize, histBucketSize, index)
	metricName := "scheduler_framework_extension_point_duration_milliseconds"
	labels := map[string]string{"Name": "some-name"}

	klog.ErrorS(err, "the validation for HistogramVec is failed. The data for this metric won't be stored in a benchmark result file", "metric", metricName, "labels", labels)

}
Output:

func Get

func Get() api.Klog

Get can be called at any time, to get a logger that writes to the WebAssembly host.

For example:

func main() {
	klog := klog.Get()
	klog.Info("hello", "world")
}

func Info

func Info(args ...any)

Info is a convenience that calls the same method documented on api.Klog.

Note: Code that uses can be unit tested in normal Go, but cannot be unit tested or benchmarked via `tinygo test -target=wasi`. To avoid this problem, use Get instead.

Example
package main

import (
	"sigs.k8s.io/kube-scheduler-wasm-extension/guest/klog"
)

func main() {
	klog.Info("NodeNumberArgs is successfully applied")

}
Output:

func InfoS

func InfoS(msg string, keysAndValues ...any)

InfoS is a convenience that calls the same method documented on api.Klog.

Note: See Info for unit test and benchmarking impact.

Example
package main

import (
	"sigs.k8s.io/kube-scheduler-wasm-extension/guest/api/proto"
	"sigs.k8s.io/kube-scheduler-wasm-extension/guest/klog"

	klogapi "sigs.k8s.io/kube-scheduler-wasm-extension/guest/klog/api"
)

var pod proto.Pod

func main() {
	klog.InfoS("execute Score on NodeNumber plugin", "pod", klogapi.KObj(pod))

}
Output:

func KObj

func KObj(obj proto.Metadata) fmt.Stringer

KObj is a convenience that calls api.KObj. This is re-declared here for familiarity.

Note: See Info for unit test and benchmarking impact.

func KObjSlice

func KObjSlice[M proto.Metadata](objs []M) fmt.Stringer

KObjSlice is a convenience that calls api.KObjSlice. This is re-declared here for familiarity.

Note: See Info for unit test and benchmarking impact.

func KObjSliceFn

func KObjSliceFn[M proto.Metadata](lazy func() []M) fmt.Stringer

KObjSliceFn is a convenience that calls api.KObjSliceFn. This is re-declared here for familiarity.

Note: See Info for unit test and benchmarking impact.

Types

This section is empty.

Directories

Path Synopsis
Package internal allows unit testing without requiring wasm imports.
Package internal allows unit testing without requiring wasm imports.

Jump to

Keyboard shortcuts

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