Skip to content

Commit

Permalink
added 'all' as log mode and updated the help text
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Jan 22, 2025
1 parent 5e0a52f commit c3fe1a5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtcombo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Flags:
--querylog-buffer-size int Maximum number of buffered query logs before throttling log output (default 10)
--querylog-filter-tag string string that must be present in the query for it to be logged; if using a value as the tag, you need to disable query normalization
--querylog-format string format for query logs ("text" or "json") (default "text")
--querylog-mode string Mode for logging queries. 'error' will only log queries that return an error. Otherwise all queries will be logged.
--querylog-mode string Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged. (default "all")
--querylog-row-threshold uint Number of rows a query has to return or affect before being logged; not useful for streaming queries. 0 means all queries will be logged.
--querylog-sample-rate float Sample rate for logging queries. Value must be between 0.0 (no logging) and 1.0 (all queries)
--queryserver-config-acl-exempt-acl string an acl that exempt from table acl checking (this acl is free to access any vitess tables).
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vtgate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Flags:
--querylog-buffer-size int Maximum number of buffered query logs before throttling log output (default 10)
--querylog-filter-tag string string that must be present in the query for it to be logged; if using a value as the tag, you need to disable query normalization
--querylog-format string format for query logs ("text" or "json") (default "text")
--querylog-mode string Mode for logging queries. 'error' will only log queries that return an error. Otherwise all queries will be logged.
--querylog-mode string Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged. (default "all")
--querylog-row-threshold uint Number of rows a query has to return or affect before being logged; not useful for streaming queries. 0 means all queries will be logged.
--querylog-sample-rate float Sample rate for logging queries. Value must be between 0.0 (no logging) and 1.0 (all queries)
--redact-debug-ui-queries redact full queries and bind variables from debug UI
Expand Down
2 changes: 1 addition & 1 deletion go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Flags:
--query-log-stream-handler string URL handler for streaming queries log (default "/debug/querylog")
--querylog-filter-tag string string that must be present in the query for it to be logged; if using a value as the tag, you need to disable query normalization
--querylog-format string format for query logs ("text" or "json") (default "text")
--querylog-mode string Mode for logging queries. 'error' will only log queries that return an error. Otherwise all queries will be logged.
--querylog-mode string Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged. (default "all")
--querylog-row-threshold uint Number of rows a query has to return or affect before being logged; not useful for streaming queries. 0 means all queries will be logged.
--querylog-sample-rate float Sample rate for logging queries. Value must be between 0.0 (no logging) and 1.0 (all queries)
--queryserver-config-acl-exempt-acl string an acl that exempt from table acl checking (this acl is free to access any vitess tables).
Expand Down
27 changes: 16 additions & 11 deletions go/streamlog/streamlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ var (
[]string{"Log", "Subscriber"})
)

const QueryLogModeError = "error"
const (
// QueryLogFormatText is the format specifier for text querylog output
QueryLogFormatText = "text"

// QueryLogFormatJSON is the format specifier for json querylog output
QueryLogFormatJSON = "json"

// QueryLogModeAll is the mode specifier for logging all queries
QueryLogModeAll = "all"

// QueryLogModeError is the mode specifier for logging only queries that return an error
QueryLogModeError = "error"
)

type QueryLogConfig struct {
RedactDebugUIQueries bool
Expand All @@ -59,7 +71,8 @@ type QueryLogConfig struct {
}

var queryLogConfigInstance = QueryLogConfig{
Format: "text",
Format: QueryLogFormatText,
Mode: QueryLogModeAll,
}

func GetQueryLogConfig() QueryLogConfig {
Expand Down Expand Up @@ -95,17 +108,9 @@ func registerStreamLogFlags(fs *pflag.FlagSet) {
fs.Float64Var(&queryLogConfigInstance.sampleRate, "querylog-sample-rate", queryLogConfigInstance.sampleRate, "Sample rate for logging queries. Value must be between 0.0 (no logging) and 1.0 (all queries)")

// QueryLogMode controls the mode for logging queries (all or error)
fs.StringVar(&queryLogConfigInstance.Mode, "querylog-mode", queryLogConfigInstance.Mode, `Mode for logging queries. 'error' will only log queries that return an error. Otherwise all queries will be logged.`)
fs.StringVar(&queryLogConfigInstance.Mode, "querylog-mode", queryLogConfigInstance.Mode, `Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged.`)
}

const (
// QueryLogFormatText is the format specifier for text querylog output
QueryLogFormatText = "text"

// QueryLogFormatJSON is the format specifier for json querylog output
QueryLogFormatJSON = "json"
)

// StreamLogger is a non-blocking broadcaster of messages.
// Subscribers can use channels or HTTP.
type StreamLogger[T any] struct {
Expand Down

0 comments on commit c3fe1a5

Please sign in to comment.