@@ -25,6 +25,7 @@ import (
2525 "strings"
2626 "time"
2727
28+ "github.com/containerd/log"
2829 "github.com/containerd/nerdctl/pkg/config"
2930 ncdefaults "github.com/containerd/nerdctl/pkg/defaults"
3031 "github.com/containerd/nerdctl/pkg/errutil"
@@ -34,7 +35,6 @@ import (
3435 "github.com/fatih/color"
3536 "github.com/pelletier/go-toml/v2"
3637
37- "github.com/sirupsen/logrus"
3838 "github.com/spf13/cobra"
3939 "github.com/spf13/pflag"
4040)
@@ -118,7 +118,7 @@ func usage(c *cobra.Command) error {
118118func main () {
119119 if err := xmain (); err != nil {
120120 errutil .HandleExitCoder (err )
121- logrus .Fatal (err )
121+ log . L .Fatal (err )
122122 }
123123}
124124
@@ -139,15 +139,15 @@ func xmain() error {
139139func initRootCmdFlags (rootCmd * cobra.Command , tomlPath string ) (* pflag.FlagSet , error ) {
140140 cfg := config .New ()
141141 if r , err := os .Open (tomlPath ); err == nil {
142- logrus .Debugf ("Loading config from %q" , tomlPath )
142+ log . L .Debugf ("Loading config from %q" , tomlPath )
143143 defer r .Close ()
144144 dec := toml .NewDecoder (r ).DisallowUnknownFields () // set Strict to detect typo
145145 if err := dec .Decode (cfg ); err != nil {
146146 return nil , fmt .Errorf ("failed to load nerdctl config (not daemon config) from %q (Hint: don't mix up daemon's `config.toml` with `nerdctl.toml`): %w" , tomlPath , err )
147147 }
148- logrus .Debugf ("Loaded config %+v" , cfg )
148+ log . L .Debugf ("Loaded config %+v" , cfg )
149149 } else {
150- logrus .WithError (err ).Debugf ("Not loading config from %q" , tomlPath )
150+ log . L .WithError (err ).Debugf ("Not loading config from %q" , tomlPath )
151151 if ! errors .Is (err , os .ErrNotExist ) {
152152 return nil , err
153153 }
@@ -216,7 +216,7 @@ Config file ($NERDCTL_TOML): %s
216216 debug = globalOptions .Debug
217217 }
218218 if debug {
219- logrus .SetLevel (logrus .DebugLevel )
219+ log .SetLevel (log .DebugLevel . String () )
220220 }
221221 address := globalOptions .Address
222222 if strings .Contains (address , "://" ) && ! strings .HasPrefix (address , "unix://" ) {
@@ -327,7 +327,7 @@ Config file ($NERDCTL_TOML): %s
327327func globalFlags (cmd * cobra.Command ) (string , []string ) {
328328 args0 , err := os .Executable ()
329329 if err != nil {
330- logrus .WithError (err ).Warnf ("cannot call os.Executable(), assuming the executable to be %q" , os .Args [0 ])
330+ log . L .WithError (err ).Warnf ("cannot call os.Executable(), assuming the executable to be %q" , os .Args [0 ])
331331 args0 = os .Args [0 ]
332332 }
333333 if len (os .Args ) < 2 {
@@ -396,7 +396,7 @@ func AddIntFlag(cmd *cobra.Command, name string, aliases []string, value int, en
396396 if envV , ok := os .LookupEnv (env ); ok {
397397 v , err := strconv .ParseInt (envV , 10 , 64 )
398398 if err != nil {
399- logrus .WithError (err ).Warnf ("Invalid int value for `%s`" , env )
399+ log . L .WithError (err ).Warnf ("Invalid int value for `%s`" , env )
400400 }
401401 value = int (v )
402402 }
@@ -423,7 +423,7 @@ func AddDurationFlag(cmd *cobra.Command, name string, aliases []string, value ti
423423 var err error
424424 value , err = time .ParseDuration (envV )
425425 if err != nil {
426- logrus .WithError (err ).Warnf ("Invalid duration value for `%s`" , env )
426+ log . L .WithError (err ).Warnf ("Invalid duration value for `%s`" , env )
427427 }
428428 }
429429 aliasesUsage := fmt .Sprintf ("Alias of --%s" , name )
@@ -501,7 +501,7 @@ func AddPersistentBoolFlag(cmd *cobra.Command, name string, aliases, nonPersiste
501501 var err error
502502 value , err = strconv .ParseBool (envV )
503503 if err != nil {
504- logrus .WithError (err ).Warnf ("Invalid boolean value for `%s`" , env )
504+ log . L .WithError (err ).Warnf ("Invalid boolean value for `%s`" , env )
505505 }
506506 }
507507 aliasesUsage := fmt .Sprintf ("Alias of --%s" , name )
0 commit comments