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

Set log level through function #389

Closed
wants to merge 1 commit into from

Conversation

tshiyuoo
Copy link

What this PR does / why we need it:

Which issue(s) this PR fixes:
The log level can be set through functions,
Not only can it be set by flags, but also by functions.

A app has a debug flag. enable the debug flag parameter, I hope that all the klog logs can be printed out.
But the klog log level can only be set through flag

Special notes for your reviewer:

Release note:

None

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 10, 2023
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tshiyuoo
Once this PR has been reviewed and has the lgtm label, please assign thockin for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 10, 2023
@pohly
Copy link

pohly commented Oct 10, 2023

We've discussed this before. Please read up on #336 and if you are interested in adding a non-flag API, then do it as described there.

Adding individual new API calls in the main klog is not how we want to do this.

@@ -438,6 +438,11 @@ func InitFlags(flagset *flag.FlagSet) {
})
}

// SetVerbosity set log level through function.
func SetVerbosity(level Level) {
logging.verbosity = level
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't thread-safe. Set has to be used.

@dashpole
Copy link

/assign @pohly
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 19, 2023
@pohly
Copy link

pohly commented Oct 20, 2023

/close

Please reopen a new PR with the approach described above, if you are interested.

@k8s-ci-robot
Copy link

@pohly: Closed this PR.

In response to this:

/close

Please reopen a new PR with the approach described above, if you are interested.

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
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants