From 098dbe6ff4f59652181c8e0e3873fbfcf0e65ea3 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 19 Jul 2022 09:47:55 +0100 Subject: [chore] use our own logging implementation (#716) * first commit Signed-off-by: kim * replace logging with our own log library Signed-off-by: kim * fix imports Signed-off-by: kim * fix log imports Signed-off-by: kim * add license text Signed-off-by: kim * fix package import cycle between config and log package Signed-off-by: kim * fix empty kv.Fields{} being passed to WithFields() Signed-off-by: kim * fix uses of log.WithFields() with whitespace issues and empty slices Signed-off-by: kim * *linter related grumbling* Signed-off-by: kim * gofmt the codebase! also fix more log.WithFields() formatting issues Signed-off-by: kim * update testrig code to match new changes Signed-off-by: kim * fix error wrapping in non fmt.Errorf function Signed-off-by: kim * add benchmarking of log.Caller() vs non-cached Signed-off-by: kim * fix syslog tests, add standard build tags to test runner to ensure consistency Signed-off-by: kim * make syslog tests more robust Signed-off-by: kim * fix caller depth arithmatic (is that how you spell it?) Signed-off-by: kim * update to use unkeyed fields in kv.Field{} instances Signed-off-by: kim * update go-kv library Signed-off-by: kim * update libraries list Signed-off-by: kim * fuck you linter get nerfed Signed-off-by: kim Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com> --- internal/db/bundb/bundb.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'internal/db/bundb/bundb.go') diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index d92318afd..784a7d443 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -33,13 +33,13 @@ import ( "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/stdlib" - "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/cache" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db/bundb/migrations" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" + "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/uptrace/bun" "github.com/uptrace/bun/dialect/pgdialect" "github.com/uptrace/bun/dialect/sqlitedialect" @@ -89,8 +89,6 @@ type bunDBService struct { } func doMigration(ctx context.Context, db *bun.DB) error { - l := logrus.WithField("func", "doMigration") - migrator := migrate.NewMigrator(db, migrations.Migrations) if err := migrator.Init(ctx); err != nil { @@ -106,11 +104,11 @@ func doMigration(ctx context.Context, db *bun.DB) error { } if group.ID == 0 { - l.Info("there are no new migrations to run") + log.Info("there are no new migrations to run") return nil } - l.Infof("MIGRATED DATABASE TO %s", group) + log.Infof("MIGRATED DATABASE TO %s", group) return nil } @@ -243,7 +241,7 @@ func sqliteConn(ctx context.Context) (*DBConn, error) { tweakConnectionValues(sqldb) if dbAddress == "file::memory:?cache=shared" { - logrus.Warn("sqlite in-memory database should only be used for debugging") + log.Warn("sqlite in-memory database should only be used for debugging") // don't close connections on disconnect -- otherwise // the SQLite database will be deleted when there // are no active connections @@ -260,7 +258,7 @@ func sqliteConn(ctx context.Context) (*DBConn, error) { return nil, fmt.Errorf("sqlite ping: %s", err) } - logrus.Info("connected to SQLITE database") + log.Info("connected to SQLITE database") return conn, nil } @@ -281,7 +279,7 @@ func pgConn(ctx context.Context) (*DBConn, error) { return nil, fmt.Errorf("postgres ping: %s", err) } - logrus.Info("connected to POSTGRES database") + log.Info("connected to POSTGRES database") return conn, nil } @@ -436,7 +434,7 @@ func (ps *bunDBService) EmojiStringsToEmojis(ctx context.Context, emojis []strin if err != nil { if err == sql.ErrNoRows { // no result found for this username/domain so just don't include it as an emoji and carry on about our business - logrus.Debugf("no emoji found with shortcode %s, skipping it", e) + log.Debugf("no emoji found with shortcode %s, skipping it", e) continue } // a serious error has happened so bail -- cgit v1.3