From 33efc8a2ec76920bd5bf6a5820d7d59eb2a64a8f Mon Sep 17 00:00:00 2001 From: Yin Da Date: Thu, 1 Sep 2022 10:35:16 +0800 Subject: [PATCH] Feat: add log args Signed-off-by: Yin Da --- cmd/apiserver/main.go | 1 + pkg/config/args_log.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 pkg/config/args_log.go diff --git a/cmd/apiserver/main.go b/cmd/apiserver/main.go index 1cc8ac4c..e50e032d 100644 --- a/cmd/apiserver/main.go +++ b/cmd/apiserver/main.go @@ -53,6 +53,7 @@ func main() { if err != nil { klog.Fatal(err) } + config.AddLogFlags(cmd.Flags()) config.AddSecretFlags(cmd.Flags()) config.AddClusterProxyFlags(cmd.Flags()) config.AddProxyAuthorizationFlags(cmd.Flags()) diff --git a/pkg/config/args_log.go b/pkg/config/args_log.go new file mode 100644 index 00000000..0007d1cb --- /dev/null +++ b/pkg/config/args_log.go @@ -0,0 +1,31 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +import ( + "flag" + + "github.com/spf13/pflag" + "k8s.io/klog/v2" +) + +// AddLogFlags add log flags to command +func AddLogFlags(set *pflag.FlagSet) { + fs := flag.NewFlagSet("", 0) + klog.InitFlags(fs) + set.AddGoFlagSet(fs) +}