mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-05 10:19:06 -06:00
Merge pull request #5615 from dolthub/pavel/encode-logged-queries
Allow logging base64-encoded queries, instead of replacing bad chars.
This commit is contained in:
@@ -455,6 +455,7 @@ func getConfigFromServerConfig(serverConfig ServerConfig) (server.Config, error,
|
||||
serverConf.TLSConfig = tlsConfig
|
||||
serverConf.RequireSecureTransport = serverConfig.RequireSecureTransport()
|
||||
serverConf.MaxLoggedQueryLen = serverConfig.MaxLoggedQueryLen()
|
||||
serverConf.EncodeLoggedQuery = serverConfig.ShouldEncodeLoggedQuery()
|
||||
|
||||
return serverConf, nil, nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ const (
|
||||
defaultAllowCleartextPasswords = false
|
||||
defaultUnixSocketFilePath = "/tmp/mysql.sock"
|
||||
defaultMaxLoggedQueryLen = 0
|
||||
defaultEncodeLoggedQuery = false
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -129,6 +130,10 @@ type ServerConfig interface {
|
||||
// If this value is 0 then the query is not truncated and will be written to the logs in its entirety. If the value
|
||||
// is less than 0 then the queries will be omitted from the logs completely
|
||||
MaxLoggedQueryLen() int
|
||||
// ShouldEncodeLoggedQuery determines if logged queries are base64 encoded.
|
||||
// If true, queries will be logged as base64 encoded strings.
|
||||
// If false (default behavior), queries will be logged as strings, but newlines and tabs will be replaced with spaces.
|
||||
ShouldEncodeLoggedQuery() bool
|
||||
// PersistenceBehavior is "load" if we include persisted system globals on server init
|
||||
PersistenceBehavior() string
|
||||
// DisableClientMultiStatements is true if we want the server to not
|
||||
@@ -186,6 +191,7 @@ type commandLineServerConfig struct {
|
||||
tlsCert string
|
||||
requireSecureTransport bool
|
||||
maxLoggedQueryLen int
|
||||
shouldEncodeLoggedQuery bool
|
||||
persistenceBehavior string
|
||||
privilegeFilePath string
|
||||
branchControlFilePath string
|
||||
@@ -279,6 +285,13 @@ func (cfg *commandLineServerConfig) MaxLoggedQueryLen() int {
|
||||
return cfg.maxLoggedQueryLen
|
||||
}
|
||||
|
||||
// ShouldEncodeLoggedQuery determines if logged queries are base64 encoded.
|
||||
// If true, queries will be logged as base64 encoded strings.
|
||||
// If false (default behavior), queries will be logged as strings, but newlines and tabs will be replaced with spaces.
|
||||
func (cfg *commandLineServerConfig) ShouldEncodeLoggedQuery() bool {
|
||||
return cfg.shouldEncodeLoggedQuery
|
||||
}
|
||||
|
||||
// DisableClientMultiStatements is true if we want the server to not
|
||||
// process incoming ComQuery packets as if they had multiple queries in
|
||||
// them, even if the client advertises support for MULTI_STATEMENTS.
|
||||
|
||||
@@ -131,6 +131,7 @@ type UserSessionVars struct {
|
||||
type YAMLConfig struct {
|
||||
LogLevelStr *string `yaml:"log_level"`
|
||||
MaxQueryLenInLogs *int `yaml:"max_logged_query_len"`
|
||||
EncodeLoggedQuery *bool `yaml:"encode_logged_query"`
|
||||
BehaviorConfig BehaviorYAMLConfig `yaml:"behavior"`
|
||||
UserConfig UserYAMLConfig `yaml:"user"`
|
||||
ListenerConfig ListenerYAMLConfig `yaml:"listener"`
|
||||
@@ -442,6 +443,14 @@ func (cfg YAMLConfig) MaxLoggedQueryLen() int {
|
||||
return *cfg.MaxQueryLenInLogs
|
||||
}
|
||||
|
||||
func (cfg YAMLConfig) ShouldEncodeLoggedQuery() bool {
|
||||
if cfg.EncodeLoggedQuery == nil {
|
||||
return defaultEncodeLoggedQuery
|
||||
}
|
||||
|
||||
return *cfg.EncodeLoggedQuery
|
||||
}
|
||||
|
||||
// PersistenceBehavior is "load" if we include persisted system globals on server init
|
||||
func (cfg YAMLConfig) PersistenceBehavior() string {
|
||||
if cfg.BehaviorConfig.PersistenceBehavior == nil {
|
||||
|
||||
Reference in New Issue
Block a user