ulogr

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: Apache-2.0 Imports: 1 Imported by: 1

README

union-logr

A logr implementation that aggregates multiple loggers.

Usage

Code Example
package main

import (
	"flag"
	"fmt"

	"github.com/go-logr/glogr"
	ulogr "gomodules.xyz/union-logr"
	"k8s.io/klog"
	"k8s.io/klog/klogr"
)

func main(){
	flag.Set("logtostderr", "true")
	flag.Parse()
	logG := glogr.New().WithName("glog")

	klog.InitFlags(flag.NewFlagSet("klog", flag.ExitOnError))
	logK := klogr.New().WithName("klog")

	ulog := ulogr.NewLogger(logG, logK).WithName("ulog").WithValues("logr", "union-logr")
	ulog.V(0).Info("Example", "Key", "Value")
}

Description

For using union-logr, you just need to do the followings:

  • Define some logger (i.e.: glogr, klogr etc.)
  • Pass those logger to ulogr.NewLogger and use it like you are using a single logger.

Thus, you can use multiple loggers at a time using a single union-logr.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(loggers ...logr.Logger) logr.Logger

Types

This section is empty.

Jump to

Keyboard shortcuts

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