Skip to content

Commit 9267b56

Browse files
committed
🎨 Logging enhancements
1 parent 22746f9 commit 9267b56

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pkg/edgevpn/files.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020

2121
func (e *EdgeVPN) SendFile(ledger *blockchain.Ledger, fileID, filepath string) error {
2222

23-
e.Logger().Infof("Serving '%s' as '%s", filepath, fileID)
23+
e.Logger().Infof("Serving '%s' as '%s'", filepath, fileID)
2424

2525
// By announcing periodically our service to the blockchain
2626
ledger.Announce(
@@ -137,7 +137,7 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
137137
if err != nil {
138138
return err
139139
}
140-
e.config.Logger.Infof("Saving file %s to %s", fileID, path)
140+
e.Logger().Infof("Saving file %s to %s", fileID, path)
141141

142142
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
143143
if err != nil {
@@ -148,6 +148,6 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
148148

149149
f.Close()
150150

151-
e.config.Logger.Infof("Received file %s to %s", fileID, path)
151+
e.Logger().Infof("Received file %s to %s", fileID, path)
152152
return nil
153153
}

pkg/edgevpn/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress
7373
stream.Close()
7474
c.Close()
7575

76-
e.config.Logger.Info("(service %s) Handled correctly '%s'", serviceID, stream.Conn().RemotePeer().String())
76+
e.config.Logger.Infof("(service %s) Handled correctly '%s'", serviceID, stream.Conn().RemotePeer().String())
7777
}()
7878
}
7979
}

pkg/logger/logger.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (l Logger) Fatal(args ...interface{}) {
6969

7070
func (l Logger) Fatalf(f string, args ...interface{}) {
7171
if l.enabled(log.LevelFatal) {
72-
pterm.Fatal.Printfln(pterm.Red(joinMsg(args...)))
72+
pterm.Fatal.Printfln(pterm.Red(f), args...)
7373
}
7474
}
7575

@@ -81,7 +81,7 @@ func (l Logger) Info(args ...interface{}) {
8181

8282
func (l Logger) Infof(f string, args ...interface{}) {
8383
if l.enabled(log.LevelInfo) {
84-
pterm.Info.Printfln(pterm.LightBlue(joinMsg(args...)))
84+
pterm.Info.Printfln(pterm.LightBlue(f), args...)
8585
}
8686
}
8787

@@ -101,7 +101,7 @@ func (l Logger) Warn(args ...interface{}) {
101101

102102
func (l Logger) Warnf(f string, args ...interface{}) {
103103
if l.enabled(log.LevelWarn) {
104-
pterm.Warning.Printfln(pterm.LightYellow(joinMsg(args...)))
104+
pterm.Warning.Printfln(pterm.LightYellow(f), args...)
105105
}
106106
}
107107

0 commit comments

Comments
 (0)