mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:02:24 -05:00
[feature] Add log-db-queries config option (#465)
This commit is contained in:
parent
e74ec70dbf
commit
094f032f74
11 changed files with 43 additions and 15 deletions
|
|
@ -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: "",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue