Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the underlying zap logger #301

Closed
calind opened this issue Jan 23, 2019 · 2 comments
Closed

Expose the underlying zap logger #301

calind opened this issue Jan 23, 2019 · 2 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@calind
Copy link
Contributor

calind commented Jan 23, 2019

I have a following use case: i'm writing an app which exposes some kubernetes suff over grpc. The grpc part of the application already has zap integration and just expects a zap logger passed in. I would like to pass the logger configured by the controller-runtime becuse it's deals nicely with kubernetes objects already but that's not exposed.

I would propose to add an option to Logger and LoggerTo which sets zap default loggers or expose the underlying zap logger.

@calind calind changed the title Allow logger to configure default zap loggers Expose the underlying zap logger Jan 23, 2019
@DirectXMan12
Copy link
Contributor

/kind feature
/priority backlog

In the short term: you can always make use of the KubeAwareEncoder in your own zap instance.
In the long term: we can probably refactor out the "set up Zap" function pretty easily so that you can just call that directly. Then, if you want to re-use the Zap logger, you could just

import (
    crzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
    "github.com/go-logr/zapr"
    logf "sigs.k8s.io/controller-runtime/pkg/log"
)

func main() {
    // instead of `log := crzap.Logger(isDevel)`
    zapLogger := crzap.RawLoggerTo(dest, isDevel)
    go doSomeNonControllerRuntimeStuff(zapLogger)
    logf.SetLogger(zapr.NewLogger(zapLogger))
}

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. labels Jan 29, 2019
@calind
Copy link
Contributor Author

calind commented Jan 31, 2019

Great! I will attempt a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

3 participants