reference global logrus (#274)

* reference logrus' global logger instead of passing and storing a logger reference everywhere

* always directly use global logrus logger instead of referencing an instance

* test suites should also directly use the global logrus logger

* rename gin logging function to clarify that it's middleware

* correct comments which erroneously referenced removed logger parameter

* setting log level for tests now uses logrus' exported type instead of the string value, to guarantee error isn't possible
This commit is contained in:
R. Aidan Campbell 2021-10-11 05:37:33 -07:00 committed by GitHub
commit 083099a957
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
210 changed files with 506 additions and 662 deletions

View file

@ -24,6 +24,7 @@ import (
"crypto/rsa"
"database/sql"
"fmt"
"github.com/sirupsen/logrus"
"net"
"net/mail"
"strings"
@ -86,7 +87,7 @@ func (a *adminDB) IsEmailAvailable(ctx context.Context, email string) (bool, db.
func (a *adminDB) NewSignup(ctx context.Context, username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string, emailVerified bool, admin bool) (*gtsmodel.User, db.Error) {
key, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
a.conn.log.Errorf("error creating new rsa key: %s", err)
logrus.Errorf("error creating new rsa key: %s", err)
return nil, err
}
@ -183,7 +184,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error {
WhereGroup(" AND ", whereEmptyOrNull("domain"))
count, err := existsQ.Count(ctx)
if err != nil && count == 1 {
a.conn.log.Infof("instance account %s already exists", username)
logrus.Infof("instance account %s already exists", username)
return nil
} else if err != sql.ErrNoRows {
return a.conn.ProcessError(err)
@ -191,7 +192,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error {
key, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
a.conn.log.Errorf("error creating new rsa key: %s", err)
logrus.Errorf("error creating new rsa key: %s", err)
return err
}
@ -226,7 +227,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error {
return a.conn.ProcessError(err)
}
a.conn.log.Infof("instance account %s CREATED with id %s", username, acct.ID)
logrus.Infof("instance account %s CREATED with id %s", username, acct.ID)
return nil
}
@ -244,7 +245,7 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
return err
}
if exists {
a.conn.log.Infof("instance entry already exists")
logrus.Infof("instance entry already exists")
return nil
}
@ -269,6 +270,6 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
return a.conn.ProcessError(err)
}
a.conn.log.Infof("created instance instance %s with id %s", domain, i.ID)
logrus.Infof("created instance instance %s with id %s", domain, i.ID)
return nil
}