summaryrefslogtreecommitdiff
path: root/internal/db/bundb/bundb.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-07-19 09:47:55 +0100
committerLibravatar GitHub <noreply@github.com>2022-07-19 10:47:55 +0200
commit098dbe6ff4f59652181c8e0e3873fbfcf0e65ea3 (patch)
tree17036ad9db68c3080e1e91279c8bce9f9ea6e5c3 /internal/db/bundb/bundb.go
parent[bugfix] Markdown format fixes (#718) (diff)
downloadgotosocial-098dbe6ff4f59652181c8e0e3873fbfcf0e65ea3.tar.xz
[chore] use our own logging implementation (#716)
* first commit Signed-off-by: kim <grufwub@gmail.com> * replace logging with our own log library Signed-off-by: kim <grufwub@gmail.com> * fix imports Signed-off-by: kim <grufwub@gmail.com> * fix log imports Signed-off-by: kim <grufwub@gmail.com> * add license text Signed-off-by: kim <grufwub@gmail.com> * fix package import cycle between config and log package Signed-off-by: kim <grufwub@gmail.com> * fix empty kv.Fields{} being passed to WithFields() Signed-off-by: kim <grufwub@gmail.com> * fix uses of log.WithFields() with whitespace issues and empty slices Signed-off-by: kim <grufwub@gmail.com> * *linter related grumbling* Signed-off-by: kim <grufwub@gmail.com> * gofmt the codebase! also fix more log.WithFields() formatting issues Signed-off-by: kim <grufwub@gmail.com> * update testrig code to match new changes Signed-off-by: kim <grufwub@gmail.com> * fix error wrapping in non fmt.Errorf function Signed-off-by: kim <grufwub@gmail.com> * add benchmarking of log.Caller() vs non-cached Signed-off-by: kim <grufwub@gmail.com> * fix syslog tests, add standard build tags to test runner to ensure consistency Signed-off-by: kim <grufwub@gmail.com> * make syslog tests more robust Signed-off-by: kim <grufwub@gmail.com> * fix caller depth arithmatic (is that how you spell it?) Signed-off-by: kim <grufwub@gmail.com> * update to use unkeyed fields in kv.Field{} instances Signed-off-by: kim <grufwub@gmail.com> * update go-kv library Signed-off-by: kim <grufwub@gmail.com> * update libraries list Signed-off-by: kim <grufwub@gmail.com> * fuck you linter get nerfed Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
Diffstat (limited to 'internal/db/bundb/bundb.go')
-rw-r--r--internal/db/bundb/bundb.go16
1 files changed, 7 insertions, 9 deletions
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