{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/klog/issues/20","repository_url":"https://api.github.com/repos/kubernetes/klog","labels_url":"https://api.github.com/repos/kubernetes/klog/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/klog/issues/20/comments","events_url":"https://api.github.com/repos/kubernetes/klog/issues/20/events","html_url":"https://github.com/kubernetes/klog/pull/20","id":380946730,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMDI4NjYz","number":20,"title":"Add SetLogger function to intercept klog output with logr","user":{"login":"munnerz","id":203583,"node_id":"MDQ6VXNlcjIwMzU4Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/203583?v=4","gravatar_id":"","url":"https://api.github.com/users/munnerz","html_url":"https://github.com/munnerz","followers_url":"https://api.github.com/users/munnerz/followers","following_url":"https://api.github.com/users/munnerz/following{/other_user}","gists_url":"https://api.github.com/users/munnerz/gists{/gist_id}","starred_url":"https://api.github.com/users/munnerz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/munnerz/subscriptions","organizations_url":"https://api.github.com/users/munnerz/orgs","repos_url":"https://api.github.com/users/munnerz/repos","events_url":"https://api.github.com/users/munnerz/events{/privacy}","received_events_url":"https://api.github.com/users/munnerz/received_events","type":"User","site_admin":false},"labels":[{"id":1112953909,"node_id":"MDU6TGFiZWwxMTEyOTUzOTA5","url":"https://api.github.com/repos/kubernetes/klog/labels/cncf-cla:%20yes","name":"cncf-cla: yes","color":"bfe5bf","default":false},{"id":1112953913,"node_id":"MDU6TGFiZWwxMTEyOTUzOTEz","url":"https://api.github.com/repos/kubernetes/klog/labels/size/L","name":"size/L","color":"ee9900","default":false}],"state":"open","locked":false,"assignee":{"login":"pohly","id":22076,"node_id":"MDQ6VXNlcjIyMDc2","avatar_url":"https://avatars1.githubusercontent.com/u/22076?v=4","gravatar_id":"","url":"https://api.github.com/users/pohly","html_url":"https://github.com/pohly","followers_url":"https://api.github.com/users/pohly/followers","following_url":"https://api.github.com/users/pohly/following{/other_user}","gists_url":"https://api.github.com/users/pohly/gists{/gist_id}","starred_url":"https://api.github.com/users/pohly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pohly/subscriptions","organizations_url":"https://api.github.com/users/pohly/orgs","repos_url":"https://api.github.com/users/pohly/repos","events_url":"https://api.github.com/users/pohly/events{/privacy}","received_events_url":"https://api.github.com/users/pohly/received_events","type":"User","site_admin":false},"assignees":[{"login":"pohly","id":22076,"node_id":"MDQ6VXNlcjIyMDc2","avatar_url":"https://avatars1.githubusercontent.com/u/22076?v=4","gravatar_id":"","url":"https://api.github.com/users/pohly","html_url":"https://github.com/pohly","followers_url":"https://api.github.com/users/pohly/followers","following_url":"https://api.github.com/users/pohly/following{/other_user}","gists_url":"https://api.github.com/users/pohly/gists{/gist_id}","starred_url":"https://api.github.com/users/pohly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pohly/subscriptions","organizations_url":"https://api.github.com/users/pohly/orgs","repos_url":"https://api.github.com/users/pohly/repos","events_url":"https://api.github.com/users/pohly/events{/privacy}","received_events_url":"https://api.github.com/users/pohly/received_events","type":"User","site_admin":false},{"login":"thockin","id":5595220,"node_id":"MDQ6VXNlcjU1OTUyMjA=","avatar_url":"https://avatars0.githubusercontent.com/u/5595220?v=4","gravatar_id":"","url":"https://api.github.com/users/thockin","html_url":"https://github.com/thockin","followers_url":"https://api.github.com/users/thockin/followers","following_url":"https://api.github.com/users/thockin/following{/other_user}","gists_url":"https://api.github.com/users/thockin/gists{/gist_id}","starred_url":"https://api.github.com/users/thockin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thockin/subscriptions","organizations_url":"https://api.github.com/users/thockin/orgs","repos_url":"https://api.github.com/users/thockin/repos","events_url":"https://api.github.com/users/thockin/events{/privacy}","received_events_url":"https://api.github.com/users/thockin/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2018-11-15T00:26:32Z","updated_at":"2019-02-27T15:14:36Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/kubernetes/klog/pulls/20","html_url":"https://github.com/kubernetes/klog/pull/20","diff_url":"https://github.com/kubernetes/klog/pull/20.diff","patch_url":"https://github.com/kubernetes/klog/pull/20.patch"},"body":"This is an example of how we can modify klog and the work required in order to allow intercepting logs, including preserving the `V` level and severity.\r\n\r\nIn order to do this, I've had to change the type signature of `Verbose` from `type Verbose bool` to:\r\n\r\n```\r\ntype Verbose struct {\r\n\tenabled bool\r\n\tlogr    logr.InfoLogger\r\n}\r\n```\r\n\r\nConsequently, it requires a corresponding change in k/k in the instances where `if klog.V(x) {` (replacing them with `if klog.V(x).Enabled()`).\r\n\r\nThe total changeset in k/k to get `bazel build //...` to pass:\r\n\r\n```\r\n pkg/cloudprovider/providers/gce/cloud/gen.go                | 160 +++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------\r\n pkg/cloudprovider/providers/vsphere/vclib/connection.go     |   2 +-\r\n pkg/controller/nodelifecycle/node_lifecycle_controller.go   |   4 +--\r\n pkg/controller/volume/attachdetach/reconciler/reconciler.go |   6 ++--\r\n pkg/kubectl/cmd/util/helpers.go                             |   2 +-\r\n pkg/kubelet/eviction/helpers.go                             |   4 +--\r\n pkg/proxy/endpoints.go                                      |   2 +-\r\n pkg/scheduler/algorithm/predicates/predicates.go            |   8 ++---\r\n pkg/scheduler/algorithm/priorities/interpod_affinity.go     |   2 +-\r\n pkg/scheduler/algorithm/priorities/resource_allocation.go   |   2 +-\r\n pkg/scheduler/algorithm/priorities/resource_limits.go       |   2 +-\r\n pkg/scheduler/algorithm/priorities/selector_spreading.go    |   2 +-\r\n pkg/scheduler/core/generic_scheduler.go                     |   6 ++--\r\n plugin/pkg/auth/authorizer/rbac/rbac.go                     |   2 +-\r\n staging/src/k8s.io/apiserver/pkg/server/httplog/httplog.go  |   4 +--\r\n staging/src/k8s.io/apiserver/pkg/util/trace/trace.go        |   4 +--\r\n staging/src/k8s.io/client-go/rest/request.go                |   8 ++---\r\n staging/src/k8s.io/client-go/transport/round_trippers.go    |   8 ++---\r\n 18 files changed, 114 insertions(+), 114 deletions(-)\r\n```\r\n\r\nWe can still preserve the old behaviour in the `k8s.io/klog/glog` package, for those that are using the dep `replace` method to implement glog.\r\n\r\nref #19"},"comment":{"url":"https://api.github.com/repos/kubernetes/klog/issues/comments/467900552","html_url":"https://github.com/kubernetes/klog/pull/20#issuecomment-467900552","issue_url":"https://api.github.com/repos/kubernetes/klog/issues/20","id":467900552,"node_id":"MDEyOklzc3VlQ29tbWVudDQ2NzkwMDU1Mg==","user":{"login":"dims","id":23304,"node_id":"MDQ6VXNlcjIzMzA0","avatar_url":"https://avatars2.githubusercontent.com/u/23304?v=4","gravatar_id":"","url":"https://api.github.com/users/dims","html_url":"https://github.com/dims","followers_url":"https://api.github.com/users/dims/followers","following_url":"https://api.github.com/users/dims/following{/other_user}","gists_url":"https://api.github.com/users/dims/gists{/gist_id}","starred_url":"https://api.github.com/users/dims/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dims/subscriptions","organizations_url":"https://api.github.com/users/dims/orgs","repos_url":"https://api.github.com/users/dims/repos","events_url":"https://api.github.com/users/dims/events{/privacy}","received_events_url":"https://api.github.com/users/dims/received_events","type":"User","site_admin":false},"created_at":"2019-02-27T15:14:36Z","updated_at":"2019-02-27T15:14:36Z","author_association":"MEMBER","body":"/assign @DirectXMan12 "}}
{"actor":{"display_login":"dims"}}