From ef51e6dee0ea95e0b4d47845636df3255d9528e6 Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Fri, 7 Aug 2020 15:42:07 +0200 Subject: [PATCH] Adding zap controlled by CLI flags (#47) * Adding zap controlled by CLI flags * Updating contributing for further logs --- config/manager/manager.yaml | 2 ++ contributing.md | 5 +++-- main.go | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index d39b8b2b..2a834ab9 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -27,6 +27,8 @@ spec: - /manager args: - --enable-leader-election + - --zap-encoder=console + - --zap-log-level=debug image: quay.io/clastix/capsule:latest imagePullPolicy: IfNotPresent name: manager diff --git a/contributing.md b/contributing.md index b7a09ba9..699196cf 100644 --- a/contributing.md +++ b/contributing.md @@ -171,9 +171,10 @@ I0803 15:16:02.042022 1 main.go:281] Starting TCP socket on 0.0.0.0:8443 I0803 15:16:02.042364 1 main.go:288] Listening securely on 0.0.0.0:8443 ``` -Since Capsule is built using _OperatorSDK_, logging is handled by the zap +Since Capsule is built using _OperatorSDK_, logging is handled by the `zap` module: verbosity increase can be controlled using the CLI flag `--zap-level` -with a value from `1` to `10` or the [basic keywords](https://godoc.org/go.uber.org/zap/zapcore#Level). +with a value from `1` to `10` or the [basic keywords](https://godoc.org/go.uber.org/zap/zapcore#Level) +although is suggested to use the `zap-devel` flag to get also stacktraces. > CA generation > diff --git a/main.go b/main.go index 7c2b74a0..e73d690f 100644 --- a/main.go +++ b/main.go @@ -78,9 +78,11 @@ func main() { flag.BoolVar(&forceTenantPrefix, "force-tenant-prefix", false, "Enforces the Tenant owner, "+ "during Namespace creation, to name it using the selected Tenant name as prefix, separated by a dash. "+ "This is useful to avoid Namespace name collision in a public CaaS environment.") + opts := zap.Options{} + opts.BindFlags(flag.CommandLine) flag.Parse() - ctrl.SetLogger(zap.New(zap.UseDevMode(true))) + ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) printVersion() if v {