Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add configuration for structured (json) vs human-readable log format #26

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/wekafsplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func init() {
file = short
return file + ":" + strconv.Itoa(line)
}
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}).With().Caller().Logger()

}

Expand Down Expand Up @@ -82,6 +81,7 @@ var (
tracingUrl = flag.String("tracingurl", "", "OpenTelemetry / Jaeger endpoint")
allowInsecureHttps = flag.Bool("allowinsecurehttps", false, "Allow insecure HTTPS connection without cert validation")
alwaysAllowSnapshotVolumes = flag.Bool("alwaysallowsnapshotvolumes", false, "Allow snapshot-based volumes even when Weka cluster doesn't support capacity enforcement")
usejsonlogging = flag.Bool("usejsonlogging", false, "Use structured JSON logging rather than human-readable console log formatting")

// Set by the build process
version = ""
Expand All @@ -107,6 +107,9 @@ func mapVerbosity(verbosity int) zerolog.Level {

func main() {
flag.Parse()
if !*usejsonlogging {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}).With().Caller().Logger()
}
zerolog.SetGlobalLevel(mapVerbosity(*verbosity))

csiMode = wekafs.GetCsiPluginMode(csimodetext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ spec:
{{- if .Values.pluginConfig.allowInsecureHttps }}
- "--allowinsecurehttps"
{{- end }}
{{- if .Values.useJsonLogging }}
- "--usejsonlogging"
{{- end }}
ports:
- containerPort: 9898
name: healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ spec:
{{- if .Values.pluginConfig.allowInsecureHttps }}
- "--allowinsecurehttps"
{{- end }}
{{- if .Values.useJsonLogging }}
- "--usejsonlogging"
{{- end }}
ports:
- containerPort: 9898
name: healthz
Expand Down Expand Up @@ -186,4 +189,4 @@ spec:
secret:
secretName: {{ .Values.legacyVolumeSecretName }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ spec:
{{- if .Values.pluginConfig.allowInsecureHttps }}
- "--allowinsecurehttps"
{{- end }}
{{- if .Values.useJsonLogging }}
- "--usejsonlogging"
{{- end }}
ports:
- containerPort: 9898
name: healthz
Expand Down
2 changes: 2 additions & 0 deletions deploy/helm/csi-wekafsplugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ nodePluginTolerations: *globalPluginTolerations
nodeSelector: {}
# -- Log level of CSI plugin
logLevel: 5
# -- Use JSON structured logging instead of human-readable logging format (for exporting logs to structured log parser)
useJsonLogging: false
# -- for migration of pre-CSI 0.7.0 volumes only, default API secret. Must reside in same namespace as the plugin
legacyVolumeSecretName: ""
# -- Optional CSI Plugin priorityClassName
Expand Down