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

[]byte will use +%v through InfoS. #236

Closed
njuptlzf opened this issue May 8, 2021 · 13 comments · Fixed by #237
Closed

[]byte will use +%v through InfoS. #236

njuptlzf opened this issue May 8, 2021 · 13 comments · Fixed by #237
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.

Comments

@njuptlzf
Copy link

njuptlzf commented May 8, 2021

/kind bug

What steps did you take and what happened:
[A clear and concise description of what the bug is.]

klog.InfoS("[]byte", "b1", []byte("hello world"))

print:
I0508 19:35:13.452661 57319 testKlog.go:11] "[]byte" b1=[104 101 108 108 111 32 119 111 114 108 100]

What did you expect to happen:
I0508 19:37:01.473191 2045 testKlog.go:11] "[]byte" b1="hello world"

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]
part of kubernetes/kubernetes#101714
As k8s conducts structured log migration, InfoS is used more and more, but []byte, usually cooperates with %q before the migration, is it necessary to submit a PR so that []byte uses %q in InfoS?
Currently in InfoS, []byte uses %+v.

klog/klog.go

Line 832 in 0cc9b83

b.WriteString(fmt.Sprintf("%s=%+v", k, v))

If the idea is approved, I will do it, otherwise I will probably continue to use klog.InfoS("[]byte", "b1", string([]byte("hello world"))).

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 8, 2021
@yuzhiquan
Copy link
Member

/assign

@yuzhiquan
Copy link
Member

Oops, sorry @njuptlzf for not notice this If the idea is approved, I will do it, otherwise I will probably continue to use.

@njuptlzf
Copy link
Author

Oops, sorry @njuptlzf for not notice this If the idea is approved, I will do it, otherwise I will probably continue to use.

Everything is for the development of the community, cheers. :)

@pohly
Copy link

pohly commented Dec 1, 2021

This didn't solve the problem for JSON. There the byte slice will be dumped as a base64 encoded string representation of the bytes.

IMHO the right solution for byte slices that are meant to be treated like strings is to convert to string before logging.

Let's reopen to discuss this further. We may have to put this into the migration guide.

/reopen
/wg structured-logging

@k8s-ci-robot k8s-ci-robot added the wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging. label Dec 1, 2021
@k8s-ci-robot
Copy link

@pohly: Reopened this issue.

In response to this:

This didn't solve the problem for JSON. There the byte slice will be dumped as a base64 encoded string representation of the bytes.

IMHO the right solution for byte slices that are meant to be treated like strings is to convert to string before logging.

Let's reopen to discuss this further. We may have to put this into the migration guide.

/reopen
/wg structured-logging

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@shivanshuraj1333
Copy link

Thanks, @pohly for pointing this out, I agree with

the right solution for byte slices that are meant to be treated like strings is to convert to string before logging.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 8, 2022
@pohly
Copy link

pohly commented Mar 8, 2022

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 8, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 6, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 6, 2022
@pohly
Copy link

pohly commented Jul 7, 2022

We may have to put this into the migration guide.

We have that now, so let's assume that this is indeed resolved.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants