Maint: pass only single strings to logger methods

- Do not assume formatting from logger's interface
- Allow to change golibs in the future to accept only strings for logger methods
This commit is contained in:
Quentin McGaw (desktop)
2021-07-23 17:36:08 +00:00
parent 21f4cf7ab5
commit 3c44214d01
34 changed files with 134 additions and 127 deletions

View File

@@ -70,9 +70,9 @@ func NewLooper(settings configuration.Updater, currentServers models.AllServers,
func (l *looper) logAndWait(ctx context.Context, err error) {
if err != nil {
l.logger.Error(err)
l.logger.Error(err.Error())
}
l.logger.Info("retrying in %s", l.backoffTime)
l.logger.Info("retrying in " + l.backoffTime.String())
timer := time.NewTimer(l.backoffTime)
l.backoffTime *= 2
select {
@@ -141,7 +141,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
case servers := <-serversCh:
l.setAllServers(servers)
if err := l.storage.FlushToFile(servers); err != nil {
l.logger.Error(err)
l.logger.Error(err.Error())
}
runWg.Wait()
l.state.setStatusWithLock(constants.Completed)

View File

@@ -69,7 +69,7 @@ func (u *updater) updateHideMyAss(ctx context.Context) (err error) {
ctx, u.client, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("HideMyAss: %s", warning)
u.logger.Warn("HideMyAss: " + warning)
}
}
if err != nil {
@@ -91,7 +91,7 @@ func (u *updater) updateIpvanish(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("Ipvanish: %s", warning)
u.logger.Warn("Ipvanish: " + warning)
}
}
if err != nil {
@@ -113,7 +113,7 @@ func (u *updater) updateIvpn(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("Ivpn: %s", warning)
u.logger.Warn("Ivpn: " + warning)
}
}
if err != nil {
@@ -150,7 +150,7 @@ func (u *updater) updateNordvpn(ctx context.Context) (err error) {
servers, warnings, err := nordvpn.GetServers(ctx, u.client, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("NordVPN: %s", warning)
u.logger.Warn("NordVPN: " + warning)
}
}
if err != nil {
@@ -188,7 +188,7 @@ func (u *updater) updatePrivado(ctx context.Context) (err error) {
ctx, u.unzipper, u.client, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("Privado: %s", warning)
u.logger.Warn("Privado: " + warning)
}
}
if err != nil {
@@ -210,7 +210,7 @@ func (u *updater) updatePrivatevpn(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("PrivateVPN: %s", warning)
u.logger.Warn("PrivateVPN: " + warning)
}
}
if err != nil {
@@ -231,7 +231,7 @@ func (u *updater) updateProtonvpn(ctx context.Context) (err error) {
servers, warnings, err := protonvpn.GetServers(ctx, u.client, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("ProtonVPN: %s", warning)
u.logger.Warn("ProtonVPN: " + warning)
}
}
if err != nil {
@@ -253,7 +253,7 @@ func (u *updater) updatePurevpn(ctx context.Context) (err error) {
ctx, u.client, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("PureVPN: %s", warning)
u.logger.Warn("PureVPN: " + warning)
}
}
if err != nil {
@@ -275,7 +275,7 @@ func (u *updater) updateSurfshark(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("Surfshark: %s", warning)
u.logger.Warn("Surfshark: " + warning)
}
}
if err != nil {
@@ -297,7 +297,7 @@ func (u *updater) updateTorguard(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("Torguard: %s", warning)
u.logger.Warn("Torguard: " + warning)
}
}
if err != nil {
@@ -341,7 +341,7 @@ func (u *updater) updateVyprvpn(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers)
if u.options.CLI {
for _, warning := range warnings {
u.logger.Warn("VyprVPN: %s", warning)
u.logger.Warn("VyprVPN: " + warning)
}
}
if err != nil {

View File

@@ -58,14 +58,14 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
if u.options.Fastestvpn {
u.logger.Info("updating Fastestvpn servers...")
if err := u.updateFastestvpn(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if err := ctx.Err(); err != nil {
return allServers, err
@@ -75,7 +75,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if u.options.HideMyAss {
u.logger.Info("updating HideMyAss servers...")
if err := u.updateHideMyAss(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if err := ctx.Err(); err != nil {
return allServers, err
@@ -85,7 +85,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if u.options.Ipvanish {
u.logger.Info("updating Ipvanish servers...")
if err := u.updateIpvanish(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if err := ctx.Err(); err != nil {
return allServers, err
@@ -95,7 +95,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if u.options.Ivpn {
u.logger.Info("updating Ivpn servers...")
if err := u.updateIvpn(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if err := ctx.Err(); err != nil {
return allServers, err
@@ -105,7 +105,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if u.options.Mullvad {
u.logger.Info("updating Mullvad servers...")
if err := u.updateMullvad(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if err := ctx.Err(); err != nil {
return allServers, err
@@ -116,7 +116,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
// TODO support servers offering only TCP or only UDP
u.logger.Info("updating NordVPN servers...")
if err := u.updateNordvpn(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if err := ctx.Err(); err != nil {
return allServers, err
@@ -126,7 +126,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if u.options.Privado {
u.logger.Info("updating Privado servers...")
if err := u.updatePrivado(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if ctx.Err() != nil {
return allServers, ctx.Err()
@@ -136,7 +136,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if u.options.PIA {
u.logger.Info("updating Private Internet Access servers...")
if err := u.updatePIA(ctx); err != nil {
u.logger.Error(err)
u.logger.Error(err.Error())
}
if ctx.Err() != nil {
return allServers, ctx.Err()
@@ -149,7 +149,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -159,7 +159,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -170,7 +170,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -180,7 +180,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -190,7 +190,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -200,7 +200,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -210,7 +210,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}
@@ -220,7 +220,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
if ctxErr := ctx.Err(); ctxErr != nil {
return allServers, ctxErr
}
u.logger.Error(err)
u.logger.Error(err.Error())
}
}