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

Move logrus setup code to log package #8441

Merged
merged 1 commit into from
Apr 24, 2023
Merged

Move logrus setup code to log package #8441

merged 1 commit into from
Apr 24, 2023

Conversation

mxpv
Copy link
Member

@mxpv mxpv commented Apr 24, 2023

This PR reduces the spread of logrus imports. It moves logrus setup code to the log package to simplify migration to a new logger in the future (containerd/log#2)

@mxpv mxpv merged commit 4a67fe0 into containerd:main Apr 24, 2023
@mxpv mxpv deleted the logrus branch April 24, 2023 20:05
)

// SetLevel sets log level globally.
func SetLevel(level string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Is it better if the type of the parameter is Level? so that when using it, we can call log.SetLevel(log.InfoLevel)

Of course, we can also add a check for the level parameter, eg.

// SetLevel sets log level globally.
func SetLevel(level Level) error {
        lvl, err := logrus.ParseLevel(level.String())
        if err != nil {
                return err
        }

        logrus.SetLevel(lvl)
        return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants