kloglogger

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: Unlicense Imports: 2 Imported by: 1

README

klog bridge for go-ovirt-client-log

This library provides klog bindings for the go-ovirt-client-log logging interface. This interface is used for logging in various oVirt client libraries and applications.

Installation

This module is installed using go modules:

go get github.com/ovirt-go-ovirt-client-log-klog

Usage

You can use it in your code as follows:

package main

import (
	kloglogger "github.com/ovirt/go-ovirt-client-log-klog"
)

func main() {
	logger := kloglogger.New()
	
	// Pass logger to other library as needed.
}

You can also use the klog Verbose() function with the logger to specify separate verbosity levels:

package main

import (
	kloglogger "github.com/ovirt/go-ovirt-client-log-klog"
	"k8s.io/klog/v2"
)

func main() {
	logger := kloglogger.NewVerbose(
		klog.V(4),
		klog.V(3),
		klog.V(2),
		klog.V(1),
    )

	// Pass logger to other library as needed.
}

How it works

This library creates a simply proxy transforming the OOP-style logger call into klog calls on the following levels:

  • Debug logs are sent to klog.Infof()
  • Info logs are sent to klog.Infof()
  • Warning logs are sent to klog.Warningf()
  • Error logs are sent to klog.Errorf()

License

This code is licensed under the Unlicense, so you are pretty much free to do with it what you want.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() log.Logger

New creates a simple klog logger which logs on the following levels:

- Debug logs are sent to Infof - Info logs are sent to Infof - Warning logs are sent to Warningf - Error logs are sent to Errorf

func NewVerbose

func NewVerbose(
	debugLevel klog.Verbose,
	infoLevel klog.Verbose,
	warningLevel klog.Verbose,
	errorLevel klog.Verbose,
) log.Logger

NewVerbose creates a logger based on the klog.V function. It logs all messages

Types

This section is empty.

Jump to

Keyboard shortcuts

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