diff --git a/utils.go b/utils.go new file mode 100644 index 000000000..8d287da1d --- /dev/null +++ b/utils.go @@ -0,0 +1,19 @@ +package utils + +import ( + "github.com/pkg/errors" + "github.com/sirupsen/logrus" +) + +func SetUpLogger(logLevelStr string) error { + logLevel, err := logrus.ParseLevel(logLevelStr) + if err != nil { + return errors.Wrapf(err, "unable to parse the specified log level: '%s'", logLevel) + } + logrus.SetLevel(logLevel) + logrus.SetFormatter(&logrus.TextFormatter{ + FullTimestamp: true, + }) + logrus.Infof("log level set to '%s'", logrus.GetLevel()) + return nil +}