mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 03:56:36 +00:00
suppress dirty logs during import libraries (#1991)
Co-authored-by: Yin Da <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -12,6 +12,7 @@ require (
|
||||
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
|
||||
github.com/briandowns/spinner v1.11.1
|
||||
github.com/containerd/containerd v1.3.2
|
||||
github.com/coreos/prometheus-operator v0.41.1
|
||||
github.com/crossplane/crossplane-runtime v0.10.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright 2021. 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 preimport
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
var _flagSet *flag.FlagSet
|
||||
|
||||
// disable logging during import
|
||||
func init() {
|
||||
lvl, _ := log.ParseLevel("panic")
|
||||
log.L.Logger.SetLevel(lvl)
|
||||
_flagSet = flag.CommandLine
|
||||
klog.InitFlags(_flagSet)
|
||||
_ = _flagSet.Set("v", "-1")
|
||||
}
|
||||
|
||||
// Start recover logging
|
||||
func Start() {
|
||||
lvl, _ := log.ParseLevel("info")
|
||||
log.L.Logger.SetLevel(lvl)
|
||||
_ = _flagSet.Set("v", "0")
|
||||
}
|
||||
@@ -21,10 +21,12 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/oam-dev/kubevela/references/a/preimport"
|
||||
"github.com/oam-dev/kubevela/references/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
preimport.Start()
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
command := cli.NewCommand()
|
||||
|
||||
Reference in New Issue
Block a user