diff options
author | 2022-04-18 16:47:11 +0200 | |
---|---|---|
committer | 2022-04-18 16:47:11 +0200 | |
commit | 094f032f747b96733982108f2e184df88d9b25ae (patch) | |
tree | a36209e2ca052cae14a88c0a4adce61702766d90 /internal | |
parent | [documentation] add screenshots to docs (#459) (diff) | |
download | gotosocial-094f032f747b96733982108f2e184df88d9b25ae.tar.xz |
[feature] Add log-db-queries config option (#465)
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/defaults.go | 1 | ||||
-rw-r--r-- | internal/config/keys.go | 6 | ||||
-rw-r--r-- | internal/config/values.go | 1 | ||||
-rw-r--r-- | internal/db/bundb/bundb.go | 4 |
4 files changed, 8 insertions, 4 deletions
diff --git a/internal/config/defaults.go b/internal/config/defaults.go index e400f6599..847f10c81 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -24,6 +24,7 @@ import "github.com/coreos/go-oidc/v3/oidc" // Note that if you use this, you still need to set Host and, if desired, ConfigPath. var Defaults = Values{ LogLevel: "info", + LogDbQueries: false, ApplicationName: "gotosocial", ConfigPath: "", Host: "", diff --git a/internal/config/keys.go b/internal/config/keys.go index 9b79bccc7..50a9c2fa7 100644 --- a/internal/config/keys.go +++ b/internal/config/keys.go @@ -21,8 +21,9 @@ package config // KeyNames is a struct that just contains the names of configuration keys. type KeyNames struct { // root - LogLevel string - ConfigPath string + LogLevel string + LogDbQueries string + ConfigPath string // general ApplicationName string @@ -109,6 +110,7 @@ type KeyNames struct { // and retrieving values from the viper config store. var Keys = KeyNames{ LogLevel: "log-level", + LogDbQueries: "log-db-queries", ApplicationName: "application-name", ConfigPath: "config-path", Host: "host", diff --git a/internal/config/values.go b/internal/config/values.go index ebee4e4b7..1c71e4e30 100644 --- a/internal/config/values.go +++ b/internal/config/values.go @@ -21,6 +21,7 @@ package config // Values contains contains the type of each configuration value. type Values struct { LogLevel string + LogDbQueries bool ApplicationName string ConfigPath string Host string diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index f190ce5ea..a79e7e4f4 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -136,9 +136,9 @@ func NewBunDBService(ctx context.Context) (db.DB, error) { return nil, fmt.Errorf("database type %s not supported for bundb", dbType) } - // add a hook to just log queries and the time they take + // add a hook to log queries and the time they take // only do this for logging where performance isn't 1st concern - if logrus.GetLevel() >= logrus.DebugLevel { + if logrus.GetLevel() >= logrus.DebugLevel && viper.GetBool(config.Keys.LogDbQueries) { conn.DB.AddQueryHook(newDebugQueryHook()) } |