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

Remove redundant logrus.SetOutput(stderr) statements #5375

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"strings"
"time"

k0slog "github.com/k0sproject/k0s/internal/pkg/log"
internallog "github.com/k0sproject/k0s/internal/pkg/log"
mw "github.com/k0sproject/k0s/internal/pkg/middleware"
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
"github.com/k0sproject/k0s/pkg/config"
Expand All @@ -56,7 +56,7 @@ func NewAPICmd() *cobra.Command {
Args: cobra.NoArgs,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
logrus.SetOutput(cmd.OutOrStdout())
k0slog.SetInfoLevel()
internallog.SetInfoLevel()
return config.CallParentPersistentPreRun(cmd, args)
},
RunE: func(cmd *cobra.Command, _ []string) error {
Expand Down
4 changes: 0 additions & 4 deletions cmd/backup/backup_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ func NewBackupCmd() *cobra.Command {
Use: "backup",
Short: "Back-Up k0s configuration. Must be run as root (or with sudo)",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
// ensure logs don't mess up output
logrus.SetOutput(cmd.ErrOrStderr())
},
RunE: func(cmd *cobra.Command, _ []string) error {
opts, err := config.GetCmdOpts(cmd)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
workercmd "github.com/k0sproject/k0s/cmd/worker"
"github.com/k0sproject/k0s/internal/pkg/dir"
"github.com/k0sproject/k0s/internal/pkg/file"
k0slog "github.com/k0sproject/k0s/internal/pkg/log"
internallog "github.com/k0sproject/k0s/internal/pkg/log"
"github.com/k0sproject/k0s/internal/pkg/sysinfo"
"github.com/k0sproject/k0s/internal/sync/value"
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
Expand Down Expand Up @@ -83,7 +83,7 @@ func NewControllerCmd() *cobra.Command {
Args: cobra.MaximumNArgs(1),
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
logrus.SetOutput(cmd.OutOrStdout())
k0slog.SetInfoLevel()
internallog.SetInfoLevel()
return config.CallParentPersistentPreRun(cmd, args)
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
5 changes: 0 additions & 5 deletions cmd/etcd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/k0sproject/k0s/pkg/config"
"github.com/k0sproject/k0s/pkg/etcd"
"github.com/sirupsen/logrus"

"github.com/spf13/cobra"
)
Expand All @@ -32,10 +31,6 @@ func etcdListCmd() *cobra.Command {
Use: "member-list",
Short: "List etcd cluster members (JSON encoded)",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
// ensure logs don't mess up the output
logrus.SetOutput(cmd.ErrOrStderr())
},
RunE: func(cmd *cobra.Command, _ []string) error {
opts, err := config.GetCmdOpts(cmd)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions cmd/kubeconfig/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"k8s.io/client-go/tools/clientcmd"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand All @@ -39,10 +38,6 @@ func kubeConfigAdminCmd() *cobra.Command {
$ export KUBECONFIG=~/.kube/config
$ kubectl get nodes`,
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
// ensure logs don't mess up the output
logrus.SetOutput(cmd.ErrOrStderr())
},
RunE: func(cmd *cobra.Command, _ []string) error {
opts, err := config.GetCmdOpts(cmd)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions cmd/kubeconfig/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand All @@ -46,10 +45,6 @@ Note: A certificate once signed cannot be revoked for a particular user`,

optionally add groups:
$ k0s kubeconfig create username --groups [groups]`,
PreRun: func(cmd *cobra.Command, args []string) {
// ensure logs don't mess up the output
logrus.SetOutput(cmd.ErrOrStderr())
},
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
username := args[0]
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/k0sproject/k0s/cmd/validate"
"github.com/k0sproject/k0s/cmd/version"
"github.com/k0sproject/k0s/cmd/worker"
k0slog "github.com/k0sproject/k0s/internal/pkg/log"
internallog "github.com/k0sproject/k0s/internal/pkg/log"
"github.com/k0sproject/k0s/pkg/build"
"github.com/k0sproject/k0s/pkg/config"

Expand All @@ -61,12 +61,12 @@ func NewRootCmd() *cobra.Command {

PersistentPreRun: func(cmd *cobra.Command, args []string) {
if config.Verbose {
k0slog.SetInfoLevel()
internallog.SetInfoLevel()
}

if config.Debug {
// TODO: check if it actually works and is not overwritten by something else
k0slog.SetDebugLevel()
internallog.SetDebugLevel()

go func() {
log := logrus.WithField("debug_server", config.DebugListenOn)
Expand Down
4 changes: 2 additions & 2 deletions cmd/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"runtime"
"syscall"

k0slog "github.com/k0sproject/k0s/internal/pkg/log"
internallog "github.com/k0sproject/k0s/internal/pkg/log"
"github.com/k0sproject/k0s/internal/pkg/sysinfo"
"github.com/k0sproject/k0s/pkg/build"
"github.com/k0sproject/k0s/pkg/component/iptables"
Expand Down Expand Up @@ -61,7 +61,7 @@ func NewWorkerCmd() *cobra.Command {
Args: cobra.MaximumNArgs(1),
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
logrus.SetOutput(cmd.OutOrStdout())
k0slog.SetInfoLevel()
internallog.SetInfoLevel()
return config.CallParentPersistentPreRun(cmd, args)
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"strings"

"github.com/k0sproject/k0s/cmd"
k0slog "github.com/k0sproject/k0s/internal/pkg/log"
internallog "github.com/k0sproject/k0s/internal/pkg/log"
)

//go:generate make codegen

func init() {
k0slog.InitLogging()
internallog.InitLogging()
}

func main() {
Expand Down
Loading