https://github.com/gomodules/union-logr
A https://github.com/go-logr/logr implementation that aggregates multiple loggers
https://github.com/gomodules/union-logr
Last synced: 6 months ago
JSON representation
A https://github.com/go-logr/logr implementation that aggregates multiple loggers
- Host: GitHub
- URL: https://github.com/gomodules/union-logr
- Owner: gomodules
- License: apache-2.0
- Created: 2019-07-02T09:43:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-06T13:11:45.000Z (almost 4 years ago)
- Last Synced: 2025-02-26T21:43:48.674Z (over 1 year ago)
- Language: Go
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# union-logr
A [logr](https://github.com/go-logr/logr) implementation that aggregates multiple loggers.
Usage
---
### Code Example
```go
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](https://github.com/gomodules/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](https://github.com/gomodules/union-logr).