mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-15 07:11:15 +00:00
chore: replace logrus with standard lib log/slog
This commit is contained in:
@@ -3,10 +3,10 @@ package app
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/h44z/wg-portal/internal/adapters"
|
||||
@@ -50,7 +50,7 @@ func migrateFromV1(db *gorm.DB, source, typ string) error {
|
||||
return fmt.Errorf("unsupported old version, update to database version %s first: %w", latestVersion, err)
|
||||
}
|
||||
|
||||
logrus.Infof("Found valid V1 database with version: %s", lastVersion.Version)
|
||||
slog.Info("found valid V1 database", "version", lastVersion.Version)
|
||||
|
||||
if err := migrateV1Users(oldDb, db); err != nil {
|
||||
return fmt.Errorf("user migration failed: %w", err)
|
||||
@@ -64,7 +64,8 @@ func migrateFromV1(db *gorm.DB, source, typ string) error {
|
||||
return fmt.Errorf("peer migration failed: %w", err)
|
||||
}
|
||||
|
||||
logrus.Infof("Migrated V1 database with version %s, please restart WireGuard Portal", lastVersion.Version)
|
||||
slog.Info("migrated V1 database successfully, please restart WireGuard Portal",
|
||||
"version", lastVersion.Version)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -126,7 +127,7 @@ func migrateV1Users(oldDb, newDb *gorm.DB) error {
|
||||
return fmt.Errorf("failed to migrate user %s: %w", oldUser.Email, err)
|
||||
}
|
||||
|
||||
logrus.Debugf(" - User %s migrated", newUser.Identifier)
|
||||
slog.Debug("user migrated successfully", "identifier", newUser.Identifier)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -220,7 +221,7 @@ func migrateV1Interfaces(oldDb, newDb *gorm.DB) error {
|
||||
return fmt.Errorf("failed to migrate device %s: %w", oldDevice.DeviceName, err)
|
||||
}
|
||||
|
||||
logrus.Debugf(" - Interface %s migrated", newInterface.Identifier)
|
||||
slog.Debug("interface migrated successfully", "identifier", newInterface.Identifier)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -319,7 +320,7 @@ func migrateV1Peers(oldDb, newDb *gorm.DB) error {
|
||||
return fmt.Errorf("failed to migrate dummy user %s: %w", oldPeer.Email, err)
|
||||
}
|
||||
|
||||
logrus.Debugf(" - Dummy User %s migrated", user.Identifier)
|
||||
slog.Debug("dummy user migrated successfully", "identifier", user.Identifier)
|
||||
}
|
||||
newPeer := domain.Peer{
|
||||
BaseModel: domain.BaseModel{
|
||||
@@ -365,7 +366,7 @@ func migrateV1Peers(oldDb, newDb *gorm.DB) error {
|
||||
return fmt.Errorf("failed to migrate peer %s (%s): %w", oldPeer.Identifier, oldPeer.PublicKey, err)
|
||||
}
|
||||
|
||||
logrus.Debugf(" - Peer %s migrated", newPeer.Identifier)
|
||||
slog.Debug("peer migrated successfully", "identifier", newPeer.Identifier)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user