Skip to content

Commit f489a06

Browse files
committed
no logrus alias to log
1 parent 9ef43c7 commit f489a06

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

wattpilot.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import (
1818
"syscall"
1919
"time"
2020

21-
log "github.com/sirupsen/logrus"
21+
"github.com/apex/log"
22+
"github.com/sirupsen/logrus"
2223
"golang.org/x/crypto/pbkdf2"
2324
"nhooyr.io/websocket"
2425
)
@@ -65,7 +66,7 @@ type Wattpilot struct {
6566
interrupt chan os.Signal
6667

6768
notify *Pubsub
68-
logger *log.Logger
69+
logger *logrus.Logger
6970
conn *websocket.Conn
7071
}
7172

@@ -86,12 +87,12 @@ func New(host string, password string) *Wattpilot {
8687
isInitialized: false,
8788
requestId: 0,
8889
data: make(map[string]interface{}),
89-
logger: log.New(),
90+
logger: logrus.New(),
9091
notify: NewPubsub(),
9192
}
9293

93-
w.logger.SetFormatter(&log.JSONFormatter{})
94-
w.logger.SetLevel(log.ErrorLevel)
94+
w.logger.SetFormatter(&logrus.JSONFormatter{})
95+
w.logger.SetLevel(logrus.ErrorLevel)
9596
if level := os.Getenv("WATTPILOT_LOG"); level != "" {
9697
if err := w.ParseLogLevel(level); err != nil {
9798
w.logger.Warn("Could not parse log level setting ", err)
@@ -116,15 +117,15 @@ func New(host string, password string) *Wattpilot {
116117

117118
}
118119
func (w *Wattpilot) SetLogger(logger *log.Logger) {
119-
w.logger = logger
120+
w.logger.SetOutput(logger)
120121
}
121122

122-
func (w *Wattpilot) SetLogLevel(level log.Level) {
123+
func (w *Wattpilot) SetLogLevel(level logrus.Level) {
123124
w.logger.SetLevel(level)
124125
}
125126

126127
func (w *Wattpilot) ParseLogLevel(level string) error {
127-
loglevel, err := log.ParseLevel(level)
128+
loglevel, err := logrus.ParseLevel(level)
128129
if err != nil {
129130
return err
130131
}

0 commit comments

Comments
 (0)